pylons

Random ids in sqlalchemy (pylons)

余生颓废 提交于 2019-12-09 06:14:21
问题 I'm using pylons and sqlalchemy and I was wondering how I could have some randoms ids as primary_key. 回答1: the best way is to use randomly generated UUIDs: import uuid id = uuid.uuid4() uuid datatypes are available natively in some databases such as Postgresql (SQLAlchemy has a native PG uuid datatype for this purpose - in 0.5 its called sqlalchemy.databases.postgres.PGUuid ). You should also be able to store a uuid in any 16 byte CHAR field (though I haven't tried this specifically on MySQL

How come I can not activate my Virtual Python Environment with 'source env/bin/activate' command?

北城以北 提交于 2019-12-09 04:37:31
问题 I am trying to activate my Virtual Python Environment to use with Pylons but I think I am executing the commands wrong. jem@jem-laptop:~$ source env/bin/activate bash: env/bin/activate: No such file or directory What am I doing wrong? How should I do it right? 回答1: I realize I had to do jem@jem-laptop:~$ ls Desktop examples.desktop Public shortener.rb Documents Mac4Lin_v1.0 ruby-1.9.1-p378 Templates Downloads Music rubygems-1.3.7 Videos Dropbox Pictures setcolors.vim virtualenv.py And here we

Creating a new virtualenv hangs

怎甘沉沦 提交于 2019-12-08 20:19:32
问题 I have a macbookpro. I downloaded virtualenv.py from pylonsbook.com/virutalenv.py when I type: python virtualenv.py --no-site-packages env it outputs: New python executable in env/bin/python then it just hangs, I don't get the prompt in terminal. I've restarted the computer and I get the same result, what's wrong? 回答1: Have you tried to easy_install virtualenv instead? Getting the most updated version is never a bad idea. (Also, that link WFM on my MacBook. After that prompt it installs

How to get multiple parameters with same name from a URL in Pylons?

一笑奈何 提交于 2019-12-08 18:39:46
问题 So unfortunately I find myself in the situation where I need to modify an existing Pylons application to handle URLs that provide multiple parameters with the same name. Something like the following... domain:port/action?c=1&v=3&c=4 Conventionally the parameters are accessed this way... from pylons import request c = request.params.get("c") #or c = request.params["c"] This will return "4" as the value in either case, because ignoring all but the last value seems to be the standard behavior in

Pyramid Framework - Can you call two seperate view functions to the same template

五迷三道 提交于 2019-12-08 14:42:29
I was playing around with the pyramid framework, and I was wondering if it is possible to call two view functions to the same template: so for example: def view1(request) args1 = 'a string' return render_to_response('page.mak',{'args1'=args1}, request=request) def view2(request) args2 = 'a string 2' return render_to_response('page.mak',{'args2'=args2}, request=request) So, note both are using the page.mak template. {'args1'=args1} is not valid Python. {'args1':args1} is though. Yes it is. Why do you suspect this would be a problem? Have you tried it and hit some error? 来源: https:/

Django idiosyncrasies

筅森魡賤 提交于 2019-12-08 07:32:17
问题 I recently started using Django 1.5.4 for a web app with MySQL backend. Just at the outset, I encountered certain limitations that makes me wonder is Django the right way to go ahead. Some glaring shortcomings are: Lack of composite primary keys. The bug has been open for 8 years. Isn't this bad for an app that relies on a lot of many-to-many tables to have a unnecessary auto primary key and work around with unique_together attribute. Reference: - http://comments.gmane.org/gmane.comp.python

Pyramid Framework - Can you call two seperate view functions to the same template

与世无争的帅哥 提交于 2019-12-08 06:34:06
问题 I was playing around with the pyramid framework, and I was wondering if it is possible to call two view functions to the same template: so for example: def view1(request) args1 = 'a string' return render_to_response('page.mak',{'args1'=args1}, request=request) def view2(request) args2 = 'a string 2' return render_to_response('page.mak',{'args2'=args2}, request=request) So, note both are using the page.mak template. 回答1: {'args1'=args1} is not valid Python. {'args1':args1} is though. 回答2: Yes

Using Parallels to test Web applications in IE

限于喜欢 提交于 2019-12-07 10:36:26
问题 I am developing a Web application in Pylons on the Mac. My development server serves pages to http://127.0.0.1:5000/. Is there any way that I can access this page from Parallels for testing with IE without having to set up a development environment in Windows? 回答1: The loopback address (127.0.0.1) is only accessible by your local machine. In this case Parallels is considered another (virtual) machine. While Parallels can be configured to use the same IP address as the host operating system,

Changing database per view & accessing multiple databases per view

雨燕双飞 提交于 2019-12-07 07:07:11
问题 I'm having some problems using SQLAlchemy in Pyramid. Although I can find examples of what I need, they're normally very short and lacking. So I've ended up with patchy code that barely makes any sense. So I'm hoping someone could give a fuller example of what I need to do. I have 4 databases all with the same schema. I want to be able to work on them from one Pyramid app, sometimes listing all "orders" from all 4 databases, sometimes just listing all "orders" from "site1". As the schemas are

Turbomail Integration with Pyramid

邮差的信 提交于 2019-12-07 06:43:08
问题 I am in need of a method to send an email from a Pyramid application. I know of pyramid_mailer, but it seems to have a fairly limited message class. I don't understand if it's possible to write the messages from pyramid_mailer using templates to generate the body of the email. Further, I haven't seen anything regarding whether rich-text is supported, or if it's just simple plain-text. Previously, I was using Turbomail with the Pylons framework. Unfortunately there doesn't appear to be any