pyramid

Pyramid 1.3 and Google App Engine 1.7

对着背影说爱祢 提交于 2019-12-05 21:53:31
I managed to make a Pyramid 1.2 WSGI app run on Google App Engine SDK 1.7. However, my current project uses several new Pyramid 1.3 features and I'm stuck on a WebOb version issue. Here's the error message: VersionConflict: (WebOb 1.1.1 (/home/matt/Python/google_appengine/lib/webob_1_1_1), Requirement.parse('WebOb>=1.2dev') Is there something I can do or I must wait for a new GAE release? A fairly reliable way to manage your pyramid application and it's dependencies on appengine is via the pyramid_appengine library which generates a skeleton project that uses buildout . disclaimer: I wrote

Route requests based on the Accept header in Python web frameworks

纵然是瞬间 提交于 2019-12-05 18:36:13
I have some experience with different web frameworks (Django, web.py, Pyramid and CherryPy), and I'm wondering in which one will it be easier and hopefully cleaner to implement a route dispatcher to a different "view/handler" based on the "Accept" header and the HTTP method e.g.: Accept: application/json POST /post/ is handled different than: Accept: text/html POST /post/ So the request gets routed to the particular view of the corresponding handler of the MIME "application/json" and the HTTP method "POST". I do know how to implement something like that in CherryPy, but I lose the use of the

Changing database per view & accessing multiple databases per view

不问归期 提交于 2019-12-05 18:02:16
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 the same, I also use the same model classes for the databases. I've tried it with both sqlahelper and

Pyramid: multiple resource factories — how to

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 17:57:51
I have a simple root resource factory: class Root: __acl__ = [ (Allow, Authenticated, 'edit') ] Now for some "special" routes, I need to create another resource factory config.add_route('special', '/special/test', factory=SpecialFactory) class SpecialFactory: __acl__ = [ (Allow, Authenticated, 'special_edit') ] Now, I want to make Root the parent of SpecialFactory -- how should I do it? Is this the right way... class SpecialFactory: def __init__(self, request): self.request = request self.__parent__ = Root(request) self.__name__ = 'special' __acl__ = [ (Allow, Authenticated, 'special_edit') ]

struck at sqlalchemy.exc.IntegrityError: (IntegrityError) constraint failed 'INSERT INTO users

て烟熏妆下的殇ゞ 提交于 2019-12-05 10:56:52
I am using sqlite database and I declared the models as in this gist https://gist.github.com/mmahesh/7245561 I have added a model instance with transaction manager as with transaction.manager: model = Users(username='example',name='Example', email_primary='m@m.com', _password='example') DBSession.add(model) Whenever I execute initialize_sample_db development.ini, this error shows up sqlalchemy.exc.IntegrityError: (IntegrityError) constraint failed 'INSERT INTO users (name, username, email_primary, email_secondary, _password, bio) VALUES (?, ?, ?, ?, ?, ?)' ('Example', 'example', 'm@m.com',

How to do a while ( x < y ) in jinja2

試著忘記壹切 提交于 2019-12-05 08:18:32
How should I do a while ( x < y ) in jinja2? I've seen the jinja2 docs, it seems like they only support for loop for a declared variable of array and while() is not supported at all. I think your closest alternative with Jinja2 would be to use a for with range : {% range number from 3 to 6 %} {{ number }} (...) {% endrange %} And you can pass the variables from your program to use them in the loop. 来源: https://stackoverflow.com/questions/13668025/how-to-do-a-while-x-y-in-jinja2

uploading multiple files with pyramid

一曲冷凌霜 提交于 2019-12-05 06:51:59
Trying to upload multiple files at once using python. The upload.html source code is as followed: <form name="frmRegister" method="post" accept-charset="utf-8" enctype="multipart/form-data" class="form-horizontal"> <div class="control-group"> <div class="controls"> <input type="file" name="files" multiple='multiple'> </div> </div> <div class="control-group"> <div class="controls"> <input class="btn btn-primary" type="submit" name="btnSubmit" value="Add Product" /> </div> </div> </form> in my admin.py: @view_config(context="mycart:resources.Product", name="add", renderer='admin/mall/product/add

How do I restrict permissions based on the single page ID in the URL?

喜欢而已 提交于 2019-12-05 06:49:56
I'm trying to implement Pyramid's Security features in my website but I'm having some trouble figuring out how to use it. I've been reading over this tutorial and this example , as well as the Pyramid docs, and I can't figure out how to implement an authorization policy for single page IDs. For example, I have the following URL scheme: /pages /pages/12 /pages obviously lists the available pages and /pages/:id is where you can read/comment on the page. The documentation/examples I've read have shown that you can implement group level ACS's by providing a groupfinder callback with a list of

How do I integrate a Bokeh Server into a Pyramids Application?

久未见 提交于 2019-12-05 06:49:00
问题 In order of complexity, with Pyramids, I can create static bokeh graphs and then incorperate them with div tags like outlined here. The Bokeh documentations explain clearly how one can setup a bokeh server for interactive data exploration, and I have successfully created such an application. What I would like to do though is to have an interactive graph within a Pyramids view page. The requirements of this page would be as followed: Upon loading of the view, a bokeh server is somehow started,

What is PasteDeploy and do I need to learn it if Eggs in Python are considered gone?

泄露秘密 提交于 2019-12-05 05:40:41
I'm quite new to Python. I've downloaded the Pyramid Framework and have been trying to understand it. It uses many separate tools for its work. For example some PasteDeploy . I tried to read PasteDeploy 's manual but can't understand anything. There is almost no valuable examples and explanation. Just syntax. All I understood is that it uses .egg format everywhere. It is based on .egg format: [composite:main] use = egg:Paste#urlmap [app:home] use = egg:Paste#static [app:blogapp] use = egg:BlogApp At the same time I found that .egg format is going to be thrown away from Python's package's