Colander: How to list attributes? Mixins or inheritance?
Hi all, about Colander I have 2 questions: [1] given a colander schema like class Principal(MappingSchema): is_enabled = SchemaNode(Bool() , title = 'Enabled?' , foo = 'bar' ) How can I build a list of the defined fields which are class attributes and tell their kwargs? (I'd like to use Colander to define more general data dictionaries and want to read those definitions under different circumstances.) [2] If many schemas have several attributes in common, is it possible to define them in a separate schema and use that as a mix-in? Or must the common schema be inherited from? [a] Mixin class MyMixin(object): frobotz = SchemaNode(Bool() , title = 'FroBotz?' , baz = 'qux' ) class MySchema(MappingSchema, MyMixin): ... [b] Inheritance class MyMixin(MappingSchema): frobotz = SchemaNode(Bool() , title = 'FroBotz?' , baz = 'qux' ) class MySchema(MyMixin): ... Thanks for your help. Dirk -- 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/-/9FiyoAgOi2AJ. 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: deform: template cache and i18n
Upgrading does not work. Deform complains: File .../lib/python2.6/site-packages/deform/template.py, line 4, in module from chameleon.zpt import language ImportError: cannot import name language On Thu, Aug 11, 2011 at 1:24 PM, Malthe Borch mbo...@gmail.com wrote: On 11 August 2011 10:19, Robert Forkel xrotw...@googlemail.com wrote: I noticed that deform form rendering is somewhat slow in my application and found the @cache decorator in deform.template. I'd like my templates to be cached, but since I use i18n, thus passing translators to initialize a template loader on a per request basis, this does not work. Now I only have a limited number of locales to support, so I was thinking about initializing template loaders for these locales at application start. But in this case, the cache decorator would have to take the translate attribute into account as well and not only the template filename. Try upgrading to Chameleon 2.x. The ``cache`` decorator you're talking about is not used on this version and I'd expect that it would just work for you out of the box. I assume that you're using the default language setup: https://docs.pylonsproject.org/projects/pyramid/1.0/narr/i18n.html#default-locale-negotiator \malthe -- 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: deform: template cache and i18n
On 11 August 2011 13:42, Robert Forkel xrotw...@googlemail.com wrote: Upgrading does not work. Deform complains: File .../lib/python2.6/site-packages/deform/template.py, line 4, in module from chameleon.zpt import language ImportError: cannot import name language You need deform=0.9.2. \malthe -- 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: deform: template cache and i18n
ok. i got chameleon 2.3 to work. but I still think I have to keep locale specific TeplateLoaders around to make caching work, because the registry key for a template does still not take locale into account, thus may retrieve a template with the wrong translator. Am I missing something? On Thu, Aug 11, 2011 at 2:03 PM, Malthe Borch mbo...@gmail.com wrote: On 11 August 2011 13:42, Robert Forkel xrotw...@googlemail.com wrote: Upgrading does not work. Deform complains: File .../lib/python2.6/site-packages/deform/template.py, line 4, in module from chameleon.zpt import language ImportError: cannot import name language You need deform=0.9.2. \malthe -- 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.
Extracting translation strings for templates using include macros
Since i18n seems to be the topic of the day, I would really appreciate help with this: I have a master template to contain headers and so forth, with various pages 'inheriting'. So, master has: tal metal:define-slot=mainMain page content in div/tal and the pages will do: tal metal:use-macro=master div metal:fill-slot=main Pretty standard stuff. However, I can't manage to extract translation strings from the various templates. If I add the full html header: html xmlns=http://www.w3.org/1999/xhtml; xmlns:tal= http://xml.zope.org/namespaces/tal; xmlns:i18n= http://xml.zope.org/namespaces/i18n; i18n:domain=myapplication it will work, but only if I also remove the macro code. Otherwise, the extractor (lingua-xml) ignores the strings - presumably on the grounds that the xml is not valid by itself. Could somebody advise me as to the best way to do this? I've experimented with variations on the theme of: http://chameleon.repoze.org/docs/latest/i18n.html#relation-with-metal-processingbut none seem to get me anywhere. Ben -- 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.
Unicode value
I have a form that I put a unicode character in one of the fields. I'm not sure what I am doing wrong: I put the character é (http://www.fileformat.info/info/unicode/char/e9/index.htm) into the form field and save it. The value in request.params shows u'Test Unicod\xc3\xa9' -- I think this should be u'Test Unicod\xe9' if it was properly decoded to utf-8. Is there somewhere I need to specify Pyramid to decode the posted values as UTF-8? 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/-/xKJaDiSidioJ. 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, Mod_WSGI and Webfaction help needed
Hi Awais, I use webfaction and I've always created a custom app (listening on port). I know it's not the most helpful answer, but you might consider setting up the app to listen on a certain port, configuring paster to run on that port, and then running: $ bin/paster serve --daemon production.ini start As for the other issues, I'm not clear on how you're transferring the code to the server. Unless you are using the server as your development environment, it might help to build the application on your computer, package it into an egg, and install it on the server with easy_install. You can always use the --install-dir=/some/other/directory option with easy_install if you really want it to be placed somewhere other than the site-packages directory of your virtualenv, although personally I think that is the best place. If you release revisions later on you can deploy a new egg with a new version number and not have to worry about keeping all the folders and subfolders of an entire application in sync in two different spots. Lastly,if you want uploaded files sent somewhere else you'd need to install the application in a different directory or specify a different path for uploading. For production applications on webfaction I run a separate static application to serve images/css/js and then mount it at myappurl/static/, to prevent requests for those files from having to go through the application. Anyway, I hope this gives you a better starting point, but I realize I haven't fully answered your questions. Maybe someone more familiar with mod_wsgi can jump in. Take care, Eric On Wed, Aug 10, 2011 at 1:13 PM, AwaisMuzaffar awais1...@googlemail.comwrote: Hi Guys, I followed the following guide (http://www.kemeneur.com/clients/pylons/ docs/pyramid/tutorials/modwsgi/index.html) to set up my application using mod_wsgi in WebFaction. However, I am a little bit puzzled about a few things. When I create a new app as shown in step 6 in webfaction: $ cd ~/modwsgi/env $ bin/paster create -t pyramid_starter myapp Every time I copy 'myapp' development files from my local machine to the server via ftp I have to do: $ ../bin/python setup.py install for the app on the server to update. Why? And secondly, I have an upload function in the app, and when I uploaded my files in the app I discovered they were placed in: ./modwsgi/env/lib/python2.6/site-packages/myapp-0.0-py2.6.egg/myapp/ static/uploads/file.jpg The function is using this to get my directory: _current = os.path.dirname(__file__) Why are they being placed in the site-packages folder? Please could someone clarify these issues for me, and whether I am doing things the right way Thanks for your time and help. Regards, Awais -- 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: Unicode value
On Thu, 2011-08-11 at 09:02 -0700, Jason wrote: I have a form that I put a unicode character in one of the fields. I'm not sure what I am doing wrong: I put the character é (http://www.fileformat.info/info/unicode/char/e9/index.htm) into the form field and save it. The value in request.params shows u'Test Unicod\xc3\xa9' -- I think this should be u'Test Unicod\xe9' if it was properly decoded to utf-8. Is there somewhere I need to specify Pyramid to decode the posted values as UTF-8? https://docs.pylonsproject.org/projects/pyramid/1.1/narr/views.html#handling-form-submissions-in-view-callables-unicode-and-character-set-issues 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/-/xKJaDiSidioJ. 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: deform: template cache and i18n
On 11 August 2011 14:43, Robert Forkel xrotw...@googlemail.com wrote: ok. i got chameleon 2.3 to work. but I still think I have to keep locale specific TeplateLoaders around to make caching work, because the registry key for a template does still not take locale into account, thus may retrieve a template with the wrong translator. Am I missing something? I think the idea is that the translation function is added at render time by keyword argument to the template render function. In other words, it's dynamically set for each rendering. \malthe -- 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: deform: template cache and i18n
Yes, that's what I'm doing now. Right now it's sort of tied to the TemplateLoader, though - at least the way deform uses Chameleon. So what I do is keep the zpt renderers around and assign to renderer.loader.kwargs['translate'] per request - not exactly a nice API to do that. On Thu, Aug 11, 2011 at 7:07 PM, Malthe Borch mbo...@gmail.com wrote: On 11 August 2011 14:43, Robert Forkel xrotw...@googlemail.com wrote: ok. i got chameleon 2.3 to work. but I still think I have to keep locale specific TeplateLoaders around to make caching work, because the registry key for a template does still not take locale into account, thus may retrieve a template with the wrong translator. Am I missing something? I think the idea is that the translation function is added at render time by keyword argument to the template render function. In other words, it's dynamically set for each rendering. \malthe -- 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: Unicode value
Groovy. It looks like setting the charset class attribute of a request subclass is deprecated, yet the documentation advises this at https://docs.pylonsproject.org/projects/pyramid/1.1/narr/webob.html#unicode Setting charset as an instance variable on my Request subclass instance worked though: class RequestWithUser(Request): def __init__(self, *args, **kwargs): Request.__init__(self, *args, **kwargs) self.charset = 'utf-8' And I had to switch to using webhelpers.util.html_escape instead of webhelpers.html.escape. -- 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/-/SsMIiV3jLYcJ. 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, authentication and userid
Hello. In the pyramid.authentication.SessionAuthenticationPolicy (or AuthTktAuthenticationPolicy) class description there is constructor argument ``callback``. One of ``callback`` arguments is `userid`. What exactly `userid` is? As I've found from the sources, it's a value that passed to pyramid.security.remember, but in that method argument is named principal. Moreover, I can pass to pyramid.security.remember not string but object (sqlalchemy model for example) and everything is working just fine (stored in the session). So maybe developers should rename userid to principal? And another question. What's the recommended way to store sqlalchemy model instance in the session that represents current user? I don't want to query database every HTTP request to obtain user object by it's uid stored as ``principal`` value. -- Sergei Stolyarov -- 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: are there still pylons eggs available?
On Mon, Aug 8, 2011 at 1:19 PM, Tjelvar tjelvar.ols...@gmail.com wrote: I'm trying to install Pylons using easy_install, but the installation egg does not seem to be available. bash-4.2$ ./easy_install Pylons=1.0 Searching for Pylons=1.0 Reading http://pypi.python.org/simple/Pylons/ Reading http://www.pylonshq.com/ Download error: [Errno 110] Connection timed out -- Some packages may not be found! (It seems like http://www.pylonshq.com/ does not exist any more) Does anyone know what is going on? Also, does anyone have any tips on how I can install Pylons 1.0? You can download Pylons 1.0b1 from http://pylonsproject.org/projects/pylons-framework/download and then install it with easy_install -- 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, authentication and userid
Hello. In the pyramid.authentication.SessionAuthenticationPolicy (or AuthTktAuthenticationPolicy) class description there is constructor argument ``callback``. One of ``callback`` arguments is `userid`. What exactly `userid` is? As I've found from the sources, it's a value that passed to pyramid.security.remember, but in that method argument is named principal. Moreover, I can pass to pyramid.security.remember not string but object (sqlalchemy model for example) and everything is working just fine (stored in the session). So maybe developers should rename userid to principal? And another question. What's the recommended way to store sqlalchemy model instance in the session that represents current user? I don't want to query database every HTTP request to obtain user object by it's uid stored as ``principal`` value. -- Sergei Stolyarov -- 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, authentication and userid
Hello. In the pyramid.authentication.SessionAuthenticationPolicy (or AuthTktAuthenticationPolicy) class description there is constructor argument ``callback``. One of ``callback`` arguments is `userid`. What exactly `userid` is? As I've found from the sources, it's a value that passed to pyramid.security.remember, but in that method argument is named principal. Moreover, I can pass to pyramid.security.remember not string but object (sqlalchemy model for example) and everything is working just fine (stored in the session). So maybe developers should rename userid to principal? And another question. What's the recommended way to store sqlalchemy model instance in the session that represents current user? I don't want to query database every HTTP request to obtain user object by it's uid stored as ``principal`` value. -- Sergei Stolyarov -- 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 userid
Sorry, all three of these messages were held for moderation and I approved all three. I have no idea why the pylons maillist holds anything for moderation, it's not configured to, but haven't had time to figure out why. - C On Thu, 2011-08-11 at 18:09 +0700, Sergei Stolyarov wrote: Hello. In the pyramid.authentication.SessionAuthenticationPolicy (or AuthTktAuthenticationPolicy) class description there is constructor argument ``callback``. One of ``callback`` arguments is `userid`. What exactly `userid` is? As I've found from the sources, it's a value that passed to pyramid.security.remember, but in that method argument is named principal. Moreover, I can pass to pyramid.security.remember not string but object (sqlalchemy model for example) and everything is working just fine (stored in the session). So maybe developers should rename userid to principal? And another question. What's the recommended way to store sqlalchemy model instance in the session that represents current user? I don't want to query database every HTTP request to obtain user object by it's uid stored as ``principal`` value. -- Sergei Stolyarov -- 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 userid
Actually I misunderstood your post, but perhaps you could use a similar pattern for saving it in the session instead of the request? -- 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/-/QR7aQORloAcJ. 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: GAE support
On Aug 10, 2011, at 5:33 PM, Chris McDonough wrote: In the meantime, GAE has become basically the only reason to support Python 2.5 in Pyramid. FYI this would also affect Jython. Work has started on 2.6 support, but it's been pretty slow. -- Philip Jenvey -- 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: GAE support
On Thu, 2011-08-11 at 11:50 -0700, Philip Jenvey wrote: On Aug 10, 2011, at 5:33 PM, Chris McDonough wrote: In the meantime, GAE has become basically the only reason to support Python 2.5 in Pyramid. FYI this would also affect Jython. Work has started on 2.6 support, but it's been pretty slow. Alex Gaynor pointed this out to me yesterday, I totally forgot that Jython wasn't yet 2.7. Not sure I want to ditch Jython support, so perhaps that announcement was a little hasty. Hurry up though! ;-) - 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.
ipython isn't invoked for paster shell
Hello -- I'm using pylons for a mapfish project and would love to get the ipython interpreter working when I call paster shell. From what I've read on the net, it should automatically use ipython if ipython is installed. I've installed ipython both globally (in the vm) as well as within the mapfish vm, yet this is what happens: (mapfish)[root@localhost]# paster shell development.ini Pylons Interactive Shell Python 2.6.6 (r266:84292, Jun 6 2011, 02:26:45) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] All objects from *.lib.base are available Additional Objects: mapper - Routes mapper object wsgiapp- This project's WSGI App instance app- paste.fixture wrapped around wsgiapp That's not ipython... Iipython 0.10 pylons 1.0 CentOS release 5.6 VM Any ideas? Thanks. Cody -- 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: Pyramid, authentication and userid
Thanks, I've already read that, it looks really complicated for me, I'm trying to write something simple using already existing classes from pyramid (SessionAuthenticationPolicy etc). On Fri, Aug 12, 2011 at 1:38 AM, Jason ja...@deadtreepages.com wrote: Actually I misunderstood your post, but perhaps you could use a similar pattern for saving it in the session instead of the request? -- Sergei Stolyarov -- 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.