python

How can you dispatch on request method in Django URLpatterns?

It's clear how to create a URLPattern which dispatches from a URL regex: (r'^books/$', books), where books can further dispatch on request method: def books(request): if request.method == 'POST': ... else: ... I'd like to know if there is an idiomatic way to include the request method inside the URLPattern, ...

Is there a 'hello world' website for django? OR (I've installed django, now what) ?

I'm learning Python and decided to start familiarizing myself with the (defacto?) Python web framework - django. I have successfully installed the latest release of django. I want a simple 'hello world' website that will get me up and running quickly. I am already familiar with web frameworks (albeit for different languages) - so I just...

Matching 3 out 5 fields - Django

Hi folks, I'm finding this a bit tricky! Maybe someone can help me on this one I have the following model: class Unicorn(models.Model): horn_length = models.IntegerField() skin_color = models.CharField() average_speed = models.IntegerField() magical = models.BooleanField() affinity = models.CharField() I would like to sea...

PyQt4 Move QTableWidget row with widgets

I have the following method in my PyQt4 app. r2 is the number of row to move, and r1 is the position where it should be moved. To clarify: the table is filled with cellWidgets, not widgetItems. def move_row(self, r1, r2): tt = self.tableWidget tt.insertRow(r1) for c in range(tt.columnCount()): tt.setCellWidget(r1, c,...

Is there an OR filter? - Django

Hi folks, is there any way of doing the following Unicorn.objects.or_filter(magical=True).or_filter(unicorn_length=15).or_filter(skin_color='White').or_filter(skin_color='Blue') where or_filter stands for an isolated match I remember using something similar but cannot find the function anymore! Help would be great! Thanks :) ...

installing paramiko on Windows

This may sound like a repeated question on SF, but I could not find a clear answer to it, yet.So. I installed Paramiko 1.7 with "setup.py install" command and while running the demo.py program, I got this error: Traceback (most recent call last): File "C:\Documents and Settings\fixavier\Desktop\paramiko-1.7\demos\demo.py", line 33, ...

any gae library for form-validation ,and show error data in the web-front using javascript..

i want to find this framework thanks ...

Upon USB insert, record unique identifer sting, format drive to FAT32 and copy a file. Bash or Python.

Hello, This is what I want to do, insert USB flash drive. mount it. record uniquie identifer string to a file. format the drive to FAT32. copy a text file to the drive. unmount it. remove the drive. 30 times The situation is this, I have bought 30 usb drives. I need to format each one to ensure they are clean, I need the unique str...

How to convert a GEOS MultiLineString to Polygon using Python?

I am developing a GeoDjango application where users can upload map files and do some basic mapping operations like querying features inside polygons. I recognized that users happen to upload "MultiLineString"s instead of "Polygon"s sometimes. This causes the queries expecting closed geometries to fail. What is the best way to convert...

CSRF error when trying to log onto Django admin page with w3m on Emacs23

I normally use Firefox and have had no problems with the admin page on my Django website. But I use Emacs23 for writing my posts, and wanted to be able to use w3m in Emacs to copy the stuff across. When I try to log into my admin pages, it gives the CSRF error: CSRF verification failed. Request aborted. Help Reason given for failure...

Add Header section to SOAP request using SOAPpy

Hello! I need to construct this SOAP query using python SOAPpy module: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt; <soap:Header> <LicenseHeader xmlns="http://schemas....

Is it possible to make Python etags a bit smarter with emacs?

I work on my Django project with emacs. In my virtualenv "postactivate" script I have the following simple command: find -L . -type f -name "*.py" | xargs etags -e > /dev/null 2>&1 & The TAGS file generates just fine but the system seems rather dumb. When the cursor is a model filter call, e.g. MyModel.objects.filter(...) and I hit...

Python and IronPython on same machine?

I am a total newbie in the Python world. I want to start to experiment with Python and IronPython and compare the results. Is it possible to install Python and IronPython on the same machine with interfering each other or is it besser to this in the virtual machine. Thx in advance. ...

Forced naming of parameters in python

In python you may have a function definition: def info(object, spacing=10, collapse=1) which could be called in any of the following ways: info(odbchelper) info(odbchelper, 12) info(odbchelper, collapse=0) info(spacing=15, object=odbchelper) thanks to python's allowing of any-order argume...

feedparser - various errors

I need feedparser (se http://www.feedparser.org) for a project, and want to keep third party modules in a separate folder. I did this by adding a folder to my python path, and putting relevant modules there, among them feedparser. This first attempt to import feedparser resulted in >>> import feedparser Traceback (most recent call last...

Is safe ( documented behaviour? ) to delete the domain of an iterator in execution

I wanted to know if is safe ( documented behaviour? ) to delete the domain space of an iterator in execution in Python. Consider the code: import os import sys sampleSpace = [ x*x for x in range( 7 ) ] print sampleSpace for dx in sampleSpace: print str( dx ) if dx == 1: del sampleSpace[ 1 ] del sampleSpace...

whats the best way to parse and replace the string with its values ?

I may have string like, """Hello, %(name)s, how are you today, here is amount needed: %(partner_id.account_id.debit_amount)d """ what would be the best solution for such template may i need to combine regular expression and eval, input string may differ like $partner_id.account_id.debit_amount$ - for the moment I've kept as python st...

Send a .png file using python cgi

Hi all, How can I send a .png file using python cgi to a flex application? Thanks in advance... ...

Qt -> PyQT problem with drawCheck()

Hi, I have QTableView with checkbox, but the checkbox is aligned left I need to align it center I try this: http://qt.nokia.com/developer/faqs/faq.2008-01-03.2614755816 But have problem with check function def drawCheck(self, painter, option, rect, state): textMargin = QtGui.QApplication.style().pixelMetric(QtGui.QStyle.PM_FocusF...

Reading and writing pickles to an encoded stream

A file format commonly used in our system is base64 encoded pickles - at the moment I can translate to and from strings in this trivial format with some simple code like this: def dumps( objinput ): """ Return an encoded cPickle """ return cpickle_dumps( objinput ).encode( ENCODING ) def loads( strinput ): """ R...