pylons

How do I get an instance of BaseHTTPRequestHandler instantiated during request handling inside an action code?

I need to access the rfile and wfile properties of a request handler instance. AFAIK, such a handler is instantiated by the framework during request lifetime. Update: I found that rfile is accessible through request.environ['wsgi.input']. To access wfile I've do a hack with the additional line in Paste sources, httpserver.py:210: ,'wsg...

request.POST pylons, getting array like in php

Hi. I have a dynamic form, i must bulid some post array to field witch some id. For example: <input type="checkbox" name="field[124][]" value="1"> <input type="checkbox" name="field[124][]" value="2"> In php i can simply get value and key. foreach($_POST as $key => $value){ if(is_array($value){ foreach($value as $key2 => $value2...

How do I create a jinja2 filter and use it within pylons ?

Am going around the houses trying to find a way to implement a simple filter. I want to create the equivalent of some Smarty "tags" to make porting easier, notably {mail_to} http://www.smarty.net/manual/en/language.function.mailto.php I seem to be going around in circles between the jinga2 docs http://jinja.pocoo.org/2/documentation/...

Having some trouble creating my Model in Pylons

I've been reading the Pylons Book and, having got to the part about Models, realise it's out of date. So I then switched over to the official Pylons documentation for creating Models in Pylons 1.0 - http://pylonshq.com/docs/en/1.0/tutorials/quickwiki_tutorial/ I've followed what they've got and it's still failing. ./blog/model/init.py ...

How do I get some string values from Pylons controller be assigned to JavaScript variables with Mako?

I'm developing under Pylons using Mako templates. The problem is that I need to assign a string from some attribute of tmpl_context to a JavaScript variable in a page body. The additional problem is that this string can be quite arbitrary, ie can contain such characters like ", ', <, >, etc... Is there a common way to do such assignment?...

How can I make 'AJAX templates' in Pylons?

I've been getting into Pylons lately and was wondering how I could go about easily integrating AJAX functionality into my websites. Basically, lets say I had a login form that usually gets accessed via site.com/user/login. Now, generally, this will be handled via something like: class UserController(BaseController): def login(self):...

How can I combine the awesomness of SQLAlchemy and EAV DB schemas?

Aight ya'll, I gotta lay a Python question on you... I've been doing some work with Pylons recently and quite like the SQLAlchemy model for database interaction. There's one section of my website though which I think could benefit from an EAV schema. Using this as my table example: id | userid | type | value ---+--------+--------|--...

How to use multiple Sessions in a pylons app?

I've read "Multiple database connections with Python + Pylons + SQLAlchemy" and I get how to create multiple engines using that technique, but now I'm looking for advice on how to handle the creation of Sessions for these engines. Right now, the Session in my project is defined as per Pylons convention: myapp.model.meta.Session = scoped_...

Pylons, FormEncode and external validation

Hi everyone! I'm building a web frontend to a server-side application, using Pylons 1.0. Right now I'm writing the first form, and I'm facing a problem concerning validation.. Using FormEncode and the @validate decorator I can easily validate the user input from a client-side perspective, but when I submit the data to the server, it may...

Genshi: TemplateSyntaxError: not well-formed (invalid token) with ampersands in <script> tag

I'm using Pylons/Genshi, and trying to show 'all recent comments' on my site with a Disqus javascript widget (Disqus is installed on the site, and I can post comments OK). However, the code below produces a nasty 500 error: TemplateSyntaxError: not well-formed (invalid token): line 25, column 121 (line 25 is the <script> line). <d...

Pylons / SQLAlchemy - ConfigParser.MissingSectionHeaderError: File contains no section headers

I've been working on a Pylons site and just now started to create my database. I made my User model class and then issued paster setup-app development.ini. Worked great. However, now when I try to paster serve --reload development.ini, I get the following error: ConfigParser.MissingSectionHeaderError: File contains no section headers. ...

How can I create controller routes in Pylons for multi-part IDs?

By default the RESTful controller in Pylons supports single-part IDs for objects. This works for some kinds of objects, but my domain model has a set of objects that have composite identifiers, and I'd like to be able to build good URLs for those as well. This is what is currently supported: GET /advanis/saas/projects/id: Show a specif...

Cherokee + uWSGI + Pylons

I have successfully deployed a Django app with uWSGI + Cherokee. However, I want to experiment with Pylons before I go decide on Django. So far I have followed the instructions/recommendations here: http://stackoverflow.com/questions/2217679/deploying-pylons-with-uwsgi Paster serve works without a hitch. But when I try to serve via uWS...

Getting started with Pylons

Hello, I am just starting to use a web framework. I have decided I really like python and started looking at web frameworks. I don't really like django for a few reasons, but from what I have tried so far I found I really like pylons. The problem I have is that I can't find that many articles/tutorials about pylons, especially 1.0 art...

Pylons formencode - How do I POST an array of data?

I have a form that is similar to the following: Enter Name: Enter Age: [add more] That add more field copies the Name and Age inputs and can be clicked as many times as the user wants. Potentially, they could end up submitting 50 sets of Name and Age data. How can I handle this received data when it's posted to my Pylons application?...

Generating custom forms from DB schema

Hi, I am a current web2py user, but find I still go back to Django once in a while (where I started). Specifically when working on projects where I want to make use of some specific django apps/plugins/extensions that don't yet exist in web2py. One thing that I can't live without in web2py, which I am looking for a solution for in Dja...

What could cause a redirect loop with Pylons + uWSGI + Cherokee?

I had no issue with Django + uWSGI + Cherokee. BUt I would like to try pylons before committing to either framework. I followed the tutorial from pylonshq.com - 1.0/gettingstarted I ran into no problems when running pylons with paste. So I used instructions to run pylons with uWSGI from projects.unbit.it - uwsgi/wiki/UsePaste This is...

mod_wsgi and pylons: setting the working environment

I'm trying to setup Pylons (1.0) with Apache mod_wsgi. Everything works fine with mod_wsgi and I can run a simple python wsgi app just fine. I've got the quickwiki example from the Pylons site working when running it with paster, but obviously I would never deploy in such a manner - so I'm trying to get the Quickwiki example working w...

Python - Is my code effecient? Or are people going to have fun killing my server...?

Aight, basically, I have a database that looks like this: id | parentid | type | name --------------------------------------------- 1 | 0 | heading | this is my heading --------------------------------------------- 2 | 1 | child | this is one of many child elements I'm using Mako to go through that list of data an...

Where do I set common data for header in Pylons?

This is rather a general question about MVC. I have a set of templates for multiple controllers and their actions. All of them inherit from a overall template that contains footer/header. I want header to render email of currently logged in user. Common task. All tutorials are too simple to have basic example of how and where do I pa...