python

Site wide caching with Django - problems with password protected pages on logout

I've recently implemented sitewide caching using memcached on my Django application, I've set the TTL to about 500 seconds, and implement per view caches on other parts of the web application. The problem I have is that when a user logs out, because it's a form post the site behaves as expected, however if they then go to a password pro...

Unable to get WAF to run

I am trying to build the Monotooth library on Ubuntu and there is a native component which needs to be compiled. The distro from github has a wscript file and requires WAF to build. However, whenever I try to execute waf configure I get: Checking for program gcc : ok /usr/bin/gcc Checking for program cpp ...

Run time of a subprocess.Popen instance

Is there an easy way to find out the current (real or cpu) run time of a subprocess.Popen instance? ...

Whats new in Python 3.x?

http://docs.python.org/dev/3.0/whatsnew/3.0.html says it lists whats new, but in my opinion, it only lists differences, so has does anybody know of any completely new Python features, introduced in release 3.x? To Avoid Confusion, I will define a completely new feature as something that has never been used in any other code before, some...

Types that define `__eq__` are unhashable in Python 3.x?

I had a strange bug when porting a feature to the Python 3.1 fork of my program. I narrowed it down to the following hypothesis: In contrast to Python 2.x, in Python 3.x if an object has a .__eq__ method it is automatically unhashable. Is this true? Here's what happens in Python 3.1: >>> class O(object): def __eq__(self, other): ...

Abstract base class inheritance in Django with foreignkey

I am attempting model inheritance on my Django powered site in order to adhere to DRY. My goal is to use an abstract base class called BasicCompany to supply the common info for three child classes: Butcher, Baker, CandlestickMaker (they are located in their own apps under their respective names). Each of the child classes has a need fo...

Filter a User list using a UserProfile field in Django Admin

I'm trying to filter the User list in Django using a UserProfile Field... I need to implement a queue system where new users are put in a queue until an Admin approves them. I simply added a is_in_queue boolean field to my UserProfile model... However, when displaying the user list in my Admin area, I realized that you can't filter the ...

How to make a private download area with django?

Hello I would like to implement a private download area on a website powered by django. The user would have to be logged in with the appropriate rights in order to be able to get some static files. What would you recommend for writing this feature. Any tips or tricks? Thanks in advance Update: Maybe because of my bad english or my la...

How import Pydev project into interactive console?

Newbie question (I'm just getting started with Python and Pydev): I've created a project "Playground" with (standard?) src/root sub-folder. In there I've created example.py. How do I import my "example" module into Pydev's interactive console? ">>> import example" gives: "ImportError: No module named example" ...

suds + jira = SAXException

I'm using Python 2.6 and suds 0.3.7 to interact with Jira 4.0. I connect to the jira server and and get information just fine. I.e., I can get all the details about any issue I want and that's great. What's not so great is that when I want to update an issue, I get a SAXException from suds (presumably). The exception is: WebFault: Se...

I need __closure__

I just checked out this very interesting mindmap: http://www.mindmeister.com/10510492/python-underscore And I was wondering what some of the new ones mean, like __code__ and __closure__. I googled around but nothing concrete. Does anyone know? ...

Python 3 xmlrpc for remote objects.

I am trying to implement a remote object implementation using xmlrpc, and python 3. I have tried the example at http://docs.python.org/3.1/library/xmlrpc.server.html?highlight=xmlrpc#simplexmlrpcserver-example, but it only works to and from localhost, how can I get it to work to and from internal IPs? ...

How do I display notifications from `django-notification`?

I've been reading the docs for django-notification, and they seem to cover creating notifications just fine, but not how to display them to users. Is there a good reference for this out there, and my Google-fu has just failed me? If not, can someone give me some pointers here? Thanks. ...

How to impose a time limit on a whole script in Python

The user is entering a python script in a Java GUI python-editor and can run it from the editor. Is there a way to take the user's script and impose a time limit on the total script? I'm familiar with how to this with functions / signal.alarm(but I'm on windows & unix Jython) but the only solution I have come up with is to put that scr...

sqlite3 Operation Error when doing many commits rapidly

I get sqlite3.OperationalError: SQL logic error or missing database when I run an application I've been working on. What follows is a narrowed-down but complete sample that exhibits the problem for me. This sample uses two tables; one to store users and one to record whether user information is up-to-date in an external directory sy...

C# equivalence of python maketrans and translate

Hi: Where could I find code of a C# equivalence of Python maketrans and translate? Thanks! ...

How to query a Django model defining a IP range with two int fields (IP, mask)

I have: class Range(models.Model): ip = models.IntegerField() # as produced by socket.inet_aton + struct.unpack mask = models.IntegerField() Given a certain IP, how can I get all the ranges that match this specific IP using the Django models? If I were using raw SQL, I would use the database's bitwise operators, but the Djang...

How do I unindent using IDLE (Python gui)

I want to write the following statment in IDLE (Python GUI) >>> if x == 0: ... x = 0 ... print('Negative changed to zero') ... elif x == 0: How can I get the unindention for the elif statment ? Some additional facts: I tried backspace and shift + tab, that doesn't help. Runing on Windows. Thanks. ...

confused __iter__

i am a reading the chapter on operator over flow and am very confused how __iter__ works. I have gone to several websites to find different examples but still dont quite understand how it works. I am wondering if someone has a really simple approach to on how to understand this function. Main problem on def__iter__(self): return self ...

Kill the process using its name inside linux (Python)

Hello, this works, but it kills every Python process. pkill python However, I cannot do: pkill myscript.py I have also tried killall, but with no luck either. Do I have to user regular expressions? By the way, I want to do this in a python script with import os. ...