pylons

Pyramid.security questions: Double cookies? Insecure cookies? Expiration?

ⅰ亾dé卋堺 提交于 2019-12-05 03:45:48
I'm taking my first foray into the Pyramid security module. I'm using this login code to set the auth_tkt: @view_config(route_name='LoginForm', request_method='POST', renderer='string') class LoginForm(SimpleObject): def __call__(self): emailAddress = self.request.params.get('emailAddress') password = self.request.params.get('password') if emailAddress != 'testemail@gmail.com' or password != 'testpassword': errorDictionary = { 'message' : "Either the email address or password is wrong." } self.request.response.status = 400 return json.dumps( errorDictionary, default=json_util.default)

Pylons, SQlite and autoincrementing fields

早过忘川 提交于 2019-12-04 21:09:42
问题 Hey! Just started working with Pylons in conjunction with SQLAlchemy, and my model looks something like this: from sqlalchemy import Column from sqlalchemy.types import Integer, String from helloworld.model.meta import Base class Person(Base): __tablename__ = "person" id = Column(Integer, primary_key=True) name = Column(String(100)) email = Column(String(100)) def __init__(self, name='', email=''): self.name = name self.email = email def __repr__(self): return "<Person('%s')" % self.name To

What is the method of doing nl2br in Genshi?

三世轮回 提交于 2019-12-04 20:07:36
hiyas. I using Genshi+Pylons. please teach me, how use \n to <br/>tag in Genshi? I hope to obtain the same result as " nl2br " in php to change line. Or, does not the solution exist? i'm assign template to some text. (genshi template) <p>${c.message}</p> Im tried. case 1: (python code) c.message = """ foo bar """ NG. display result is "foo bar" case 2: (python code) c.message = """ foo<br /> bar """ NG. display result is "foo<br />bar". displayed escaped stirings! It was a same deal as <br/> as for <br />. Postscript. I want to avoid using the pre tag. thanks. When it is not easy to read

Pylons - Changing the regular 404 Not Found page to a custom one

≯℡__Kan透↙ 提交于 2019-12-04 19:47:21
How do I change the regular 404 page generated by Pylons to my own custom-made 404 page? Thanks in advance, John From what I know, you have to edit your ErrorController in appname/controllers/error.py and change the "document" method. def document(self): return render('/my_errors/blah.mako') Read that for more details: http://wiki.pylonshq.com/display/pylonsdocs/Error+Documents#changing-the-template Just create your view and use add_notfound_view configuration method to configure it. See: http://docs.pylonsproject.org/docs/pyramid/en/latest/api/config.html?highlight=document%20error#pyramid

Python pyramid - How to use checkboxes and radio buttons

北慕城南 提交于 2019-12-04 18:36:51
I've been trying to make a form with checkboxes and radio button using Pyramid framework but I can't figure out how to do it properly. I'm using the pyramid_simpleform . So far I've been able to put my checkboxes on the form using a for loop but I can't make any checkbox checked even if I specify checked=True . % for item in groups: ${form.checkbox(name="groups",label=item, value=item, checked=True)} % endfor I know there's a better way of doing this. Is there any examples I could look at. All the examples in pyramid's documentation are simple text fields. I didn't find any radio button or

I'm using Pylons and having issues with response.set_cookie

放肆的年华 提交于 2019-12-04 17:04:24
I am thinking one of the versions of Pylons is different but I could not find an easy way to tell what versions I was running. In the first example I am fairly certain it is 0.9.7 and up using webob to set the cookie. This environment is setting the @ symbol to \100. As you can see in the other environment doing the exact same thing sets the value properly. Any assistance would be appreciated if you need further information let me know. Newer version of Pylons (I think) setting the value incorrectly response.set_cookie('email', 'user@domain.com', max_age=3600) response.headers ResponseHeaders(

Pylons FormEncode with an array of form elements

最后都变了- 提交于 2019-12-04 09:46:41
问题 I have a Pylons app and am using FormEncode and HtmlFill to handle my forms. I have an array of text fields in my template (Mako) <tr> <td>Yardage</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]',

Deploying Pylons with uWSGI

↘锁芯ラ 提交于 2019-12-04 08:51:40
We're trying to move our intranet to Pylons. My boss is trying to set up Pylons to use uWSGI behind Apache so he can set up multiple, independent applications. However, he's having a difficult time getting it set up, with some apparent code problems in the C source code for uWSGI. Does anyone have any suggestions for how to deploy Pylons applications that might help us out? Thanks, Doug Here is how I did it: http://tonylandis.com/python/deployment-howt-pylons-nginx-and-uwsgi/ You can directly use paste for deploying pylons on uWSGI: http://projects.unbit.it/uwsgi/wiki/UsePaste The Pylons

How to create and restore a backup from SqlAlchemy?

浪尽此生 提交于 2019-12-04 07:58:23
问题 I'm writing a Pylons app, and am trying to create a simple backup system where every table is serialized and tarred up into a single file for an administrator to download, and use to restore the app should something bad happen. I can serialize my table data just fine using the SqlAlchemy serializer, and I can deserialize it fine as well, but I can't figure out how to commit those changes back to the database. In order to serialize my data I am doing this: from myproject.model.meta import

How do I run a single test with Nose in Pylons

醉酒当歌 提交于 2019-12-04 07:27:31
问题 I have a Pylons 1.0 app with a bunch of tests in the test/functional directory. I'm getting weird test results and I want to just run a single test. The nose documentation says I should be able to pass in a test name at the command line but I get ImportErrors no matter what I do For example: nosetests -x -s sometestname Gives: Traceback (most recent call last): File "/home/ben/.virtualenvs/tsq/lib/python2.6/site-packages/nose-0.11.4-py2.6.egg/nose/loader.py", line 371, in loadTestsFromName