pylons

Best Practices for Python UnicodeDecodeError

青春壹個敷衍的年華 提交于 2019-11-29 00:29:00
I use Pylons framework, Mako template for a web based application. I wasn't really bother too deep into the way Python handles the unicode strings. I had tense moment when I did see my site crash when the page is rendered and later I came to know that it was related to UnicodeDecodeError . After seeing the error, I started mesh around my Python code adding encode, decode calls for string with 'ignore' option but still I could not see the errors gone sometime. Finally I used to decode to ascii with ignore and made the site running without any crash. Input to my site comes through many sites.

Debug Pylons application through Eclipse

血红的双手。 提交于 2019-11-28 21:14:15
问题 I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp? 回答1: Create a new launch configuration (Python Run) Main tab Use paster-script.py as main module (you can find it in the Scripts sub-directory in your python installation directory) Don't forget to add the root folder of your application in the PYTHONPATH zone

With sqlalchemy how to dynamically bind to database engine on a per-request basis

拜拜、爱过 提交于 2019-11-28 18:03:27
I have a Pylons-based web application which connects via Sqlalchemy (v0.5) to a Postgres database. For security, rather than follow the typical pattern of simple web apps (as seen in just about all tutorials), I'm not using a generic Postgres user (e.g. "webapp") but am requiring that users enter their own Postgres userid and password, and am using that to establish the connection. That means we get the full benefit of Postgres security. Complicating things still further, there are two separate databases to connect to. Although they're currently in the same Postgres cluster, they need to be

Handle mysql restart in SQLAlchemy

一笑奈何 提交于 2019-11-28 17:07:16
My Pylons app uses local MySQL server via SQLAlchemy and python-MySQLdb. When the server is restarted, open pooled connections are apparently closed, but the application doesn't know about this and apparently when it tries to use such connection it receives "MySQL server has gone away": File '/usr/lib/pymodules/python2.6/sqlalchemy/engine/default.py', line 277 in do_execute cursor.execute(statement, parameters) File '/usr/lib/pymodules/python2.6/MySQLdb/cursors.py', line 166 in execute self.errorhandler(self, exc, value) File '/usr/lib/pymodules/python2.6/MySQLdb/connections.py', line 35 in

SQLAlchemy, clear database content but don't drop the schema

社会主义新天地 提交于 2019-11-28 16:58:23
I'm developing a Pylons app which is based on exisitng database, so I'm using reflection. I have an SQL file with the schema that I used to create my test database. That's why I can't simply use drop_all and create_all . I would like to write some unit tests and I faced the problem of clearing the database content after each test. I just want to erase all the data but leave the tables intact. Is this possible? The application uses Postgres and this is what has to be used also for the tests. I asked about the same thing on the SQLAlchemy Google group, and I got a recipe that appears to work

How to efficiently manage frequent schema changes using sqlalchemy?

拟墨画扇 提交于 2019-11-28 14:25:23
问题 I'm programming a web application using sqlalchemy. Everything was smooth during the first phase of development when the site was not in production. I could easily change the database schema by simply deleting the old sqlite database and creating a new one from scratch. Now the site is in production and I need to preserve the data, but I still want to keep my original development speed by easily converting the database to the new schema. So let's say that I have model.py at revision 50 and

python list to newline separated value

柔情痞子 提交于 2019-11-28 12:54:42
Im trying to get data in pylon to use in jquery autocomplete, the librarary i'm using for autocomplete it requires this format abc pqr xyz and in python i have data in this format [["abc"], ["pqr"],["xyz"] How do i convert this list to the above one. Edit: I trying to use these for a autocompete and i'm using pylons, in which the query to the server return list in this format [["abc"], ["pqr"],["xyz"] http://jquery.bassistance.de/autocomplete/demo/ this library except remote call in abc pqr xyz i tried to use "\n".join(item[0] for item in my_list) but it returns data in firebug like this. 'asd

sqlalchemy existing database query

折月煮酒 提交于 2019-11-28 06:02:40
I am using SQLAlchemy as ORM for a python project. I have created few models/schema and it is working fine. Now I need to query a existing MySQL database, no insert/update just the select statement. How can I create a wrapper around the tables of this existing database? I have briefly gone through the sqlalchemy docs and SO but couldn't find anything relevant. All suggest execute method, where I need to write the raw sql queries, while I want to use the SQLAlchemy query method in same way as I am using with the SA models. For example if the existing db has table name User then I want to query

Check if a user has a permission in pyramid (pylons 2)?

半世苍凉 提交于 2019-11-28 05:49:49
问题 How do i check if a user has a permission in pyramid. For example, I want to show some HTML only if a user has some permission, but have the view available for everybody. 回答1: The usual method is: from pyramid.security import has_permission has_permission('view', someresource, request) See also http://docs.pylonsproject.org/projects/pyramid/1.0/narr/security.html#debugging-imperative-authorization-failures and http://docs.pylonsproject.org/projects/pyramid/1.0/api/security.html#pyramid

Which is faster, python webpages or php webpages? [closed]

岁酱吖の 提交于 2019-11-28 04:20:41
Which is faster, python webpages or php webpages? Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php? I know that serving a python base webpage via cgi is slower than php because of its long start up every time. I enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons. Ross It sounds like you don't want to compare the two languages , but that you want to compare two web