pylons

Using Pylons global variables with JavaScript (escaping brackets)

独自空忆成欢 提交于 2019-12-20 07:07:30
问题 I am trying to access a result in a dictionary held in a Python global variable within JavaScript. var selected = jQuery('.target option:selected').text() var list = "${c.persons_by_permission["+selected+"]}" If I directly access the dictionary without the using the variable: var list = "${c.persons_by_permission['stringID']}" Then the code works. However, when I am trying to use the variable to access the dictionary I get a syntax error (I believe its because of the curly braces). I have

UnicodeEncodeError: 'latin-1' codec can't encode character

痴心易碎 提交于 2019-12-17 04:13:08
问题 What could be causing this error when I try to insert a foreign character into the database? >>UnicodeEncodeError: 'latin-1' codec can't encode character u'\u201c' in position 0: ordinal not in range(256) And how do I resolve it? Thanks! 回答1: Character U+201C Left Double Quotation Mark is not present in the Latin-1 (ISO-8859-1) encoding. It is present in code page 1252 (Western European). This is a Windows-specific encoding that is based on ISO-8859-1 but which puts extra characters into the

Pylons Uploading Distorted Images on Windows

ⅰ亾dé卋堺 提交于 2019-12-14 02:15:43
问题 I'm creating an web app in Pylons, and am working on an image upload action. This is currently running using egg:paste#http on my windows machine, in the basic development configuration described in the pylons documentation quickstart. When I POST an image to my application, then move the image to the web root directory, then pull the uploaded image up in the browser, the image appears distorted. This is what I got when i uploaded a GIF of the Yahoo! logo, but most files don't show up in the

Schema qualified tables with SQLAlchemy, SQLite and Postgresql?

跟風遠走 提交于 2019-12-13 11:42:41
问题 I have a Pylons project and a SQLAlchemy model that implements schema qualified tables: class Hockey(Base): __tablename__ = "hockey" __table_args__ = {'schema':'winter'} hockey_id = sa.Column(sa.types.Integer, sa.Sequence('score_id_seq', optional=True), primary_key=True) baseball_id = sa.Column(sa.types.Integer, sa.ForeignKey('summer.baseball.baseball_id')) This code works great with Postgresql but fails when using SQLite on table and foreign key names (due to SQLite's lack of schema support)

Pylons: Sharing SQLAlchemy MySQL connection with external library

浪尽此生 提交于 2019-12-13 02:18:14
问题 I am running Pylons using SQLAlchemy to connect to MySQL, so when I want to use a database connection in a controller, I can do this: from myapp.model.meta import Session class SomeController(BaseController): def index(self): conn = Session.connection() rows = conn.execute('SELECT whatever') ... Say my controller needs to call up an external library, that also needs a database connection, and I want to provide the connection for it from the SQLAlchemy MySQL connection that is already

Pyramid pserve.exe syntax error

雨燕双飞 提交于 2019-12-12 22:23:42
问题 I have created a pyramid application using pcreate, now when I try to run it using pserve with --reload, I get following error SyntaxError: Non-ASCII character '\x90' in file <path>\pserve.exe on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details Interestingly this error shows up only when I use --reload, if I remove reload it starts fine. After debugging, I see another file pserve-script.py at the same location of pserve.exe and this python script is

Database-Independent MAX() Function in SQLAlchemy

时光总嘲笑我的痴心妄想 提交于 2019-12-12 14:24:12
问题 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? 回答1: You can find aggregate functions in: from sqlalchemy import func func.avg(...) func.sum(...) func.max(...) In 0.5 you can use an ORM query like a select: session.query(func.max(Table.column)) 来源: https://stackoverflow.com/questions/2358634/database-independent-max-function-in-sqlalchemy

Run Pylons controller as separate app?

前提是你 提交于 2019-12-12 07:47:18
问题 I have a Pylons app where I would like to move some of the logic to a separate batch process. I've been running it under the main app for testing, but it is going to be doing a lot of work in the database, and I'd like it to be a separate process that will be running in the background constantly. The main pylons app will submit jobs into the database, and the new process will do the work requested in each job. How can I launch a controller as a stand alone script? I currently have: from

Pylons application Internationalization

﹥>﹥吖頭↗ 提交于 2019-12-12 04:45:45
问题 What the best way to make pylons application internationalist? 回答1: A Google search finds these docs. 回答2: PyICU and I highly recommend Babel. Also if you need SEO you should read this: http://my.opera.com/WebApplications/blog/2008/03/17/search-engine-friendly If want more info (you can start using babel in five minutes), read the pylons book its free: http://pylonsbook.com/en/1.1/internationalization-and-localization.html 来源: https://stackoverflow.com/questions/2341387/pylons-application

How to create/modify the controller class generated by pylons?

妖精的绣舞 提交于 2019-12-11 13:24:05
问题 Say I wanted to add some imports to the file generated when I run: paster controller controllern_name Is this possible? 回答1: I assume you want to modify the pylons templates -- in this case controller.py_tmpl . It's best to create your own set of templates based on the ones from pylons, and then use them when starting a new project. 来源: https://stackoverflow.com/questions/3699796/how-to-create-modify-the-controller-class-generated-by-pylons