pylons

pylons on production server fedora 8

I'm interested in learning some python, and thought Pylons would be a good starting point (after spending 2 days trying to get django working -- to no avail). I have an Amazon EC2 instance with Fedora 8 on it. It is a bare-bones install. I am halfway through my second day of trying to get it to work. I have mod_wsgi installed. I have A...

Proper way to set object instance variables

I'm writing a class to insert users into a database, and before I get too far in, I just want to make sure that my OO approach is clean: class User(object): def setName(self,name): #Do sanity checks on name self._name = name def setPassword(self,password): #Check password length > 6 characters ...

Proper way in Python to raise errors while setting variables

What is the proper way to do error-checking in a class? Raising exceptions? Setting an instance variable dictionary "errors" that contains all the errors and returning it? Is it bad to print errors from a class? Do I have to return False if I'm raising an exception? Just want to make sure that I'm doing things right. Below is some...

Error handling with Python + Pylons

What is the proper way to handle errors with Python + Pylons? Say a user sets a password via a form that, when passed to a model class via the controller, throws an error because it's too short. How should that error be handled so that an error message gets displayed on the web page rather than the entire script terminating to an error...

Python MySQLdb placeholders syntax

I'd like to use placeholders as seen in this example: cursor.execute (""" UPDATE animal SET name = %s WHERE name = %s """, ("snake", "turtle")) Except I'd like to have the query be its own variable as I need to insert a query into multiple databases, as in: query = """UPDATE animal SET name = %s WHERE name = %s...

Simplest way to handle and display errors in a Python Pylons controller without a helper class

I have a class User() that throw exceptions when attributes are incorrectly set. I am currently passing the exceptions from the models through the controller to the templates by essentially catching exceptions two times for each variable. Is this a correct way of doing it? Is there a better (but still simple) way? I prefer not to u...

config['pylons.g'] AttributeError pylons

Having the following error AttributeError: 'NoneType' object has no attribute 'sa_engine' on this line in model/init.py Session = scoped_session(sessionmaker(autoflush=True, autocommit=False, bind=config['pylons.g'].sa_engine)) When printing config dictionary, it has 'pylons.g' key but value at this key is None. I do not understand ...

What is a really simple explanation of unit testing?

I've never done any unit testing before, and would like to learn what it is and how it can be useful in my Python code. I've read through a few Python unit testing tutorials online but they're all so complicated and assume an extended programming background. I'm using Python with Pylons to create a simple web app. Any simple examp...

Pylons: View latest debug message

Is there a way to view the latest debug message instead of having to copy and paste something like "_debug/view/1269848287" to the browser everytime? ...

Get a user's timezone in Python + Pylons

Is there a way to get the timezone of the connecting user using Pylons, and to adjust the content before rendering accordingly? Or can this only be done by JS? Thanks. ...

What is the most efficient way to populate class attributes with a row from a database query?

Looking to have a database query set all the instance variables in a class: Example: def populate(self, if): #Perform mysql query self._name = row['name'] self._email = row['email'] ... What's the fastest way to do this? Or is this not recommended (with a better approach)? Thanks. ...

Pylons: Set global variable for Authkit user

How can I can set a global variable for the username of the logged-in user? At the moment i have the following code in all my controllers to get the username. I rather set it as a global variable if possible. request.environ.get("REMOTE_USER") I tried putting the same code in the app_globals.py file but it gave me the following error m...

Losing 'post' requests sent to Pylons paster server

I'm sending post requests to a Pylons server (served by paster serve), and if I send them with any frequency many don't arrive at the server. One at a time is ok, but if I fire off a few (or more) within seconds, only a small number get dealt with. If I send with no post data, or with get, it works fine, but putting just one character of...

Where did Pylons beautiful error handling go? Using Nginx + Paster + Flup#fcgi_thread

I need to run my development through nginx due to some complicated subdomain routing rules in my pylons app that wouldn't be handled otherwise. I had been using lighttpd + paster + Flup#scgi_thread and the nice error reporting by Pylons had been working fine in that environment. Yesterday I recompiled Python and MySQL for 64bit, and al...

Pylons check for cookie on every page load

Hi -- I want to check whether or not a cookie is set with every page load in Pylons. Where's the best place to put this logic? Thanks! ...

Pylons redirect to 404 error page

What function to I use to redirect to the default 404 error page? Sample code appreciated. Thank you! ...

How to configure for multiple gettext domains with babel, pylons, setuptools

While trying to internationalize my pylons web and mobile application, 'myapp', Im finding that I would like to keep separate gettext pot files for separate domains. There will be common msgid values for both web and mobile users and there will also be unique msgid values that are only translated for web or mobile users. Im expecting l...

SECURITY Flaws in this design for User authentication.

SECURITY Flaws in this design for User authentication. From: http://wiki.pylonshq.com/display/pylonscookbook/Simple+Homegrown+Authentication Note: a. Project follows the MVC pattern. b. Only a user with a valid username and password is allowed submit something. Design: a. Have a base controller from which all controllers ...

Cache the result of a MySQLdb database query in memory

Our application fetches the correct database server from a pool of database servers. So each query is really 2 queries, and they look like this: Fetch the correct DB server Execute the query We do this so we can take DB servers online and offline as necessary, as well as for load-balancing. But the first query seems like it could b...

Is there an admin plugin for Python Pylon?

Im moving from django to pylons, is there an admin app? ...