pylons

How to run a clone of reddit.com website. Reddit.com source code gives error while implementing on Ubuntu 9.10 (karmic)

Hello Everybody!! I am implementing the reddit.com source code on ubuntu karmic 9.10. I have followed all the steps and in one step where i am using paster command it throws an error. $paster shell example.ini File "/usr/local/lib/python2.6/dist-packages/Pylons-0.9.6.2- py2.6.egg/pylons/middleware.py", line 11, in from webhelper...

Setting a property from the Pylons .ini file

Let's say I have a settings.py file in my app's root folder (/myapp/myapp/settings.py) with just a bunch of variables in it: var1 = '' var2 = '' Can I automatically set one of those variables from the .ini file? I tried this: myapp.settings.var1 = 'this is from development.ini' But when I call var1 it is still the empty string: i...

Pylons application Internationalization

What the best way to make pylons application internationalist? ...

Unable to access database from within a method

I keep receiving the error, "TypeError: 'Shard' object is unsubscriptable." #Establish an on-demand connection to the central database def connectCentral(): engine = engine_from_config(config, 'sqlalchemy.central.') central.engine = engine central.Session.configure(bind=engine) #Establish an on-demand connection to a shard ...

What is the proper way to pass errors from classes to rendered html in python

I'm performing all my form validation in a class, and would like to be able to get the errors from the class to the rendered html. One approach I was thinking about was to create a global variable "c" that would store all the errors and to set them from within the class, as I still want the individual methods to return false when they f...

What is a good way to handle database objects in python classes?

Should I access global db object directly from within the methods of each class? Or from each method, should I instantiate an instance of the db object? One of my database objects changes depending on the id of the info being accessed so it is created through a function connectToDatabase(id). Should I make this a global function, ha...

Python try/except ... function always returns false

I'm trying to figure out the problem in this short paragraph of code. Any help would be appreciated. Regardless of what I specify User.email to be, it always returns false. def add(self): #1 -- VALIDATE EMAIL ADDRESS #Check that e-mail has been completed try: #Validate if e-mail address is in correct format ...

Creating a global function, accessible from all classes, with Python + Pylons

Using pylons 0.9.7, I'm trying to make a function that connects to a database on demand. I'd like it to be accessible from all functions within all model classes. In model/__init__.py, I have: #Establish an on-demand connection to the central database def connectCentral(): engine = engine_from_config(config, 'sqlalchemy.central.'...

Database-Independent MAX() Function in SQLAlchemy

I'd like to calculate a MAX() value for a column. What's the proper way to do this in sqlalchemy while preserving database independence? ...

If I'm only planning to use MySQL, and if speed is a priority, is there any convincing reason to use SQLAlchemy?

SQLAlchemy seems really heavyweight if all I use is MySQL. Why are convincing reasons for/against the use of SQLAlchemy in an application that only uses MySQL. ...

Uploading files different servers at once using a single html Form

Is there a way to make a form where it can simultaneously upload to several servers at once? Currently in my web application, I am asking the users to type in some info + select a few files to upload. Title, Description, Info, etc File 0 File 1 File 2 File ... On the backend, I'm using Pylons. Currently it accepts POST of (info + ...

Global function in __init__.py not accessible using Pylons + Python

I'm having trouble creating a global function accessible from within all classes. I receive an error from within user.py that says: NameError: global name 'connectCentral' is not defined Here is my current code. project/model/__ init __.py: """The application's model objects""" import sqlalchemy as sa from sqlalchemy im...

Integrating SQLAlchemy's ORM with existing classes in pylons.

I have a class in my existing python project, User, that I would like to map to tables. But I'm not sure what the best way to do this is? Does this mean I can remove: class User: pass from my model/__ init __.py? Or should I leave that in there, and have something like: from project.model.user import User class User: pass ...

In mako, how can I cycle through a list and display each value?

I have a Python list that I'm supplying to the template: {'error_name':'Please enter a name', 'error_email':'Please enter an email'} And would like to display: <ul> <li>Please enter a name</li> <li>Please enter an email</li> </ul> ...

What are some good ways (quick to implement and easy to tweak) to create an ajax-enabled form in Pylons?

Are there alternatives to manually coding the JS and HTML? Is there a Pylons-way to do this? Sample code is appreciated. ...

Why does python + pylons "remember" previously specified class variables?

I have a simple form in python + pylons that submits to a controller. However, each page load doesn't seem to be a fresh instantiation of the class. Rather, class variables specified on the previous page load are still accessible. What's going on here? And what's the solution? ...

Can nginx forward to Pylons, ignore response, return alternate response?

Hi All, One of my URLs is for a tracking cookie. In the basic configuration, the pylons controller parses the query string, does a DB query, and sets the cookie accordingly. I want to move to nginx. I am wondering if this is possible: nginx fetches value of cookie from memcached nginx writes the headers and serves static file nginx r...

What are the helpful online resources there for Python beginners?

Specifically for the ff: topics: Windows installation Using mod_wsgi/mod_python Python best practices Python security stuff Using Pylons Thanks ...

Logging in worker threads spawned from a pylons application does not seem to work

I have a pylons application where, under certain cirumstances I want to spawn multiple worker threads to process items in a queue. Right now we aren't making use of a ThreadPool (would be ideal, but we'll add that in later). The main problem is that the worker threads logging does not get written to the log files. When I run the code ou...

In a pylons web app, should a cookie be set from a model class or a controller?

Trying to figure out the best way to do this: Should I do something like: def index(self): if request.POST: u = User(id) u.setCookie() #All session logic in def setCookie() Or set the cookie in the controller like: def index(self): if request.POST: u = User(id) response.set_cookie('session_key...