pyramid

User Authentication in Pyramid

感情迁移 提交于 2019-12-02 17:16:06
I'm building a webapp and needed to choose between Django and Pyramid. I decided to go with Pyramid. I understand Pyramid comes with its own authentication/authorization framework which looks nice. But I haven't seen anywhere in Pyramid where users/groups/permissions are defined. In Django these things come for free. I'm using SQLAlchemy and was wondering if there are similar users/groups/permissions already built that I can import. I'd rather not define these objects/mappings and hash/salting of passwords myself. Django's definitions of these things are pretty much all I need. Can anyone

How do I redirect python pyramid waitress logging to stdout on heroku?

こ雲淡風輕ζ 提交于 2019-12-02 16:46:43
问题 According to the docs (http://docs.pylonsproject.org/projects/waitress/en/latest/): Waitress sends its logging output (including application exception renderings) to the Python logger object named waitress. You can influence the logger level and output stream using the normal Python logging module API. That's all the documentation has to say. I'm trying to redirect logging output to stdout. How would I go about doing that in the pastedeploy .ini file? 回答1: Are you trying to log the requests

Pyramid traversal view lookup using method names

萝らか妹 提交于 2019-12-02 08:09:03
问题 In pyramid when using traversal url lookup, is it possible to have the view lookup algorithm check for method names of a class. For example, I could do something like this: @view_defaults(context=models.Group) class GroupView(object): def __init__(self, context, request): self.context = context self.request = request @view_config(name='members') def members(self): pass to match let's say /groups/somegroup/members Is there a way to make the name lookup part dynamic? That is, something like

Pyramid traversal view lookup using method names

别等时光非礼了梦想. 提交于 2019-12-02 06:01:26
In pyramid when using traversal url lookup, is it possible to have the view lookup algorithm check for method names of a class. For example, I could do something like this: @view_defaults(context=models.Group) class GroupView(object): def __init__(self, context, request): self.context = context self.request = request @view_config(name='members') def members(self): pass to match let's say /groups/somegroup/members Is there a way to make the name lookup part dynamic? That is, something like this: @view_defaults(context=models.Group) class GroupView(object): def __init__(self, context, request):

Passing arguments in python setup.py install_requires list

白昼怎懂夜的黑 提交于 2019-12-01 19:19:57
I have used pip to install PIL. It requires two additional arguments while installation. So the command for installation looks something like this. pip install PIL --allow-external PIL --allow-unverified PIL I need to add the PIL package in setup.py file. Adding PIL in the install_requires list do install PIL but it doesn't work, as I need to install PIL with the additional arguments. So how can I add the PIL to the install_requires list with additional arguments ? Currently, there is no way to specify extra arguments in install_requires in setup.py. But, I solved my problem of installing

Routing subdomains in Pyramid

Deadly 提交于 2019-12-01 18:39:13
问题 In Pylons 1.0 I could go into config/routing.py and add map.connect('/', controller='index', conditions=dict(sub_domain=False)) map.connect('/', controller='mobileindex', conditions=dict(sub_domain='m')) to route m.mydomain.com to a different controller, but still use the same app. Can I do the same in Pyramid? 回答1: Theoretically, this is covered by add_route() with a pregenerator argument. 回答2: An example of what @syrion is referring to is available here: Multiple domains and subdomains on a

Passing arguments in python setup.py install_requires list

為{幸葍}努か 提交于 2019-12-01 18:11:24
问题 I have used pip to install PIL. It requires two additional arguments while installation. So the command for installation looks something like this. pip install PIL --allow-external PIL --allow-unverified PIL I need to add the PIL package in setup.py file. Adding PIL in the install_requires list do install PIL but it doesn't work, as I need to install PIL with the additional arguments. So how can I add the PIL to the install_requires list with additional arguments ? 回答1: Currently, there is no

Insert not working for SQLAlchemy database session

五迷三道 提交于 2019-12-01 16:41:34
问题 Why isn't a record being inserted? There is an id returned but when I check the database there is no new record. From models.py from zope.sqlalchemy import ZopeTransactionExtension DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) And views.py DBSession.execute(text('INSERT INTO (a,b,c) VALUES (\'a\',\'b\',\'c\') RETURNING id'), params=dict(a=a,b=b,c=c)) I've tried committing with transaction.commit() which doesn't get an error but doesn't insert a record. result

How can I install packages on my heroku app?

回眸只為那壹抹淺笑 提交于 2019-12-01 14:39:58
I have an app that makes use of shortuuid ( https://pypi.python.org/pypi/shortuuid/0.1 ) that is working fine locally when I run it with runapp.py: import os from paste.deploy import loadapp from waitress import serve if __name__ == "__main__": port = int(os.environ.get("PORT", 5000)) app = loadapp('config:production.ini', relative_to='.') serve(app, host='0.0.0.0', port=port) It does not work, however, when I try and run it with ../bin/pserve development.ini. I get the error: import error: no module named shortuuid. When I push it to heroku I get the same error. I have installed shortuuid

How can I install packages on my heroku app?

≡放荡痞女 提交于 2019-12-01 12:06:19
问题 I have an app that makes use of shortuuid (https://pypi.python.org/pypi/shortuuid/0.1) that is working fine locally when I run it with runapp.py: import os from paste.deploy import loadapp from waitress import serve if __name__ == "__main__": port = int(os.environ.get("PORT", 5000)) app = loadapp('config:production.ini', relative_to='.') serve(app, host='0.0.0.0', port=port) It does not work, however, when I try and run it with ../bin/pserve development.ini. I get the error: import error: no