Re: pyramid_sqla 1.0rc1 released
Is there a reason that a pyramid_sqla template does not add 'pyramid_sqla' as a dependency of the generated project, considering that the project is doing imports from the pyramid_sqla package? Michael On Thu, Jan 27, 2011 at 2:36 PM, Daniel Holth dho...@gmail.com wrote: stucco_auth's the approach includes: 1. SQLAlchemy session is only available as request.db (as far as stucco_auth is concerned). 2. Transaction management. No .commit() or .rollback() in view code. 3. Each package has its own declarative_base() and its own versioned schema It has no paster template. It would work fine if request.db = pyramid_sqla.get_session(). I am more interested in the reusability story than the quick start story. Something like: 'pip install pyramid_wiki' root = dict(wiki=pyramid_wiki.Wiki()) create_tables(session, 'pyramid_wiki') config.include(pyramid_wiki.config) http://localhost:6543/wiki/ -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.compylons-discuss%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: pyramid_sqla 1.0rc1 released
Also, is there a reason that the template creates websetup.py as well as scripts/create_db.py? I see that create_db.py is documented, so websetup.py must just be there as an example of how to do it? Michael On Thu, Jan 27, 2011 at 8:06 PM, Michael Merickel mmeri...@gmail.comwrote: Is there a reason that a pyramid_sqla template does not add 'pyramid_sqla' as a dependency of the generated project, considering that the project is doing imports from the pyramid_sqla package? Michael On Thu, Jan 27, 2011 at 2:36 PM, Daniel Holth dho...@gmail.com wrote: stucco_auth's the approach includes: 1. SQLAlchemy session is only available as request.db (as far as stucco_auth is concerned). 2. Transaction management. No .commit() or .rollback() in view code. 3. Each package has its own declarative_base() and its own versioned schema It has no paster template. It would work fine if request.db = pyramid_sqla.get_session(). I am more interested in the reusability story than the quick start story. Something like: 'pip install pyramid_wiki' root = dict(wiki=pyramid_wiki.Wiki()) create_tables(session, 'pyramid_wiki') config.include(pyramid_wiki.config) http://localhost:6543/wiki/ -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.compylons-discuss%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: pyramid_sqla 1.0rc1 released
I see a 'directory' parameter documented in add_static_route(), however the actual implementation doesn't seem to support it. The whole add_static_route() idea is a nice backward-compatible feature with pylons but I feel like it takes away from some of the features pyramid provides, like the static_url() function which can help map arbitrary urls to directories. The static_url() function unfortunately doesn't work with any regular routes, such as those created by add_static_route(), leaving the developer to use either the application_url (effectively hard-coding the structure) or through route_url() which isn't immediately obvious. Anyway I wanted to bring this up in case it can provoke some better documentation for the feature, or possibly not supporting it as the default setup for static content. Thanks again for pyramid_sqla, it does a great job of hooking sqlalchemy into pyramid. Michael On Fri, Jan 28, 2011 at 12:26 AM, Mike Orr sluggos...@gmail.com wrote: On Thu, Jan 27, 2011 at 9:32 PM, Michael Merickel mich...@merickel.org wrote: I'll also point out that the create_db script should probably be initialized with your app's name instead of SimpleDemo in the line: app = get_app(ini_file, SimpleDemo) Thanks for the replies! Michael Hmm, I don't know how that got in there, or why it didn't cause the script to raise an exception. -- Mike Orr sluggos...@gmail.com -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.compylons-discuss%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
sqlalchemy without scoped_session
I wanted to expand on the pyramid_cookbook entry (https://github.com/ Pylons/pyramid_cookbook/blob/master/sqla.rst) for using sqlalchemy without the scoped_session. So I created a gist that demonstrates more in-depth how it can be setup and used within a project. https://gist.github.com/805439 Any comments or corrections would be greatly appreciated. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: sqlalchemy without scoped_session
s = Session.object_session(self) without model code should work with the caveat that it won't if the object isn't part of a session yet. Also wanted to point out DanielHolth's implementation of this inside of stucco_auth. He stores the session in the environ, sharing it with a custom transaction manager, removing the need for a threadlocal transaction manager. Michael On Tue, Feb 1, 2011 at 10:02 AM, Chris McDonough chr...@plope.com wrote: On Mon, 2011-01-31 at 21:12 -0800, Michael Merickel wrote: I wanted to expand on the pyramid_cookbook entry (https://github.com/ Pylons/pyramid_cookbook/blob/master/sqla.rst) for using sqlalchemy without the scoped_session. So I created a gist that demonstrates more in-depth how it can be setup and used within a project. https://gist.github.com/805439 Any comments or corrections would be greatly appreciated. It would be useful to also show a sample view using request.db to complete the picture. It's also necessary sometimes to get at the session from a model instance sometimes (to perform another query). In a world without a global way to get a session, rather than always pass it in, I'm hoping folks can use http://www.sqlalchemy.org/docs/orm/session.html#sqlalchemy.orm.session.Session.object_session? - C -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.compylons-discuss%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Help with creating view functions
That error is telling me that you have a bug in your mako template... probably referencing a variable that you forgot to pass in (thus it is undefined). Michael On Sat, Mar 12, 2011 at 4:33 PM, AwaisMuzaffar awais1...@googlemail.comwrote: Hi, Thanks I will read into it more. I assumed it was the same thing. I have also tried: def blog_view(request): variable = 'hello world' return render_to_respomse('myblog:templates/pages/my-blog.mak', {'variable':variable}, request=request) And, I recieve the following error: URL: http://127.0.0.1:6543/my-blog/ File '/Users/Awais/virtualenv/lib/python2.6/site-packages/ WebError-0.10.3-py2.6.egg/weberror/evalexception.py', line 431 in respond app_iter = self.application(environ, detect_start_response) File '/Users/Awais/virtualenv/lib/python2.6/site-packages/ repoze.tm2-1.0b1-py2.6.egg/repoze/tm/__init__.py', line 23 in __call__ result = self.application(environ, save_status_and_headers) File '/Users/Awais/virtualenv/lib/python2.6/site-packages/pyramid-1.0- py2.6.egg/pyramid/router.py', line 158 in __call__ response = view_callable(context, request) File '/Users/Awais/virtualenv/lib/python2.6/site-packages/pyramid-1.0- py2.6.egg/pyramid/config.py', line 2916 in _requestonly_view response = view(request) File '/Users/Awais/virtualenv/MyBlog/myblog/views.py', line 25 in pages_view {'page':page}, request=request) File '/Users/Awais/virtualenv/lib/python2.6/site-packages/pyramid-1.0- py2.6.egg/pyramid/renderers.py', line 111 in render_to_response return helper.render_to_response(value, None, request=request) File '/Users/Awais/virtualenv/lib/python2.6/site-packages/pyramid-1.0- py2.6.egg/pyramid/renderers.py', line 322 in render_to_response result = self.render(value, system_values, request=request) File '/Users/Awais/virtualenv/lib/python2.6/site-packages/pyramid-1.0- py2.6.egg/pyramid/renderers.py', line 318 in render result = renderer(value, system_values) File '/Users/Awais/virtualenv/lib/python2.6/site-packages/pyramid-1.0- py2.6.egg/pyramid/mako_templating.py', line 131 in __call__ result = template.render_unicode(**system) File '/Users/Awais/virtualenv/lib/python2.6/site-packages/Mako-0.3.6- py2.6.egg/mako/template.py', line 292 in render_unicode as_unicode=True) File '/Users/Awais/virtualenv/lib/python2.6/site-packages/Mako-0.3.6- py2.6.egg/mako/runtime.py', line 575 in _render **_kwargs_for_callable(callable_, data)) File '/Users/Awais/virtualenv/lib/python2.6/site-packages/Mako-0.3.6- py2.6.egg/mako/runtime.py', line 607 in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File '/Users/Awais/virtualenv/lib/python2.6/site-packages/Mako-0.3.6- py2.6.egg/mako/runtime.py', line 633 in _exec_template callable_(context, *args, **kwargs) File 'myblog_templates_pagesbase_mak', line 27 in render_body File 'myblog_templates_pages_my_blog_mak', line 34 in render_body File '/Users/Awais/virtualenv/lib/python2.6/site-packages/Mako-0.3.6- py2.6.egg/mako/runtime.py', line 181 in __str__ raise NameError(Undefined) NameError: Undefined -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Pyramid routing questions
The pyramid form of url dispatch is very explicit - you make a specific route and assign a view to handle that based on properties of the request. In order to make the magic routing based on ``action``, the simple way is to just use the pyramid_handlers package which provides a very similar behavior to the original pylons controllers. http://docs.pylonsproject.org/projects/pyramid_handlers/dev/ Michael On Wed, Mar 16, 2011 at 5:03 AM, brutka bru...@gmail.com wrote: Hello! I am learning Pyramid after a few project on Pylons. Cannot get the Pyramid routing (I am not using traversing). Questions. 1. In Pylons it was usefull to set controller explicit, and have the action dynamic (as part of Url matching). Can I do somehting like that in Pyramid? Or I have to specify routes for ALL Views? (for all actions in Pylons terms) 2. I am using language code as part of URL. ex, /pagename - for default language /en/pagename - for english /fr/pagename - for french, etc... I order to use same routes for all languages I inherited from Mapper, overloaded match and routematch methods (I detect if language is present in URL, save it, then remove it from URL, and then run original match and routmatch code). How can I do something like that in Pyramid? -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Pyramid modify query parameter of current url
The query parameter to resource url expects a list of 2-tuples, coincidentally the same as what is returned by request.GET.items(). I'd suggest: qs = dict(request.GET) qs['page'] = 2 url = resource_url(context, request, query=qs.items()) This is untested, but it is not far off from working. Michael On Fri, Mar 18, 2011 at 4:53 PM, oO oliv...@ozoux.com wrote: What would be the best way to modify only one of the query parameters of the current url without modifying anything else? I have a query based pagination in a mako template, and I want it to only modify the page=X part of the url, without having to know anything about the current view, or the other potential parameters that might exist on the query already (sorting for example) I'm using traversal and so I can't really use current_route_url() but I wish there was something similar. I can extract the current resource, view_name, but I'm now sure how I would get the query as a dictionary that would be compatible with what resource_url() expects to rebuild the modified url. Any ideas? oO -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: add_route and view_attr
To solve your problem you probably just need to remove the view_attr from add_route and call config.scan(). The problem here is the ambiguity in add_route because it supports routes and the ability to add a single view. Rather add_view and view_config are identical except that view_config requires to you call config.scan() to place the decorator within your code, instead of within your config. Michael On Thu, Apr 7, 2011 at 11:30 AM, Eric Lemoine eric.lemo...@camptocamp.comwrote: On Thursday, April 7, 2011, Gael Pasgrimaud g...@gawel.org wrote: Hi, On Thu, Apr 7, 2011 at 4:47 PM, Eric Lemoine eric.lemo...@camptocamp.com wrote: Hi I have view class defined as follows: class Entry(object): def __init__(self, request): self.request = request self.debug = debug in request.params lang = request.params.get(lang, request.registry.settings.get(default_locale_name)) self.lang = lang @view_config(route_name='home', renderer='templates/index.html') def home(self): return {'lang': self.lang, 'debug': self.debug} And a route to the home action defined with this: config.add_route('home', '/', view_attr='home') Don't know why you are using two different configuration. add_route and view_config do the same thing. Eg: add an entry to the registry. You just need to use add_route: config.add_route('home', '/', view_attr='home', view='yourmodule.Entry', renderer='...') Hi Gael. I know this works, but I've been looking at separating concerns, that is specifying route-related stuff with add_route, and view-related stuff with view_config. As far as I know this can be achieved using route_name to bind the route to the view_config at config.scan time. But it doesn't work when specifying a view_attr in add_route. -- Eric Lemoine Camptocamp France SAS Savoie Technolac, BP 352 73377 Le Bourget du Lac, Cedex Tel : 00 33 4 79 44 44 96 Mail : eric.lemo...@camptocamp.com http://www.camptocamp.com -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: session, beaker cookie expiration and remember me
I know you can set session.cookie_expires on a per-session basis. Michael On Thu, Apr 7, 2011 at 7:31 AM, Oliver Christen oliver.chris...@camptocamp.com wrote: Dear all I have been asked to implement a way for user to be able to stay logged for a longer period of time if they check a remember me option at log in. I have looked at Pylons's Beaker documentation but I cant find how to modify the session cookie expiration date during runtime. I would be really grateful is someone could tell me if this is possible, and if yes, how. Thank you very much in advance Best regards Oliver -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Cluegun App Example Security
FWIW I just cloned and ran cluegun for the first time using paster serve development.ini in a new virtualenv and it ran fine for me. The /manage view redirected to /login, then admin/admin user/pass took me back to /manage where I was able to delete pastes. It does say Failed login on the login form if I try to use the wrong credentials. Why does Pyramid conclude that the default is deny?!? In your example the principal is simply Everyone, which doesn't have the 'manage' permission, thus the denial. Michael On Mon, Apr 18, 2011 at 3:34 AM, Sascha sascha.b...@gmx.de wrote: Here's the debug information: debug_authorization of url http://localhost:6544/manage (view name u'manage' against context sdtrpt.models.Foo object None at 0x1c5adb0): ACLDenied permission 'manage' via ACE 'default deny' in ACL [('Allow', 'system.Everyone', 'view'), ('Allow', 'admin', 'manage')] on context sdtrpt.models.Foo object None at 0x1c5adb0 for principals ['system.Everyone'] The ACL of the Foo object is defined as: __acl__ = [ (Allow, Everyone, 'view'), (Allow, Authenticated, 'manage'), (Allow, 'admin', 'manage') ] Why does Pyramid conclude that the default is deny?!? On Apr 18, 8:40 am, Sascha sascha.b...@gmx.de wrote: Hi there! I have modeled my app's security after the Cluegun example (https:// github.com/Pylons/cluegun). When it did not work, I reviewed Cluegun and realized that it does not work either. When I try to access the manage view, I am getting the login screen. According to the password file, it should be possible to log in with admin/admin. That seems to work, I am not getting a message that this fails. However, I am again presented with the login screen. It seems to me that there is a glitch somewhere. Can anybody confirm this, please? Thanks, Sascha -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: need help with enginx configuration with Pylons.
I'm not sure what the pros/cons of fastcgi are, but I use nginx in production as a reverse proxy on several projects. This cookbook is for pyramid, but the configuration is framework-agnostic: http://docs.pylonsproject.org/projects/pyramid_cookbook/dev/deployment.html#nginx-paster-supervisord Obviously your INI file will be slightly different for pylons, but the nginx configuration would remain the same. Michael On Sun, Apr 24, 2011 at 12:24 PM, Krishnakant Mane krm...@gmail.com wrote: Hello all. Can some one help me out with a small problem? if any one has ever deployed an application in pylons 0.9.7 using nginx 1.0 or lower, then please give me an example of nginx.conf file and any other files I need to change. My application name is gnukhata and I will highly appreciate if some one could also share off list a production.ini file. Right now I am trying to configure the file as given at, http://www.rightbrainnetworks.com/blog/deploying-a-pylons-app-to-production-step-by-step-part-1-of-2/ I did as exactly mentioned in this tutorial part one for nginx.conf. I have the lines changed exactly as in the example there. Can some one tell me if that's the correct way to do? happy hacking. Krishnakant. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: need help with enginx configuration with Pylons.
The paste http server is capable of running on its own and handling traffic. This setup just uses nginx as a load balancer. I'm really not familiar with how fastcgi interacts with WSGI apps, someone else will have to answer that for you. Michael On Sun, Apr 24, 2011 at 2:50 PM, Krishnakant Mane krm...@gmail.com wrote: Thanks Michael. So will just reverce proxy help me utilise the performance bennifits that nginx offers? Afterall this kind of setup will only help to proxy requests to python paist. But is paist itself good enough to handle loads of requests? I herd that fastcgi does some event based requesting and lends the work to some worker processes? is that right or this will any ways happen with nginx using reverce proxy? Happy hacking. Krishnakant. On 25/04/11 00:41, Michael Merickel wrote: I'm not sure what the pros/cons of fastcgi are, but I use nginx in production as a reverse proxy on several projects. This cookbook is for pyramid, but the configuration is framework-agnostic: http://docs.pylonsproject.org/projects/pyramid_cookbook/dev/deployment.html#nginx-paster-supervisord Obviously your INI file will be slightly different for pylons, but the nginx configuration would remain the same. Michael On Sun, Apr 24, 2011 at 12:24 PM, Krishnakant Mane krm...@gmail.comwrote: Hello all. Can some one help me out with a small problem? if any one has ever deployed an application in pylons 0.9.7 using nginx 1.0 or lower, then please give me an example of nginx.conf file and any other files I need to change. My application name is gnukhata and I will highly appreciate if some one could also share off list a production.ini file. Right now I am trying to configure the file as given at, http://www.rightbrainnetworks.com/blog/deploying-a-pylons-app-to-production-step-by-step-part-1-of-2/ I did as exactly mentioned in this tutorial part one for nginx.conf. I have the lines changed exactly as in the example there. Can some one tell me if that's the correct way to do? happy hacking. Krishnakant. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: how can I make pyramid application install configure.zcml with other files.
You need a MANIFEST.in file, or the other option is to install setuptools-git (assuming your files are under git) and package your application using python setup.py sdist. Michael On Sun, Apr 24, 2011 at 9:21 PM, Chung, Ha Nyung minorbl...@gmail.comwrote: I was trying to make my application load configuration from zcml file, and in development environment - when I'm running with paster serve command - everything worked well. But when I tried to run it in production environment integrated with apache using wsgi, it couldn't find configure.zcml file, and I found that file was not installed(or copied) properly even though I've ran 'python setup.py install' command. How can I make that setup.py script to install .zcml file properly? -- Chung, Ha Nyung minorblend (at) gmail (dot) com -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Released Pyramid application template with user account management
Please look at the shootout implementation of passwords. I added support for cryptacular there, hoping it might serve as a decent example for using bcrypt, etc. It'd damn easier than dealing with any hashing yourself. https://github.com/Pylons/shootout/blob/master/shootout/models.py#L28 Michael On Mon, Apr 25, 2011 at 2:52 PM, Daniel Holth dho...@gmail.com wrote: FULL PEDANTISM ON $6$ is a SHA-512-based algorithm developed by Ulrich Drepper of RedHat. It performs 5000 rounds by default but it supports a rounds= parameter. The algorithm is only based on SHA-512; each round is more work than SHA-512 by itself. I prefer bcrypt but this algorithm was specifically developed for the benefit of those whose list of approved algorithms only has SHA on it. On my Ubuntu system, I can also pass the $2a$ prefix to os.crypt() to get bcrypt without installing anything, not even the far superior cryptacular library which wraps a public-domain C implementation of bcrypt. /END PEDANTISM AND SHAMELESS SELF-PROMOTION Is the standard bcrypt work factor of 10 (2^10 rounds) really obsolete? -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: [Pyramid] Disable SQLAlchemy Transaction
Nothing is stopping you from defining another session object bound to the same engine that does not use the ZTE. As long as your engine is accessible through the settings/registry then it shouldn't be an issue to create a session in your script and use it only there. Michael On Thu, May 12, 2011 at 1:37 AM, jerry jerryji1...@gmail.com wrote: It seems transaction based SQLAlchemy session is defined by the ZopeTransactionExtension -- DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) This is causing problem with my long-running/large-volume paster command, which are not suitable for transactions. But I couldn't get the DBSession redefined no matter how I fiddle with the paster command source. Is there a way to temporarily turn off transaction in a Pyramid project? Thanks in advance! Jerry -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: best way to handle IntegrityError with pyramid_tm
2) Return a newly committed object (for instance, if I save a new user successfully, I'd like to return that user object to the handler) You can populate your user object's pkey same as always by issuing a session.flush() after adding the object to your session. This will dump it to the database, populate the pkey, and refresh the orm object. The data is not persisted until you commit the session using transaction.commit() or allowing pyramid_tm to issue the commit for you at the end of the request. This may passively answer your previous question, but maybe not. In general if you're worried about integrity errors you can probably just issue a flush (which executes the SQL in the db) and see if that works. One question I cannot answer, however, is how the transaction manager interacts with nested transactions. Anyone have an answer for this? -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: [Akhet] how do I serve my app from subdirectory?
To host a WSGI app at a subdirectory you have to do 2 things. 1) Tell apache to forward requests only for that subdirectory. This is done using the WSGIScriptAlias. 2) Tell the WSGI app that it is being hosted at a subdirectory. This is done by setting the SCRIPT_NAME parameter in the WSGI environ to '/mysubdir'. One way to do this is to add paste's PrefixMiddleware to your pipeline. An example is to edit your ini file: [filter:paste_prefix] use = egg:PasteDeploy#prefix prefix = /mysubdir [pipeline] use = paste_prefix # ... other middleware ... myapp Michael (raydeo in #pylons) -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: URL outside of view callable
The registry is also embedded in the request, and is required for pyramid to find the list of routes... thus a pyramid request object is required to generate the paths as well. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Best practices for where to work with SQLAlchemy
Assuming transaction.close is a typo and you meant transaction.commit, you may want to think about not calling it at all and allowing the transaction manager (repoze.tm2 or pyramid_tm) handle performing the commit for you. The reason for this is that your changes will automatically be rolled back if your request fails after you would have normally done a commit. For example in your template renderer, where you have little control as your view callable is already complete by the time that happens. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Problem installing egg from file
I think you can just run easy_install egg_file. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Reusing sqlalchemy models across several pyramid apps
On Mon, May 23, 2011 at 7:35 AM, Daniel Holth dho...@gmail.com wrote: The only limitation I've found is that you have to use class attributes, not string table names, to reference foreign keys. e.g. ForeignKey(User.foobar) instead of ForeignKey('usertable.foobar_id') I've never found a situation where I needed to use the actual class attribute... all of my declarative foreign keys (and relations) use strings. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Debugging mako templates in pyramid?
I'm pretty sure that blaflamme forked weberror and re-added nice tracebacks for mako. However it's only on github and not actually integrated with weberror... you can install it yourself though. https://github.com/blaflamme/pyramid_weberror -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Need help to deploy pylons app under wsgi and apache
You need to configure mod_wsgi to use the correct PYTHONPATH pointing to your virtualenv. Either that or run setup.py develop on your source to install it into the virtualenv. That should help with your DistributionNotFound issues. Also, while this is for pyramid, the instructions are identical for deploying a pylons app under mod_wsgi: http://docs.pylonsproject.org/projects/pyramid/1.0/tutorials/modwsgi/index.html -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: get complete url of app:static as string ?
URLs in pyramid are generated based on the context of the request. Therefore if there is no request telling the generator what the host/port/subpath are, pyramid will not know the correct URL to generate. You can trick pyramid with a fake request, but that's just the way it is. You may want to just get the base url from a setting in your INI and create it that way. Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: issue to deploy pylons application under mod_wsgi
I don't use mod_wsgi but the pyramid documentation for it is almost an identical setup to pylons, perhaps it can help you out. http://docs.pylonsproject.org/projects/pyramid/1.0/tutorials/modwsgi/index.html Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Pyramid, traversal, and file-extensions -- not possible?
Using traversal you'll need to define your own __getitem__ on your context objects that is capable of discriminating your leaf nodes. With regards to the SO question, the pyramid way of dealing with this is much more flexible than the pylons mechanism of an if within the view code. For example you can add a custom view predicate which will point the view lookup at the same (or different) view with a different renderer. def json_fmt(context, request): if request.matchdict['ext'] == 'json': return True return False config.add_route('test', '/test') config.add_route('test_fmt', '/test.{ext}') config.add_view(route_name='test', view='ms.views.test', renderer='test.mako') config.add_view(route_name='test_fmt', view='ms.views.test', custom_predicates=(json_fmt,), renderer='json') # ms/views.py def test(request): return { 'key': 'value', } The returned dictionary will either be passed to the mako template, or rendered as json depending on which view matched leaving you to focus on views, letting pyramid handle rendering it for you. Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Pyramid, traversal, and file-extensions -- not possible?
On Jun 11, 3:02 pm, Matt Feifarek matt.feifa...@gmail.com wrote: Sure, but we're not using traversal anymore now... we're hand-poking all of this stuff. I like your solution, in a non-traversal situation. Sorry, I gave this example because it's a better solution to the SO solution that you linked to, so I figured you were interested in how to do it with dispatch as well. Can I keep traversal, keep using simple @view_config decorators, and have file-extensions? Seems like no. How you use views with traversal is completely dependent on your resource tree. So assuming you have a tree for /users/matt and you want to handle a view named status off of the User('matt'), you could simply add a view for 'status' and a view for 'status.json': @view_config(name='status', context=User, renderer='status.mako') @view_config(name='status.json', context=User, renderer='json') def status_view(request): user = request.context return { 'key': 'value', # passed to the matched renderer } At least in the brief moment I've pondered this, you will have a problem matching a view in the case where there is no name. For example matching '/users/matt.json', as the User.__getitem__ will have to take care of that. You can probably argue that handling this url with that format wouldn't make sense anyway, however. Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Simple Jquery AJAX question
On Thu, Jun 16, 2011 at 10:03 AM, AwaisMuzaffar awais1...@googlemail.comwrote: config.add_route('ajax', '/ajax/', view='testproject.views.ajax') def ajax(request): string = 'hello world' return Response(string) This is fine, but there are 2 enhancements you may want to use in your Pyramid code. First, if you want to expand your interface to be more restful in the future, you may want to separate your config using predicates to match POST requests to certain views and GET requests to other views. The other thing is that you can utilize Pyramid's renderers to avoid having to return a full Response object yourself. As an example, set the renderer to 'json' (or if you do it in add_route then it's the view_renderer). config.add_route('ajax', '/ajax') config.add_view(route_name='ajax', view='testproject.views.ajax', request_method='POST', renderer='json') From your view code you can then: return 'hello world' and it will be json serialized for you. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Pyramid with SQLAlchemy (Non-Gobal session)
On Thu, Jun 16, 2011 at 12:38 AM, Liju lij...@gmail.com wrote: The documentation says 'It’s sometimes advantageous to not use SQLAlchemy’s thread-scoped sessions'. The issue isn't with scoped_session as much as it has to do with using a global variable to store your database connections. It just works out that if you avoid using a global variable, you don't need the protection of scoped_sessions because everything in pyramid is per-request (which is per-thread) already. The reasons to avoid using a global scoped_session are the same as the reasons to avoid any global variable. It's true that each request is processed in a separate thread (or greenlet as the case may be). However, that doesn't address the issue of running multiple applications in the same process. All of a sudden your global variables start stepping on each other and you have problems. Obviously this is not a common case, but the fact that pyramid has no global variables, and that there are ways to avoid creating any in your app as well, can really save your butt when the time comes. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Logging configuration for applications run without paster
On Fri, Jun 17, 2011 at 9:30 AM, Benjamin Sims benjamins...@gmail.comwrote: After digging, my understanding is that logging is set up my paster rather than as part of Pyramid. The question is therefore how can I ensure that my script works through the same logging framework, based on development.ini? You can run logging.config.fileConfig('/path/to/ini-file') to load the logging settings. http://docs.python.org/library/logging.config.html#logging.config.fileConfig -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: ownership authorization
Look at my pyramid auth demo on github. It explains how you can use url dispatch along with a resource tree to do row-level authentication. It basically boils down to creating a dynamic __acl__ property on your resource object that will return entries for only users that own your object. Specifically look at the User object. https://github.com/mmerickel/pyramid_auth_demo -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Pyramid authentication and authorization plugin
On Sat, Jun 18, 2011 at 3:56 PM, Liju lij...@gmail.com wrote: Is there a plugin that can be used with Pyramid framework that can do authentication and/or authorization based on LDAP/Custom Registry (Files etc) DB ? You can use pyramid with repoze.who v2 by way of the pyramid_who plugin. I believe that it does have an ldap plugin, as well as many other ways of doing authentication. Note that this is for authentication. Usually authorization is something application-specific so you'll probably have to write your own authorization policy, but luckily the api for that is fairly simple. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Static file in egg file
You need to create a MANIFEST.in file or use one of the SCM plugins for setuptools like setuptools-git which will automatically package files that are under version control. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Pyramid_rpc Json-rpc
On Mon, Jun 20, 2011 at 3:39 AM, Istvan istvan.v...@gmail.com wrote: I would be happy to get an example, how to use it. Can someone suggest a tutorial or a simple example? Thanks, Istvan As I said, the JSON-RPC implementation is in the master branch on github. The docs and tests are there as well. As it's not released, you need to clone the repo and look at it. https://github.com/Pylons/pyramid_rpc/raw/master/docs/jsonrpc.rst -- Michael https://github.com/Pylons/pyramid_rpc/raw/master/docs/jsonrpc.rst -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: chameleon makes pyramid unfriendly
On Tue, Jun 21, 2011 at 9:00 AM, Chris Withers ch...@simplistix.co.ukwrote: 1.x, I don't think Pyramid works with 2.x... The reason chameleon doesn't work with 2.x is because you're using deform, which is currently not compatible with 2.x (at least it's locked to 1.3). Pyramid isn't the issue here. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: webhelpers SCRIPT_NAME
On Wed, Jun 22, 2011 at 2:24 PM, Thomi Richards tho...@gmail.com wrote: Yes I am - I have plans to upgrade to Pylons 1.0, and then to pyramid, but I'm waiting for someone to make an ubuntu package for pyramid, or update the pylons package in ubuntu 11.04 to a later version of pylons. I don't want to state the obvious here, or insult the benefits of using versions from your package manager, BUT, the state of python packaging with virtualenv is such that your development/deployment experience will be much much better, and you will get more current versions of software, if you do not rely on your system's version of python and your system's version of packages (which is usually fairly out of date for any project being actively developed). -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: lengthy controller routines
On Wed, Jun 22, 2011 at 2:42 PM, RVince rvinc...@gmail.com wrote: Will the first controller routine be allowed to finish? Or does it abort, in favor of the latest controller routine. I suppose I am asking if multiple controller routines can be executed by the same client simulataneoulsy? The framework itself does not stop the user from doing anything with any URL. If you want to prevent the user from executing 2 requests simultaneously then you need to track that yourself, and perform the appropriate checks at the start of each request. As far as the framework is concerned a request is anonymous until you treat it otherwise. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Chameleon have template inheritance like mako?
There's a bug in the newly released pyramid 1.1 alpha 1. Temporary solution until 1.1 alpha 2 is out: easy_install pyramid==1.0 -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Chameleon have template inheritance like mako?
FWIW alpha 2 is now released, so you can continue to use 1.1 if you would like. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: using declarative base in pylons project
On Sat, Jun 25, 2011 at 7:19 AM, Grigoriy Tretyakov monax.tinyc...@gmail.com wrote: Hello. I'd like to use declarative_base from sqlalchemy.ext in my project. But for initialize Base, I need engine. How I can get initialized engine in model.__init__.py? May be I could use engine=None? You do not need an engine to build a model using a declarative base. The metadata/base only ever need an engine if you are using autoloading or when you go to create the tables (Base.metadata.create_all(engine=..)). -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: I can't use [\w]{8}(-[\w]{4}){3}-[\w]{12} in add_route pattern ?
Do you think this may be related to https://github.com/Pylons/pyramid/issues/123 which is patched in the 1.1 alpha release? Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Dynamic template rendering
All of Pyramid's template rendering is handled in the context of a request. This is primarily because the template lookup is handled through the registry which is attached to the request. If you have the registry, you can use pyramid.renderers.render() with a dummy request object in order to use the template directly (or if you are in a view, you may just pass in your current request object). I really don't understand your problem though... Pyramid uses views to handle requests, so given that, when you are in your view you may do whatever you want to return a valid pyramid.response.Response object. For example: resp = Response() resp.body = render('mytemplate.mako', {'param': request.params['some_request_param']}, request) return resp -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Dynamic template rendering
On Tue, Jun 28, 2011 at 1:52 PM, Liju lij...@gmail.com wrote: But was checking if there was a way to invoke a template directly without having to route request to a view, like JSP (in J2EE). But I guess its not worth it. On Jun 28, 11:27 am, Michael Merickel mmeri...@gmail.com wrote: All of Pyramid's template rendering is handled in the context of a request. This is primarily because the template lookup is handled through the registry which is attached to the request. If you have the registry, you can use pyramid.renderers.render() with a dummy request object in order to use the template directly (or if you are in a view, you may just pass in your current request object). You specifically asked how to render a template based on a request parameter, which implies that you have a request, which implies that we have no problem here. Like I said, you can fake a request fairly easily, but if you want to use the templating engines that pyramid set up for you, they require the registry. Assuming that the registry is in pyramid.threadlocal.get_current_registry() correctly, you can simply call render('mytemplate.mako', { some dict of values }) and it will work without a request. FWIW if you truly don't care about doing anything in python, you can of course define a view that doesn't do anything, and register that for the routes you want to render: def null_view(request): pass config.add_route('my_route', '/') config.add_route('my_users', '/users') config.add_view(null_view, route_name='my_route', renderer='mytemplate.mako') config.add_view(null_view, route_name='my_users', renderer='myusers.mako') -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Dynamic template rendering
def null_view(request): pass That pass should actually be a return {}, because if a view is using a renderer it needs to return a dictionary. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: comparison between play and pyramid in term of performance
On Wed, Jul 6, 2011 at 9:33 PM, Robert Ramsay duran...@gmail.com wrote: Looking to the future when pyramid can stably run on PyPy, you will likely find it hard to see any difference. FTR, Pyramid does run on PyPy. If you look at jenkins.pylonsproject.org the tests are run on PyPy and Jython just the same as CPython. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: a challenge sending ods file to the browser throgh and an action
For the browser to serve up a file for download you can set the Content-Disposition header on the response. http://en.wikipedia.org/wiki/MIME#Content-Disposition -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: why are not templates automatically reloaded ?
On Sat, Jul 16, 2011 at 5:55 AM, wbwylbt wbwy...@gmail.com wrote: I modified development.ini : 'reload_templates'=true Just to nitpick it should be: [app:myapp] reload_templates = true If you're actually throwing quotes around reload_templates, I'm pretty sure it won't work. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: signal only works in main thread
You may also be able to run the ssh client within a multiprocessing process that you can spawn from the thread. I can't promise that works, but it shouldn't be difficult to try out. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Pyramid transactions and other request lifecycle events
Ben was investigating the idea of tying pyramid_beaker to a transaction, but I'm not sure if anything ever came of it. Maybe we should resurrect the idea. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Pyramid: choose renderer at runtime
This may help you: http://stackoverflow.com/questions/6553569/in-pyramid-how-can-i-use-a-different-renderer-based-on-contents-of-context/6557728#6557728 On top of that, pyramid also supports: request.override_renderer = ... via http://docs.pylonsproject.org/projects/pyramid/1.1/narr/renderers.html#overriding-a-renderer-at-runtime On Thu, Aug 4, 2011 at 8:57 AM, neurino neur...@gmail.com wrote: Is there a *suggested* way to set a view renderer at runtime in Pyramid? What I need is to render, in the same view, a basic form then, if some more info are needed (this is known by first form data), render another form with already entered info as hidden field and more fields to be filled. In a Pylons controller I could select which renderer use like this: def my_view(self): c.form = Form(request, BasicSchema) if c.form.validate(): obj = form.bind(MYModel()) if **need more info**: c.form = Form(AdvancedSchema, obj=obj) if form.validate(): obj = form.bind(obj) else: return render('advanced_form.mako') **persist obj someway** redirect(...) return render('basic_form.mako') In my Pyramid app I have: config.add_route('new', '/new') config.add_view(my_view, route_name='new', renderer='basic_form.mako') and in `basic_form.mako` according to a passed value I render the form one way or another: %if step == 1: #render basic form %else: #render advanced form %endif but it seems a bit ugly and cumbersome to me. Any advice? Thanks for your support -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: how to handle sqlalchemy exception with pyramid?
The real exceptions occur when the data is flushed to the database, not the actual commit. If you do a dbsession.flush() in your view code and it doesn't error then you can be fairly certain that the transaction's commit() will not fail. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: ipython isn't invoked for paster shell
I do not believe that IPython is supported in the *Pylons* shell, paster shell. We do have support for IPython in the paster pshell command that ships with Pyramid. I, however, could be wrong, it's been a while since I've used Pylons. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: ipython isn't invoked for paster shell
Another thing to mention is that we recently updated the Pyramid pshell to support IPython 0.11... the embedded shell was backward incompatible with 0.10. As 0.11 was only recently released you may be experiencing this fallback behavior. Looks like the Pylons shell will need an upgrade if anyone wants to work up a patch! -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: ipython isn't invoked for paster shell
Pyramid's 'pshell' also supports both versions of IPython here: https://github.com/Pylons/pyramid/blob/eaf6cb2372bb274e83b7322b4dc80744de07cb8b/pyramid/paster.py#L185 On Fri, Aug 19, 2011 at 2:04 AM, Andrey Popp 8may...@gmail.com wrote: On Wed, Aug 17, 2011 at 10:02 PM, Iuri Diniz iuridi...@gmail.com wrote: I have the same problem After upgrade to ipython 0.11, paster shell doesn't invoke ipython I downgrade it to ipython 0.10 by $ pip install 'ipython==0.10' Someone should provide patch similar to this one[1]. [1]: https://github.com/mitsuhiko/werkzeug/commit/db8f4dd551430269bf18a0a2593f4543a7223063 -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: The MetaData is not bound to an Engine or Connection.
First of all this belongs in the SQLAlchemy mailing list. I'm guessing that you have not setup your Session object with the engine yet, so bind=Session.bind is just binding to None. Wherever you are initializing your engine you'll want to be doing engine = engine_from_config(...) Session.configure(bind=engine) -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Pyramid 1.2a1 released
It's funny you should ask. :-) http://michael.merickel.org/2011/8/23/outgrowing-pyramid-handlers/ On Aug 24, 2011 6:24 AM, Graham Higgins gjhigg...@gmail.com wrote: Particular thanks to Michael Merickel for this release; much of the code and design in 1.2 is his. Hats off to MM for the solid contrib. I've been following progress on the #pyramid irc log (my TZ=GMT so I'm generally obliged to follow the discussions using the irclog) ... and my attention was drawn to a remark that Michael recently made on #pyramid: Q: Are using Handlers kinda frowned upon? Coming from Pylons and sorta at a fork-in-the-road of whether I should just abandon my old habits or not raydeo: they are fine.. you don't gain a lot by using them though, especially if you don't care about dispatching to a view based on {action} patterns raydeo: and in 1.2 that will be solved more directly using just regular views raydeo: in general I would describe handlers as a crutch :-) okay, I note the smiley but I'd also be interested in a more detailed explanation of the programming / software engineering rationale that underpins a view of handlers as a crutch as this doesn't seem to be explored anywhere in the narrative docs. Cheers, Graham -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To view this discussion on the web visit https://groups.google.com/d/msg/pylons-discuss/-/hJvW4DMsP_AJ. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Pyramid 1.2a1 released
On Wed, Aug 24, 2011 at 12:42 PM, Michael Merickel mich...@merickel.orgwrote: It's funny you should ask. :-) http://michael.merickel.org/2011/8/23/outgrowing-pyramid-handlers/ On Aug 24, 2011 6:24 AM, Graham Higgins gjhigg...@gmail.com wrote: Q: Are using Handlers kinda frowned upon? Coming from Pylons and sorta at a fork-in-the-road of whether I should just abandon my old habits or not raydeo: they are fine.. you don't gain a lot by using them though, especially if you don't care about dispatching to a view based on {action} patterns raydeo: and in 1.2 that will be solved more directly using just regular views raydeo: in general I would describe handlers as a crutch :-) To clarify on that point, I wasn't knocking the concept of controllers/handlers as much as I was talking about the usefulness of the pyramid_handlers package versus doing the class-based views directly in Pyramid. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Pyramid 1.2a1 released
Tweens are Pyramid-specific middleware. They go between the WSGI stack and the main Pyramid application, effectively wrapping your app. On Wed, Aug 24, 2011 at 6:44 PM, Alexandre Conrad alexandre.con...@gmail.com wrote: 2011/8/23 Chris McDonough chr...@plope.com Pyramid 1.2a1 has been released. This is the first alpha release in the 1.2 series. Congrats! A What's New In Pyramid 1.2 document exists at http://docs.pylonsproject.org/projects/pyramid/1.2/whatsnew-1.2.html describing the differences between 1.1 and 1.2. So tweens. It sounds like applying a decorator to each of my views, right? -- Alex | twitter.com/alexconrad -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Applying changes to the database schema – SQLAlchemy
You should address this question to the SQLAlchemy mailing list as it's unrelated to Pyramid, but basically as you said, it's a hard problem that will not be solved simply by changing the property on the column in your class definition. You will need to learn how to mutate the underlying database, by executing raw sql, through some interface for your database, or via the sqlalchemy-migrate package. You should also note that not every database backend supports changing constraints. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Issue with pyramid 1.2a+
The way weberror worked is that it'd dump the URL to the console, and you could visit that url to see the traceback. I think this was fairly reasonable. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Issue with pyramid 1.2a+
I don't see this as an issue because if you're deploying with the debugtoolbar enabled you should be shot. Regardless adding the token to the url doesn't sound like a big deal. I guess we'll just have to think about it. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Issue with pyramid 1.2a+
The toolbar should be configured to *always* dump out the url to the traceback in the logger as well as display the url in the web page rendered for the traceback. I think part of the point of the debugtoolbar is the interactive traceback so I'd like to see 'debug' remain as the default, or rename the setting so that 'true' is the interactive and 'readonly' is the one the user might change it to. On Tue, Aug 30, 2011 at 3:23 PM, Bruce Wade bruce.w...@gmail.com wrote: I like that idea, then at least there is the option of having debugging controls for those who want/need them. On Tue, Aug 30, 2011 at 1:15 PM, Chris McDonough chr...@plope.com wrote: On Tue, 2011-08-30 at 14:01 -0500, Michael Merickel wrote: The way weberror worked is that it'd dump the URL to the console, and you could visit that url to see the traceback. I think this was fairly reasonable. So I have this working on a branch. It keeps exceptions around and dumps a URL to the console with the token in it that is capable of pulling up an exception page. The remaining obsessing that needs to be done (sort of unrelated, but excavated by the work I did) is that currently there's a boolean setting named debugtoolbar.intercept_exc. It currently implies that the traceback page both be shown and that the traceback page embeds the debugging controls. However, the underlying machinery allows the pretty traceback to be shown without the debugging controls (only allowing view source, more or less). I'd like to consider changing the meaning of debugtoolbar.intercept_exc to be a tri-state: false: don't catch the exception at all and let it bubble up true: show the traceback without debugging controls debug: show the traceback with debugging controls Any better idea? - C -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
[pyramid_rpc] 0.3 release
pyramid_rpc 0.3 has been released. Here are the changes: - JSON-RPC support. - Updated both JSON-RPC and XML-RPC to support a workflow closer to that used by Pyramid itself. RPC methods are actual views, thus they accept the full array of view predicates including permissions. - Added a view mapper, which is enabled by default in both XML-RPC and JSON-RPC. Disable it by setting ``mapper=None`` on a method. - Deprecated the previous implementation of XML-RPC. - Removed the (unreleased) JSON-RPC implementation that had been in master. Sorry if you were using it. Documentation is available at https://docs.pylonsproject.org/projects/pyramid_rpc/dev/ You can install it via PyPI: easy_install pyramid_rpc==0.3 Enjoy, and please report any issues you find to the issue tracker at https://github.com/Pylons/pyramid_rpc/issues Thanks! -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Routing requested based on presence of query params
``request_method`` is limited to comparison with a single query parameter. To add more complex behavior you will need to use a custom predicate. Note that you are not required to use 2 routes here... After the pattern is matched for your route, there is view lookup performed based on the *view* predicates. For example: config.add_route('readPage', '/SupportMapAdmin/api') config.add_view(sortView, route_name='readPage', request_param='sort') config.add_view(startAndLimitView, route_name='readPage', request_param='start') config.add_view(startAndLimitView, route_name='readPage', request_param='limit') OR, if this is too verbose, a custom predicate: def custom_param_predicate(*params): def predicate(context, request): return any([param in request.params for param in params]) return predicate config.add_route('readPage', '/SupportMapAdmin/api') config.add_view(sortView, route_name='readPage', request_param='sort') config.add_view(startAndLimitView, route_name='readPage', custom_predicates=(custom_params_predicate('start', 'limit'),)) It is also possible to do this with route predicates instead of view predicates, but I'm not sure why you would want to necessarily unless the different groups of views set different traversal paths or root factories. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: How to route http/https for specific views?
This is actually a fairly large security hole unless you are carefully controlling when the auth cookies are being passed to avoid sending those cookies in the clear. Also the performance on https these days shouldn't be an issue, more and more sites are moving to pure-https. Regardless, the pregenerator on a route exists for this reason, although it's fairly verbose. Basically you can create a pregenerator for a route that modifies the _app_url property to be what you want when generating a URL for that route. def http_only(request, elements, kw): kw['_app_url'] = 'http://' + request.host + request.script_name return elements, kw config.add_route('public', '/public', pregenerator=http_only) request.route_url('public') - http always -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Composite application configuration
Apologies for not following most of the conversation, but just thought I'd mention that in the past I've done: def main(global_conf, **app_settings): settings = global_conf.copy() settings.update(app_settings) Which allows you to override settings in your app if you want while still specifying common setup in [DEFAULT]. Pyramid just uses PasteDeploy to parse the INI file, so any 'set' semantics will still work. Since the settings are not combined by Pyramid, however, I don't think you will gain much by using 'set' over the code I showed above. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Chaining of views using wrapper
1) What url are you visiting when you get the error? 2) There are no routes in play here, so I can't tell if your talk of using pyramid_handlers is a red herring, or the actual problem. Can you elaborate? And to clarify why I care, render_view_to_response (the underlying code behind wrapping views) only works with traversal. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Chaining of views using wrapper
As I said in my previous reply, the wrapped views do not work with routes, only with traversal. Thus they will not work with handlers, which are an abstraction on top of routes. Pyramid does not have a public api for invoking other views during a request. Instead it provides a very extensible mechanism for looking up views based on properties of the request itself, as well as supporting decorators. A very common paradigm is to just abstract common functionality into a method that you call from different views. Thus the code is structured in the opposite direction, instead of a single view with multiple workers, you would have many views. This tends to be what people want anyway, they just aren't used to having the view lookup machinery outside of Pyramid that can call different views based on a query string or anything other predicate for the same physical URL. I'd suggest you think about how to achieve what you want without attempting to wrap the view. If you're still stuck, pyramid_handlers supports the __action_decorator__ class property which will wrap all views within the handler with the decorator, allowing you to mutate the response before it goes out. If you have any questions about what I'm talking about, don't hesitate to ask. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Chaining of views using wrapper
No problem. I feel obligated to mention however that pyramid_handlers works fine for this case as well. You can decorate multiple methods with the same name but different predicates. For example: class MyHandler(object): def __init__(self, request): self.request = request @action(name='endpoint', request_method='GET', renderer='string') def GET_endpoint(self): return 'this is a GET request' @action(name='endpoint', request_method='GET', request_param='fmt=json', renderer='json') def GET_endpoint_for_json(self): return {'key': 'value'} config.add_handler('api', '/foo/{action}', handler=MyHandler) /foo/endpoint - 'this is a GET request' /foo/endpoint?fmt=json - '{key:value}' -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Why is my database session disappearing?
This is a subtle error that is on the docket to get fixed in the future. The issue here is that the settings stored by Pyramid is a *copy* of the dict you passed to the Configurator. Thus any modifications you do to the original dict are irrelevant. Either modify your setup code to mutate the settings dict before passing it to the Configurator, or mutate the copy via config.registry.settings. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Correct way to use a custom 404 view
The way to think about this is that Pyramid is at the end of a WSGI pipeline. It supports a way for catching and handling any exceptions that occur within Pyramid itself via exception views. You have seen one exception view already via the HTTPNotFound exception. You may add an exception view for anything raised within Pyramid, including HTTPForbidden, HTTPInternalServerError or even *Exception*. An exception view is invoked if an exception of that type is *raised*. Thus for your HTTPInternalServerError exception view to be invoked you'd need to raise HTTPInternalServerError somewhere in your code. Obviously the general way to add a view for all exceptions is to add a view for Exception, which uses your internal_error template and sets the response's status to 500. You can then further add more specific instances of Exception, like HTTPNotFound if you wanted a different error template (or status code) for that exception. Note that exception views only work for exceptions, if you *return* HTTPNotFound, the exception view will not be invoked and the returned value will be expected to be a conforming Response object (which it happens to be). Now, if an exception is not handled by Pyramid because you didn't add a view for it, then it will simply propagate up the WSGI stack until something else handled it. WebError is one such option. If left unhandled, the WSGI server will catch it and return a default 500 page (which is what you're seeing). Your INI setup is actually incorrect, because you didn't actually add the filter to the pipeline. Configuring a filter is only one step, you also must add it: [pipeline:main] pipeline = weberror tm myapp -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: wiki.pylonshq.com still supported?
There was some talk at one point of dumping it out as a static site hosted read-only somewhere. I haven't heard anything about that in months though. Sounds like a good idea to me. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: [Paste] Pyramid on Python 3.2
Pyramid is only actually dependent on PasteScript for the paster command and scaffolds, so whether Paste gets ported or not isn't a big deal. The paster command is used to generate scaffolds, start servers and the convenient ability to paster request simulate a request into a conforming WSGI app. If we are interested in porting PasteScript it's definitely an undertaking because there is a large amount of code unused by a basic Pyramid application. It'd probably be worth taking the opportunity to look into some fairly large bw-incompat changes to PasteScript to knock its capabilities into something more manageable. For example, it currently uses Cheetah to do templates which is not py3k compatible whereas Jinja2 is compat and more actively developed/supported. PasteDeploy has been ported, so hopefully INI file syntax can remain relatively unchanged minus the fact that it may be unlikely paste.httpserver is ported. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: [Paste] Pyramid on Python 3.2
On Sun, Sep 25, 2011 at 7:45 PM, Mike Orr sluggos...@gmail.com wrote: I guess we should spec out what we're using in PasteDeploy and PasteScript. Then we can either write a minimal tool(s) for Pyramid that does that, or look for something that does that. If it's a Pyramid tool, we can use Mako or Chameleon, which are already dependencies. If it's a generic tool, we can probably use Tempita because it's tiny. I don't see any reason this tool would be Pyramid-specific. PasteScript is generally useful and I haven't seen a compelling reason to change that. I agree that for this purpose we don't want to change the INI syntax; that would be a separate project. Although we could replace %(here)s with {here} as minor improvement. One of the nastiest parts of PasteDeploy was reading the INI file on demand the way Pylons does it; that requires doing ugly imports and replicating what Paste does because the functions were ill-named and didn't encapsulate the level you needed. There's a Pyramid function now that loads an application for you, but the part about reading a generic section and recognizing Paste'isms like %(here)s isn't done, so that would be one of the goals. This is also entirely independent of the porting issue. PasteDeploy is already ported so we aren't actively searching for a replacement for the reason of running it on py3k. We need a standalone HTTP server of some sort to run out of the box. If not paste.httpserver, what then? PasteScript already bundles the CherryPy WSGI server in its package. This would probably be the logical thing to keep when looking for a default cross-version compatible server to use. Most other servers I'm aware of are not pure-python and have higher barrier to entry when setting up. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Is there an opposite of 'authenticated' in Pyramid?
On Mon, Sep 26, 2011 at 1:36 PM, Benjamin Sims benjamins...@gmail.comwrote: That is, a way to check that a user is not authenticated in order to restrict access to a login form? Restricting access is done via Pyramid's use of ACLs (mapping a user's principals to permissions). This means that you need a way to map a principal X to permission 'not_logged_in'. Principal X could be pyramid.security.Everyone, but obviously that also includes Authenticated users. If you are using one of Pyramid's default authn policies with a callback, it's not going to be possible to build that restriction into the list of principals and you would have to do it through a custom authorization policy. However, it's very easy to implement your own authentication policy and modify the effective_principals(request) function to do exactly what you want. The link below shows how to build a custom authentication policy. https://docs.pylonsproject.org/projects/pyramid_cookbook/dev/authentication.html#custom-authentication-policy -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Is there an opposite of 'authenticated' in Pyramid?
On Tue, Sep 27, 2011 at 4:53 AM, Dan Sommers d...@tombstonezero.net wrote: On Mon, 26 Sep 2011 23:29:07 -0500, Michael Merickel wrote: On Mon, Sep 26, 2011 at 1:36 PM, Benjamin Sims benjamins...@gmail.comwrote: How about some combination of the Authenticated principal and DENY: __acl__ = [(pyramid.security.DENY, pyramid.security.Authenticated, ('login',))] Ha, forgot about DENY. :-) Do that! -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: pyramid_tm: problem upgrading to 0.3
pyramid_tm is now a tween placed under excview. Thus the pipeline for a request ends up: wsgi server - exception views - pyramid_tm - pyramid So the issue here is that pyramid_tm actually expires the commit *before* the exception view is executed. This means that you cannot do database operations in an exception view as it stands without managing the connection yourself. The rationale is behind this is that it makes the api for using the tm more sane. In the past pyramid_tm has used a commit veto that aborts when there is 4xx/5xx responses, exceptions, or x-tm=abort headers. This is fairly complicated and the current interface is simply to abort on exceptions. The old behavior is achievable by placing the pyramid_tm tween over excview instead of under, and using the default_commit_veto that you pasted. In terms of fixing this to allow database operations within your exception views, suggestions are welcome, but I think in general the new behavior is more sane. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: how to exclude some views from csrf checking
matched_route has been around since at least 1.0. It's only not None if using url dispatch. Also, it's a failed attempt at a fix anyway, because now I remember that it isn't populated until after the NewRequest subscriber has been called. Perhaps you should place your CSRF checks on a ContextFound subscriber instead. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Serving Static File with Permissions using Nginx, Uwsgi
You can still have nginx serve your static files after pyramid has checked the permissions by having pyramid return a response containing the x-accel-redirect header. For more info about it look into nginx's version of X-Sendfile. http://wiki.nginx.org/X-accel http://wiki.nginx.org/XSendfile -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Serving Static File with Permissions using Nginx, Uwsgi
Your solution actually isn't any more efficient than what you had before, so I'd expect you'd see a similar performance issue. The point of X-Accel-Redirect is that you do not have to open the file and read it in Python. Your view should return a simple Response object with no body, and just the appropriate headers (possibly content-type, as well as status_code). nginx will see that header and add the body to the response for you outside of Python, leaving your app free to service other requests while nginx handles the file I/O. If you're able to make these improvements and it works, I'd like to add this to the Pyramid cookbook. So hopefully either you can issue a pull request to the cookbook or just paste your changes here and I'll write it up. :-) -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Serving Static File with Permissions using Nginx, Uwsgi
On Mon, Oct 10, 2011 at 2:34 PM, Sharil Shafie sisha...@gmail.com wrote: OK. That means that the response doesnt contain that read file code. That's the idea. The response body would be filled in by nginx. Regardless this was all just a suggestion, there are other reasons why your original response may be having issues when served directly by Pyramid. For example, there could be misconfigured timeouts or size limitations, but it's hard to say. Pyramid should have no trouble serving up static files under light-moderate load. It's just that serving a file takes time, and during that time your application won't be able to service many other requests because it'll occupy one of the threads in your WSGI server's threadpool. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Modifying Beaker Session Timeout
http://stackoverflow.com/questions/7603674/how-do-i-override-the-default-session-timeout-with-pyramid-pyramid-beaker-bea -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: in defense of traversal
On Wed, Oct 12, 2011 at 2:00 PM, Mariano Mara mariano.m...@gmail.comwrote: The with recursive sql idiom (such as the one you would find in pgsql and oracle) could be of help on this situation. It's harder than it sounds to actually utilize that. Each step of traversal expects a new context object, and there isn't an obvious spot in the traversal process to say ok we're done, now perform the query. Also AFAIK SQLAlchemy doesn't provide much assistance in building a with recursive query. Assuming you had some way to return dummy query builder objects during traversal, you might be able to use a ContextFound event at the end of traversal to actually perform the database query and replace the context before view lookup is performed. To know what the dummy objects represent you'd probably still need some in-memory representation of your tree structure. Possibly something smarter could be done with a custom traverser as well. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: ApplicationDelete event
How about registering an atexit handler to cleanup the thread. http://docs.python.org/library/atexit.html -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Recommended way to do background processing once the response is sent
Using a messaging queue via celery or zeromq or anything else is the recommended solution. The response callback is not executed out-of-band so it won't help you here. There's also the option of just using multiprocessing or something to offload the work if you don't want to setup another long-running process. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Crazy behavior of `Making A “User Object” Available as a Request Attribute`
Okay, I can't tell if you are misunderstanding that cookbook recipe, or if you made the decision independent of that to store the user object in your *session*. That is not what the recipe is advocating. It advocates a mechanism to query the user the first time you access that property of the request object and cache the result in memory for the lifetime of that request. Now if you decided that instead of querying the user from a database you would get it from a session then that's fine, but you need to understand that you are serializing a sqlalchemy object into a cookie. Thus when you go back to load that object from the cookie, you need to reconnect it with the database to make sure that it didn't change. This is done via the DBSession.refresh(). The point here is that either way is valid, but you *will* need to talk to the database once per-request if you want to use that object with SQLAlchemy. Another option is to only serialize the properties of the user that you care about, then you can use those directly without having to talk to the database. Then you're making the assumption that those properties didn't change in the background. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Crazy behavior of `Making A “User Object” Available as a Request Attribute`
You would have to paste code to explain why your user object isn't re-queried between requests, because that makes no sense. All the @reify decorator does is cache the object within a single request, it doesn't affect other threads or other requests at all. All I can think of is that you are either looking at the output wrong or you are sharing a database session across threads. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Intermittent encoding error after moving to Apache
The MySQL errors are likely the fact that you didn't set the pool_recycle time in your SQLAlchemy connection pool. MySQL connections timeout (by default) after 8 hours I believe. http://www.sqlalchemy.org/docs/dialects/mysql.html#connection-timeouts The timeout is also available as an INI setting. On Thu, Oct 27, 2011 at 2:41 PM, Benjamin Sims benjamins...@gmail.comwrote: The log is posted at the end of my previous mail - I do sometimes get 'MySQL has gone away errors' but they do not seem to be always at the same time as this one, which is: UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 467 2011/10/27 Cornelius Kölbel cornelius.koel...@lsexperts.de So you get an internal server error? Take a look into the apache error log. I guess you will see a mysql server has gone away Kind regards Cornelius -- Cornelius Kölbel Http://www.lsexperts.de LSE Leading Security Experts GmbH Tel: +49 6151 9067-252, mobil: +49 160 96307089 Unternehmenssitz: Weiterstadt Geschäftsführer: Oliver Michel, Sven Walther, Dr. Peter Schill Am 27.10.2011 um 20:23 schrieb Benjamin Sims benjamins...@gmail.com: Hi all, I've recently moved from Paster + Sqlite to Apache + MySQL and, well, it hasn't been smooth. I'm running into various problems which are likely due to the server setup (occasional very slow connections, MySQL has gone away errors) etc. However, I have one that is really bugging me and I would appreciate any thoughts from those who might have seen it before or can guide me as to where to focus debugging. Every so often, the server will throw a 500 error (log below). I understand the need to encode/decode strings correctly; the problem here is that I cannot reliably reproduce the error to find where the mistake is. If I reload a page ten times, sometimes the error will occur; sometimes it won't. I get the impression that it happens more often when the server isn't 'warmed up' by requests, but I may be imagining this. Thanks for any tips; I apologise for the lack of detail. Ben [Fri Oct 28 02:03:27 2011] [error] No handlers could be found for logger exc_logger [Fri Oct 28 02:03:27 2011] [error] [client 217.46.198.185] mod_wsgi (pid=7827): Exception occurred processing WSGI script '/home/my_user/virtualenv/app_dir.wsgi'., referer: http://example.org/app_dir/stream/all/1 http://example.org/app_dir/stream/all/1 [Fri Oct 28 02:03:27 2011] [error] [client 217.46.198.185] Traceback (most recent call last):, referer: http://example.org/app_dir/stream/all/1 http://example.org/app_dir/stream/all/1 [Fri Oct 28 02:03:27 2011] [error] [client 217.46.198.185] File /home/my_user/virtualenv/lib/python2.6/site-packages/repoze.tm2-1.0b2-py2.6.egg/repoze/tm/__init__.py, line 24, in __call__, referer: http://example.org/app_dir/stream/all/1 http://example.org/app_dir/stream/all/1 [Fri Oct 28 02:03:27 2011] [error] [client 217.46.198.185] result = self.application(environ, save_status_and_headers), referer: http://example.org/app_dir/stream/all/1 http://example.org/app_dir/stream/all/1 [Fri Oct 28 02:03:27 2011] [error] [client 217.46.198.185] File /home/my_user/virtualenv/lib/python2.6/site-packages/pyramid-1.2.1-py2.6.egg/pyramid/router.py, line 176, in __call__, referer: http://example.org/app_dir/stream/all/1 http://example.org/app_dir/stream/all/1 [Fri Oct 28 02:03:27 2011] [error] [client 217.46.198.185] response = self.handle_request(request), referer: http://example.org/app_dir/stream/all/1 http://example.org/app_dir/stream/all/1 [Fri Oct 28 02:03:27 2011] [error] [client 217.46.198.185] File /home/my_user/virtualenv/lib/python2.6/site-packages/pyramid-1.2.1-py2.6.egg/pyramid/tweens.py, line 34, in excview_tween, referer: http://example.org/app_dir/stream/all/1 http://example.org/app_dir/stream/all/1 [Fri Oct 28 02:03:27 2011] [error] [client 217.46.198.185] response = view_callable(exc, request), referer: http://example.org/app_dir/stream/all/1 http://example.org/app_dir/stream/all/1 [Fri Oct 28 02:03:27 2011] [error] [client 217.46.198.185] File /home/my_user/virtualenv/lib/python2.6/site-packages/pyramid-1.2.1-py2.6.egg/pyramid/config/views.py, line 311, in rendered_view, referer: http://example.org/app_dir/stream/all/1 http://example.org/app_dir/stream/all/1 [Fri Oct 28 02:03:27 2011] [error] [client 217.46.198.185] context), referer: http://example.org/app_dir/stream/all/1 http://example.org/app_dir/stream/all/1 [Fri Oct 28 02:03:27 2011] [error] [client 217.46.198.185] File /home/my_user/virtualenv/lib/python2.6/site-packages/pyramid-1.2.1-py2.6.egg/pyramid/renderers.py, line 393, in render_view, referer: http://example.org/app_dir/stream/all/1 http://example.org/app_dir/stream/all/1 [Fri Oct 28 02:03:28 2011] [error] [client 217.46.198.185] return self.render_to_response(response, system, request=request), referer: http://example.org/app_dir/stream/all/1
Re: match_param not behaving as expected - pyramid-1.2.1-Py2.7
match_param is for matching items in the matchdict. These are patterns in your url, for example if you had the url /match/{param}, then you might use match_param='param=edit' to only match when that pattern is edit. request_param is used to match the query string in your url (things after the ?-mark). So you might do request_param='action' to match any url with an action parameter, or request_param='action=edit' to match any url with ?action=edit. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: h.link_to() in Pyramid
These things are not automatically exposed in Pyramid like they were in Pylons. Pyramid's request object has a tmpl_context, but to expose it you must use it in the template as request.tmpl_context or you can inject it as c or some such via a BeforeRender event. A helper object in templates can be achieved using the cookbook recipe here: http://docs.pylonsproject.org/projects/pyramid_cookbook/dev/templates.html#using-a-before-render-event-to-expose-an-h-helper-object -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Possible? Raise HTTPNotFound within Exception handler view
It is not possible to raise an exception within an exception view. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Clarification on Authorization?
Yeah so building off of what Joe said, the basic idea is that the object in question (the context for that URL) should be able to tell the system what principals can access it, and with what permission (ACLs). You can place an __acl__ on your RandomObject that returns the list of Accounts available to access it. You'll want to make the __acl__ dynamic by making it a function and decorating it with @property. The proper RandomObject is loaded from a URL by modifying the route's traversal tree and traversal path (setting the factory and the traverse parameters). For example, you might use a resource tree that only traverses the path traverse='/{object}/{id}' (I doubt the account is relevant when finding the URL in your database, but maybe you want to use it anyway to set a default ACL for that single Account). -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Form field processing
The key[subkey] syntax is not supported in WebOb (I think). On Mon, Nov 14, 2011 at 11:41 AM, Chris McDonough chr...@plope.com wrote: On Mon, 2011-11-14 at 09:28 -0800, Mengu wrote: actually, pylons had this. it was request.params.getall('param') but pyramid does not support this. It does, actually. It's a WebOb feature (both Pyramid and Pylons use WebOb). - C On Nov 14, 6:12 pm, Gael Pasgrimaud g...@gawel.org wrote: Hi, Are you coming from php ? :) WebOb does not handle arrays/hashes and I don't think that this is in the current roadmap. On Mon, Nov 14, 2011 at 7:52 AM, uday gotou...@gmail.com wrote: Hi all, I think it is more helpful if we can make form fields processing more convenient which can reduce verbosity in views. for example assume profile model/table has fields username and password in my form i write likeinput type='text' name='profile[username']input type='password' name='profile[password]' so when this form is submitted, it would be cool if I can just do like: request.POST['profile'] which gives me a dict of names and values specific to that model/table whatever so if I do request.POST['profile'] = {'username': value entered by user, 'password': value entered by user} is this feature already there? or can it be achieved in any other way? is it related to webob or pyramid? I am ready to work on this to make it available in pyramid, so please give me pointers to work on this. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com . To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group athttp:// groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Checking permission using route name?
You can use pyramid.security.has_permission() to check access to a particular permission. view_execution_permitted is traversal-only. For has_permission() you just need to be sure to pass in the context that contains the correct ACLs for that view. On Mon, Nov 14, 2011 at 12:18 PM, Mark Erbaugh m...@microenh.com wrote: On Nov 14, 2011, at 10:29 AM, Mattias wrote: Is there anyway to check if the user have the required permissions when I only know the route_name? def main(global_config, **settings): [snip] config.add_route('administrations', '/administrations') class Administration(object): def __init__(self, request): self.request = request @view_config(route_name = 'administrations', renderer='administration.mako', permission='admin) def admin(self): return {'name':'test'} I tried view_execution_permitted(self.request.context, self.request, view_name) but since I am using URL dispatch my views don't have any view_names so that functions always return a Allowed() instance. My understanding is that if someone without admin permission would automatically get a HTTP Forbidden response if they try to visit the administrations page. In fact, in the documentation under the SQLAlchemy + URL Dispatch Tutorial, the HTTP Forbidden view is remapped to the login screen. Thus, if someone tries to access the page withouth proper credentials, they get a chance to provide those credentials. Or am I missing something in your question? Mark -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Form field processing
uday, I think you'll want to just prefix your values, then you can iterate over the POST and turn it into a dictionary: input name=profile-name/ input name=profile-email/ profile = {} for k in request.POST.keys(): if k.startswith('profile-'): profile[k[len('profile-'):]] = request.POST.get(k) name = profile.get('name', 'Bob') On Mon, Nov 14, 2011 at 12:29 PM, Chris McDonough chr...@plope.com wrote: On Mon, 2011-11-14 at 13:27 -0500, Chris McDonough wrote: On Mon, 2011-11-14 at 12:21 -0600, Michael Merickel wrote: The key[subkey] syntax is not supported in WebOb (I think). Yeah, sorry. I meant that when you do this in a form: input type=text name=foo/input input type=text name=foo/input You can do in a view: request.getall('foo') Sorry, rather: request.POST.getall('foo') On Mon, Nov 14, 2011 at 11:41 AM, Chris McDonough chr...@plope.com wrote: On Mon, 2011-11-14 at 09:28 -0800, Mengu wrote: actually, pylons had this. it was request.params.getall('param') but pyramid does not support this. It does, actually. It's a WebOb feature (both Pyramid and Pylons use WebOb). - C On Nov 14, 6:12 pm, Gael Pasgrimaud g...@gawel.org wrote: Hi, Are you coming from php ? :) WebOb does not handle arrays/hashes and I don't think that this is in the current roadmap. On Mon, Nov 14, 2011 at 7:52 AM, uday gotou...@gmail.com wrote: Hi all, I think it is more helpful if we can make form fields processing more convenient which can reduce verbosity in views. for example assume profile model/table has fields username and password in my form i write likeinput type='text' name='profile[username']input type='password' name='profile[password]' so when this form is submitted, it would be cool if I can just do like: request.POST['profile'] which gives me a dict of names and values specific to that model/table whatever so if I do request.POST['profile'] = {'username': value entered by user, 'password': value entered by user} is this feature already there? or can it be achieved in any other way? is it related to webob or pyramid? I am ready to work on this to make it available in pyramid, so please give me pointers to work on this. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss +unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss +unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en
Re: beaker configuration
This is probably because the arguments to the method change every time the method is called. i.e. self is a different instance of your class every time. On Mon, Nov 14, 2011 at 1:49 PM, Jason ja...@deadtreepages.com wrote: Whenever I call a method decorated with cache_region it is still executing the method every time it is called (as I see with a print statement while in development). I have my beaker config in the INI file: cache.regions = default_term, second, short_term, long_term cache.type = memory cache.second.expire = 1 cache.short_term.expire = 60 cache.default_term.expire = 300 cache.long_term.expire = 3600 Which get configured as regions in main(): pyramid_beaker.set_cache_regions_from_settings(settings) In the handler (I'm using pyramid_handlers) I have imported from beaker.cache import cache_region and then used the decorator as: @cache_region('default_term', 'contacts') def _get_contacts(self, userid): print 'retrieving contacts' # get contacts from another server return contacts This is being called from a view-callable. Is there something simple I am overlooking, this is all the setup that I have seen required in the pyramid_beaker and beaker documentation. Thanks, Jason -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To view this discussion on the web visit https://groups.google.com/d/msg/pylons-discuss/-/wbJZX5hgbFQJ. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: beaker configuration
Don't upgrade to 1.6 quite yet. pyramid_beaker doesn't support it until its next release which I hope will be very soon. On Mon, Nov 14, 2011 at 3:21 PM, Jason ja...@deadtreepages.com wrote: You're absolutely right. Caching instance methods with the cache_region decorator is only supported in Beaker 1.6 and higher. I'm using 1.5.4 (thanks for debug toolbar letting me easily see the versions). -- Jason -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To view this discussion on the web visit https://groups.google.com/d/msg/pylons-discuss/-/3uaZLUSqQYoJ. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Multiple transactions within request
It's been hard to follow what has actually been tried, but I just wanted to point some stuff out about zope.sqlalchemy (the code for it is literally 1 small file and shouldn't be talked about with such a scary tone). When doing transaction.savepoint() it returns a savepoint object that calls session.begin_nested(). and when you call rollback on that savepoint object it calls session.rollback(). I think that is identical to SQLAlchemy's expected use. For example: sp = transaction.savepoint() # session.begin_nested() try: # do stuff except IntegrityError: sp.rollback() # session.rollback() # do more stuff transaction.commit() # or ideally don't commit and let pyramid_tm do that part for you On Tue, Nov 15, 2011 at 9:19 AM, Michael Bayer mike...@zzzcomputing.comwrote: On Nov 15, 2011, at 7:09 AM, Vlad K. wrote: Why I didn't think of this earlier? Transaction complains if you use session.commit() or session.begin_nested() directly, wants you to use transaction.commit() and transaction.savepoint() instead and it just didn't occur to me to try session.rollback() nevertheless (and in my mind transaction.abort() == session.rollback() which now I see is NOT the same), and trying savepoint.rollback() fails, I assumed session.rollback() was called by Transaction since the SQL debug output clearly shows savepoint rollback being emitted, so I went to search for another solution. Aside from me being silly for not trying this before (and it is even suggested by the InvalidRequestError!), it is a bit illogical to have to use transaction.savepoint() and then use session.rollback() instead of savepoint.rollback(). glad you figured this out. Now we need to adjust zope.sqlalchemy's API and/or documentation so that the SAVEPOINT use case is made clear.I would think that since SAVEPOINTs can be per-connection, perhaps zope.sqlalchemy would support begin_nested() on individual sessions...or maybe not. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: Absolute path for static assets/ Get file modified time
You will need to use the pkg_resources api from the Python stdlib. Currently (this will be fixed in 1.3) there is no public API for computing paths. import pkg_resources asset_path = 'mypackage:static/favicon.ico' package, file = asset_path.split(':', 1) abs_path = pkg_resources.resource_filename(package, file) last_access_time = os.stat(abs_path)[8] On Wed, Nov 16, 2011 at 3:55 PM, Jay T jay.pyl...@gmail.com wrote: How do I get the absolute path for static assets ? The reason I need the absolute path is to determine the last modified time of a specific file so I can append it to my static resources like JS and CSS files. I wrote a Mako template def like this but it fails at : here = os.path.dirname(__file__) %def name=appendFileModifiedTime(**path) % fmTime = -1 import os here = os.path.dirname(__file__) path = os.path.join(here,path) if os.path.exists(path): fmTime = os.stat(path)[8] else: fmTime = -999 path = path +'?%s'%fmTime return path % /%def Thanks, Jay -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.**compylons-discuss@googlegroups.com . To unsubscribe from this group, send email to pylons-discuss+unsubscribe@* *googlegroups.com pylons-discuss%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/** group/pylons-discuss?hl=enhttp://groups.google.com/group/pylons-discuss?hl=en . -- Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.