python

Does the Python library httplib2 cache URIs with GET strings?

In the following example what is cached correctly? Is there a Vary-Header I have to set server-side for the GET string? import httplib2 h = httplib2.Http(".cache") resp, content = h.request("http://test.com/list/") resp, content = h.request("http://test.com/list?limit=10") resp, content = h.request("http://test.com/list?limit=50") ...

can pylons + authkit ignore particular responses with 401 status?

hey all ... i am writing a pylons app, and I am using authkit for authentication/authorization. if a user is not logged in and hits a page that requires authorization, authkit swallows the 401 (not authenticated) response and redirects to a login page. this is great for the web interface, but not great for our web services. when an una...

Self-repairing Python threads

Hi guys, I've created a web spider that accesses both a US and EU server. The US and EU servers are the same data structure, but have different data inside them, and I want to collate it all. In order to be nice to the server, there's a wait time between each request. As the program is exactly the same, in order to speed up processing, ...

Paypal NVP API with Django

I am looking into using the paypal NVP API to allow users to pay on my website for a recurring subscription. I have a few questions about the requirements. Will my site have to meet the "PCI Compliance" stuff. I guess I will have to get an SSL certificate and is there anything else that is required or that I need to know about? ...

How to install SimpleJson Package for Python

http://pypi.python.org/pypi/simplejson I am just diving into the Python world and want to make a simple twitter application which requires the installation of simplejson but not sure how I can set it up and get it working.. I am on a Windows System ...

Unable to put Python code to Joomla

I have a Python code from Google app engine. I need to implement it to Joomla. How can you implement Python code to Joomla? [edit after the 1st answer] It is enough for me that I can put the code to a module position. ...

Changing the title of a Tab in wx.Notebook

I'm experimenting with wxPython, I have a tabbed interface (notebook) and each tab is basically a file list view (yes, I'm trying to make a file manager) The file list inherits from wx.ListCtrl, and the tabbed interface inherits from wx.Notebook I'm just starting .. and I had it so double clicking on a folder will cd into that folder,...

App Engine - problem trying to set a Model property value

Hi, I'm pretty new to app engine, and I'm trying to set a bit of text into the app engine database for the first time. Here's my code: def setVenueIntroText(text): venue_obj = db.GqlQuery("SELECT * FROM Venue").get() venue_obj.intro_text = text # Works if I comment out db.put(venue_obj) # These two lines This ...

Reversible version of compile() in Python

I'm trying to make a function in Python that does the equivalent of compile(), but also lets me get the original string back. Let's call those two functions comp() and decomp(), for disambiguation purposes. That is, a = comp("2 * (3 + x)", "", "eval") eval(a, dict(x=3)) # => 12 decomp(a) # => "2 * (3 + x)" The returned string does not...

How can I batch rename files?

Hello, I'm looking for a script (Perl, Python or batch would be fine) that will go through a designated file tree and renames all the child files. For example, Folder1>File1.anytype becomes Folder1>Folder1File1.anytype. Thanks ...

Django Template - New Variable Declaration

Let me preface by I am just starting Python so if this is really a simple question ^_^ I have a html file with the following content: {%for d in results%} <div class="twt"> <img src="{{ d.profile_image_url }}" width="48px" height="48px" /> <span> {{ d.text }} </span> <span class="date">{{ d.created_at }}</span> </div> {...

How can you make a vote-up-down button like in Stackoverflow?

Problems how to make an Ajax buttons (upward and downward arrows) such that the number can increase or decrease how to save the action af an user to an variable NumberOfVotesOfQuestionID I am not sure whether I should use database or not for the variable. However, I know that there is an easier way too to save the number of votes. H...

Python 3: formatting zip module arguments correctly (newb)

Please tell me why this code fails. I am new and I don't understand why my formatting of my zip arguments is incorrect. Since I am unsure how to communicate best so I will show the code, the error message, and what I believe is happening. #!c:\python30 # Filename: backup_ver5.py import os import time import zipfile source = r'"C:\D...

What is the purpose of python's inner classes?

Python's inner/nested classes confuse me. Is there something that can't be accomplished without them? If so, what is that thing? ...

How do I set Session name with Cherrypy?

In PHP I would do it like this: session_name("special_session_name"); So how do I do it with Cherrypy? Just need to find exact equivalent for it. PHP manual page: http://fi2.php.net/session_name ...

What is the best ordered dict implementation in python?

I've seen (and written) a number of implementations of this. Is there one that is considered the best or is emerging as a standard? What I mean by ordered dict is that the object has some concept of the order of the keys in it, similar to an array in PHP. odict from PEP 372 seems like a strong candidate, but it's not totally clear tha...

How can domain aliases be set up using Django?

I am working on creating a website in Django which consists of two parts: the website itself, and the forum. They will both be on separate domains, i.e. example.com and exampleforum.com. How can this be done in Django, when the forum and main site are part of the same instance? ...

Help Me Figure Out A Random Scheduling Algorithm using Python and PostgreSQL

I am trying to do the schedule for the upcoming season for my simulation baseball team. I have an existing Postgresql database that contains the old schedule. There are 648 rows in the database: 27 weeks of series for 24 teams. The problem is that the schedule has gotten predictable and allows teams to know in advance about weak parts...

How do I apply Django model Meta options to models that I did not write?

I want to apply the "ordering" Meta option to the Django model User from django.contrib.auth.models. Normally I would just put the Meta class in the model's definition, but in this case I did not define the model. So where do I put the Meta class to modify the User model? ...

Find Hyperlinks in Text using Python (twitter related)

How can I parse text and find all instances of hyperlinks with a string? The hyperlink will not be in the html format of test but just http://test.com Secondly, I would like to then convert the original string and replace all instances of hyperlinks into clickable html hyperlinks. I found an example in this thread: http://stackoverflo...