python

What is better for web development Python+Django or PHP+Symfony ?

What is better for web development Python+Django or PHP+Symfony ? And why? ...

Framework/service for hosting and managing files

Hi, in a webapp I'm building there is a planned side feature of supporting product illustrations and manuals (so pictures and PDFs), possibly arranged in galleries. As I'd rather not implement from scratch all of the uploading, managing and serving of this content, I'm looking for existing solutions which I could integrate. For example...

Django: How to write the reverse function for the following

The urlconf and view is as follows: url(r'^register/$', register, { 'backend': 'registration.backends.default.DefaultBackend' }, name='registration_register'), def register(request, backend, success_url=None, form_class=None, ...

Facebook authentication with extended permission request

Hi there, I'm wondering which authentication method to use if i need extended permissions (e.g. if i want to use the users photos in my application). The methods are either the single-sign on using JavaScript SDK or by using the OAuth 2.0 protocol. Both methods are explained here: Authentication - Facebook developers. The JS SDK would b...

How do I TRUNCATE TABLE using Django orm?

Hello! To empty database table, I use this SQL Query: TRUNCATE TABLE `books` How to I Truncate table using Django models and orm? I've tried this, but it doesn't work: Book.objects.truncate() ...

Open/Close database connection in django

I am using Django and Postgresql as my DBMS. I wish to set a setting that enables to enable/disable database connection. When the connection is set to closed (in settings.py) the site will display a message such as "meintanence mode" or something like that. Django will not show any db connection error message (or mail them to admins). I...

Detect a tag in hook-script SVN

Is there a way that I can detect a tag/branch in SVN? Could I find out where the commits destination is? I want to check that all externals are set to a specific version of the folder they are pointing to, I don't want to prevent commits to a tag with this script. I am writing the script with the c-python bindings. ...

Python import error: Symbol not found, but the symbol <s>is</s> *is not* present in the file

I get this error when I try to import ssrc.spread: ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ssrc/_spread.so, 2): Symbol not found: __ZN17ssrcspread_v1_0_67Mailbox11ZeroTimeoutE The file in question (_spread.so) includes the symbol: $ nm _spread.so | grep _ZN17ssrcspread_v1_0_67M...

python - file copy completion?

In Linux, How can we know if a file has completed copying before reading it?. (In Windows, OSError is raised.) ...

logger chain in python

I'm writing python package/module and would like the logging messages mention what module/class/function they come from. I.e. if I run this code: import mymodule.utils.worker as worker w = worker.Worker() w.run() I'd like to logging messages looks like this: 2010-06-07 15:15:29 INFO mymodule.utils.worker.Worker.run <pid/threadid>:...

PythonMagickWand Shepards Distortion (ctypes LP_c_double problem)

I am trying to use PythonMagickWand to use a Shepards distortion on an image. You can also see the source of distort.c that is used by ImageMagick. PythonMagickWand does not by default support Shepards distortion. To fix this, I added in: ShepardsDistortion = DistortImageMethod(15) to line 544 of PythonMagickWand (See here for my modi...

Filtering rows withing Admin using a Queryset - Django

Hi folks, I'm trying to find a way to filter down rows of objects within Django Admin, using a queryset. e.g. Person.objects.filter(Q(name='John')|Q(surname='Doe')) I'm finding quite complicated to figure out. Any ideas? ...

stdout and stderr anomalies

from the interactive prompt: >>> import sys >>> sys.stdout.write('is the') is the6 what is '6' doing there? another example: >>> for i in range(3): ... sys.stderr.write('new black') ... 9 9 9 new blacknew blacknew black where are the numbers coming from? ...

Python - detect keyboard layout

Playing around with RFID reader in serial, using python to output to console through uinput/ The thing is, doing the conversion from fake-rfid-keyboard-codes to code sent to uinput/, I would better know if I am using a QWERTY or an AZERTY ('a' becoming 'q', etc...) Back here in Belgium, especially during the event I am working on we ar...

How to make string from regex and value of group

I have regexp for twitter profile url and someone's twitter profile url. I can easily extract username from url. >>> twitter_re = re.compile('twitter.com/(?P<username>\w+)/') >>> twitter_url = 'twitter.com/dir01/' >>> username = twitter_re.search(twitter_url).groups()[0] >>> _ 'dir01' But if I have regexp and username, how do I get ur...

javascript [jQuery and GooG viz] with a datasource

Hi, My first attempts at JS / Jquery - I'm trying to setup a page where i can populate a table from data that is stored in a database. I now have a Python datasource up and running which seems to works fine - i've also managed to hack up something that is able to display that on a page (code below). I found a datepicker on the jQuery ...

How to pass file descriptors from parent to child in python?

Hi, I am using multiprocessing module, and using pools to start multiple workers. But the file descriptors which are opened at the parent process are closed in the worker processes. I want them to be open..! Is there any way to pass file descriptors to be shared across parent and children? ...

Assigning IDs to instances of a class (Pythonic)

I want to have each instance of some class have a unique integer identifier based on the order that I create them, starting with (say) 0. In Java, I could do this with a static class variable. I know I can emulate the same sort of behavior with Python, but what would be the most 'Pythonic' way to do this? Thanks ...

How can I find all the possible combinations of a list of lists (in Python)?

I have the following structure in Python: letters = [['a', 'b', 'c'], ['p', 'q', 'r', 's'], ['j', 'k', 'l']] I would like to find all the possible combinations of letters in the order that they currently exist. For the example above this would be: apj apk apl aqj aqk aql ... csk csl This seems like it should be a very simple thing ...

Fast method call scheduling in Python

Hi all! For some part of my project I need a process-local scheduling system that will allow me to delay method execution on few seconds. I have thousands of “clients” of this system, so using threading.Timer for each delay is a bad idea because I will quickly reach OS thread limit. I've implemented a system that use only one thread for...