pylons

How To Create Per-Request Singleton in Pylons?

In our Pylons based web-app, we're creating a class that essentially provides some logging functionality. We need a new instance of this class for each http request that comes in, but only one per request. What is the proper way to go about this? Should we just create the object in middleware and store in in request.environ? Is there a ...

Cheking added file to upload python, pylons?

Hi! I try to upload file, how can i check if file is upload when i send empty input witch file upload i get AttributeError: 'unicode' object has no attribute 'filename' How can i check added file? ...

I'm searching for a messaging platform (like XMPP) that allows tight integration with a web application.

Hi, At the company I work for, we are building a cluster of web applications for collaboration. Things like accounting, billing, CRM etc. We are using a RESTfull technique: For database we use CouchDB Different applications communicate with one another and with the database via http. Besides, we have a single sign on solution, so tha...

TinyMce File browser for pylons?

Hi. Did you now some ajax based filebrowser to TinyMCE wich can i use in my pylons app? Thanks, for help :) ...

How to display multiple images?

I'm trying to get multiple image paths from my database in order to display them, but it currently doesn't work. Here's what i'm using: def get_image(self, userid, id): image = meta.Session.query(Image).filter_by(userid=userid) permanent_file = open(image[id].image_path, 'rb') if not os.path.exists(image.image_path): ...

Efficient way in Python to add an element to a comma-separated string

I'm looking for the most efficient way to add an element to a comma-separated string while maintaining alphabetical order for the words: For example: string = 'Apples, Bananas, Grapes, Oranges' addition = 'Cherries' result = 'Apples, Bananas, Cherries, Grapes, Oranges' Also, a way to do this but while maintaining IDs: string = '1:Ap...

Efficient way in Python to remove an element from a comma-separated string

I'm looking for the most efficient way to add an element to a comma-separated string while maintaining alphabetical order for the words: For example: string = 'Apples, Bananas, Grapes, Oranges' subtraction = 'Bananas' result = 'Apples, Grapes, Oranges' Also, a way to do this but while maintaining IDs: string = '1:Apples, 4:Bananas, ...

Can Django be used for web services?

My friend said, "Pylons is so much better for web services." My other friend said, "You can modify Django in a way to do exactly whatever you like." In Django, what is necessary to be modified (urls.py? models classes? settings?) in order to do "web services" with APIs and REST and versioning, etc etc.? ...

"Win32 exception occurred releasing IUnknown at..." error using Pylons and WMI

Hi all, Im using Pylons in combination with WMI module to do some basic system monitoring of a couple of machines, for POSIX based systems everything is simple - for Windows - not so much. Doing a request to the Pylons server to get current CPU, however it's not working well, or atleast with the WMI module. First i simply did (somethin...

Conditional operator in Mako using Pylons

In PHP, I often use the conditional operator to add an attribute to an html element if it applies to the element in question. For example: <select name="blah"> <option value="1"<?= $blah == 1 ? ' selected="selected"' : '' ?>> One </option> <option value="2"<?= $blah == 2 ? ' selected="selected"' : '' ?>> Two ...

In Pylons, how do I perform actions after writing the response?

In a pylons controller, I would like to first return the response to the request (so that the user gets a response ASAP), and then perform some additional operations (say, updating view counts, etc.) that didn't need to happen to generate the response. What's the best-practice for doing things like this? Thanks! ...

Are there viable alternatives for Web 2.0 apps besides lots of Javascript?

If you say find C-style syntax to be in the axis of evil are you just hopelessly condemned to suck it up and deal with it if you want to provide your users with cool web 2.0 applications - for example stuff that's generally done using JQuery and Ajax etc? Are there no other choices out there? We're currently building intranet apps usin...

Returning Database Blobs in TurboGears 2.x / FCGI / Lighttpd extremely slow

Hey everyone, I am running a TG2 App on lighttpd via flup/fastcgi. We are reading images (~30kb each) from BlobFields in a MySQL database and return those images with a custom mime type via a controller method. Caching these images on the hard disk makes no sense because they change with every request, the only reason we cache these in...

Framework Similar to Pylons for Ruby

I've been using Python for most of my web projects lately, and have come to really love the Pylons MVC framework. I like the incredible transparency (lack of magic), the built-in components they selected (sqlalchemy, formencode, routes), and the ability to easily change things up (use a different ORM or templating engine). Moving forwa...

Pylons and Pisa (xhtml2pdf): blank page in IE

I'm using pylons to serve a dynamically generated pdf document for reporting: my approach works in firefox & chrome (it displays the pdf inline if the plugin is available or otherwise downloads it) but IE (7 & 8) only show a blank page and doesn't prompt for download. IE correctly shows PDFs generated by other websites, though. Don't kn...

Set AUTO_INCREMENT using SqlAlchemy with MySQL on Columns with non-primary keys?

I can't figure out how to set AUTO_INCREMENT on a UNIQUE column using SqlAlchemy 0.6.0 with MySQL 5. I know this can be done in MySQL, but I don't want to have to distribute extra .sql scripts in order to set up the databases for my application. I want SqlAlchemy to build the schema from within Python. As far as I have found so far, th...

Can the Django urls.py system be turned into Pylon's Routes?

How can that be done? Thanks ...

What is (self) in the python code? (OOP question)

class MyController(BaseController): def index(self): # Return a rendered template #return render('/test.mako') # or, return a response return '' Why does the function "index" have "self"? I got this code from Pylons controller ...

Pylons interactive debugger UnboundExecutionError

Where I work, we use Pylons for our web development framework. Every so often when debugging an error using Pylons' interactive debugger, I encouter a traceback that includes the following type of error regarding a variable, etc. not being bound to a session: UnboundExecutionError: Instance is not bound to a Session; attribute refresh...

Importing fixtures with foreign keys and SQLAlchemy?

I've been experimenting with using fixture to load test data sets into my Pylons / PostgreSQL app. This works great except that it fails to properly create foreign keys if they reference an auto increment id field. My fixture looks like this: class AuthorsData(DataSet): class frank_herbert: first_name = "Frank" la...