python

Python embedding with threads -- avoiding deadlocks?

Is there any way to embed python, allow callbacks from python to C++, allowing the Pythhon code to spawn threads, and avoiding deadlocks? The problem is this: To call into Python, I need to hold the GIL. Typically, I do this by getting the main thread state when I first create the interpreter, and then using PyEval_RestoreThread() to ...

How do you use FCKEditor's image upload and browser with mod-wsgi?

I am using FCKEditor within a Django app served by Apache/mod-wsgi. I don't want to install php just for FCKEditor andI see FCKEditor offers image uploading and image browsing through Python. I just haven't found good instructions on how to set this all up. So currently Django is running through a wsgi interface using this setup: impor...

Passing functions with arguments to another function in Python?

Is it possible to pass functions with arguments to another function in Python? Say for something like: def Perform ( function ) : function but the functions to be passed will be like: Action1() Action2(p) Action3(p,r) ...

Best way to convert a Unicode URL to ASCII (UTF-8 percent-escaped) in Python?

I'm wondering what's the best way -- or if there's a simple way with the standard library -- to convert a URL with Unicode chars in the domain name and path to the equivalent ASCII URL, encoded with domain as IDNA and the path %-encoded, as per RFC 3986. I get from the user a URL in UTF-8. So if they've typed in http://➡.ws/♥ I get 'htt...

Blogging System which runs on the Google App Engine

Hey, what is a cool blogging engine for GAE? I really like wordpress, but PHP isn't available on the GAE. Which blogging systems do you use on GAE? Which experiences you have made with it? Thanks. ...

Tool to determine what lowest version of Python required?

Is there something similar to Pylint, that will look at a Python script (or run it), and determine which version of Python each line (or function) requires? For example, theoretical usage: $ magic_tool <EOF with something: pass EOF 1: 'with' statement requires Python 2.6 or greater $ magic_tool <EOF class Something: @classmeth...

mod_wsgi yield output buffer instead of return

Right now I've got a mod_wsgi script that's structured like this.. def application(environ, start_response): status = '200 OK' output = 'Hello World!' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output...

How to consume XML from RESTful web services using Django / Python?

Should I use PyXML or what's in the standard library? ...

How to use subprocess when multiple arguments contain spaces?

I'm working on a wrapper script that will exercise a vmware executable, allowing for the automation of virtual machine startup/shutdown/register/deregister actions. I'm trying to use subprocess to handle invoking the executable, but the spaces in the executables path and in parameters of the executable are not being handled correctly by...

How to call a parent class's method from child class in python?

Stackers, I apologize for this question in advance. It must be a FAQ, but I don't seem to be able to find the answer. When creating a simple object hierarchy in python, I'd like to be able to invoke methods of the parent class from a derived class. In Perl and Java, there is a keyword for this (super). In Perl, I might do this: pa...

Server Side Google Markers Clustering - Python/Django

After experimenting with client side approach to clustering large numbers of Google markers I decided that it won't be possible for my project (social network with 28,000+ users). Are there any examples of clustering the coordinates on the server side - preferably in Python/Django? The way I would like this to work is to gradually inde...

Python "Task Server"

My question is: which python framework should I use to build my server? Notes: This server talks HTTP with it's clients: GET and POST (via pyAMF) Clients "submit" "tasks" for processing and, then, sometime later, retrieve the associated "task_result" submit and retrieve might be separated by days - different HTTP connections The "ta...

How can I get the results of a Perl script in Python script?

I have one script in Perl and the other in Python. I need to get the results of Perl in Python and then give the final report. The results from Perl can be scalar variable, hash variable, or an array. Please let me know as soon as possible regarding this. ...

Learning Graphical Layout Algorithms

During my day-to-day work, I tend to come across data that I want to visualize in a custom manner. For example, automatically creating a call graph similar to a UML sequence diagram, display digraphs, or visualizing data from a database (scatter plots, 3D contours, etc). For graphs, I tend to use GraphViz. For UML-like plots and 3D pl...

What is the best way to access stored procedures in Django's ORM.

I am designing a fairly complex database, and know that some of my queries will be far outside the scope of Django's ORM. Has anyone integrated SP's with Django's ORM successfully? If so, what RDBMS and how did you do it? ...

How to get field names when running plain sql query in django

In one of my django views I query database using plain sql (not orm) and return results. sql = "select * from foo_bar" cursor = connection.cursor() cursor.execute(sql) rows = cursor.fetchall() I am getting the data fine, but not the column names. How can I get the field names of the result set that is returned? ...

Is there a way to draw arbitrary annotations onto an existing Pmw.BLT.Graph instance?

I'm using Pmw.Blt.Graph to plot a line graph. I need to mark up this graph with additional data visualized in a way that Graph doesn't seem to be able to draw. (I thought I could use line_create's trace parameter to do it, but trace's behavior currently breaks when you change the axis mins and maxes, which I need to do.) Some possible...

Newbie teaching self python, what else should I be learning?

I'm a newbie to programming. I had 1 semester of computer science (we used java). I got an A in the course and was able to do everything assigned, however I'm not sure I really understood it. I ignored the text and learned by looking at sample programs and then trial and error. I was ahead of the class except for two guys who came in kn...

how to avoid hard-coding urls in webapp templates

I'm developing software on google app engine. I'm using the webapp framework. is there any way to avoid hard-coding urls in the html templates? django provides a solution, but I couldn't find one for webapp. thanks in advance.. ...

Sphinx automated image numbering/captions?

Is there a way to automatically generate an image/figure caption using sphinx? I currently have rest-sphinx files I'm converting to html and (latex)pdf using sphinx. I'd like an easy way for users to reference a specific image in the resulting html/pdf files. For example, if a user is refering to the documentation in an email, "In 'Ima...