unicode problem
Hello all, I use Pylons 0.9.6 with SQLAlchemy 0.4.1 and Genshi 0.4.4 I have a strange unicode dilemma ... : - either I set sqlalchemy.convert_unicode = true in my configuration file and url_for fails with : exceptions.Exception: url_for can only return a string or None, got unicode instead: /ias/pics/published.png - either I don't set sqlalchemy.convert_unicode and then Genshi fails with : exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128) Any idea how could I resolve this (other than str() everything in my template files ..) ? Thanks, Julien -- Julien Cigar Belgian Biodiversity Platform http://www.biodiversity.be Université Libre de Bruxelles (ULB) Campus de la Plaine CP 257 Bâtiment NO, Bureau 4 N4 115C (Niveau 4) Boulevard du Triomphe, entrée ULB 2 B-1050 Bruxelles Mail: [EMAIL PROTECTED] @biobel: http://biobel.biodiversity.be/person/show/471 Tel : 02 650 57 52 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: mod_wsgi and pylons, Logging
Sorry, got myself confused, where I said CustomLog I meant ErrorLog. Can you summarise what works and doesn't for basic use case inside a hello world application. Ie., what gets output to Apache error log (and which one) for the following: import sys def application(environ, start_response): status = '200 OK' output = 'Hello World!' print sys.stderr, sys.stderr print environ[wsgi.errors], wsgi.errors response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output] This will tell me if we are talking about an underlying mod_wsgi issue, or something specific to how Pylons does logging. Note that LogLevel directive in Apache must be at least 'error' for either of these to be displayed. Generally the default is 'warn' which should capture them. If both of those works in both embedded and daemon mode, but a Pylons specific application is not generating anything to error log when you expect it, can you give a small example which would demonstrate the problem. Thanks. Graham On Dec 20, 5:41 pm, Jeff Lindsay [EMAIL PROTECTED] wrote: Ok, that makes sense now but only concerns me more because logging in daemon mode is not working, using wsgi.errors or sys.stderr. However, I'm a bit confused because CustomLog is used for access logs, which does work btw if I wasn't clear. It's only error logs that don't work. -jeff On Dec 19, 2007 9:47 PM, Graham Dumpleton [EMAIL PROTECTED] wrote: I am only referring to anything output directly via sys.stderr. Any messages output via wsgi.errors passed in the WSGI environment, which is how most WSGI application would tend to log, would go to the log file associated with the context the request is handled in. If you have a CustomLog in a VirtualHost container, then that is where those messages would go. Any error messages generated by mod_wsgi, including error tracebacks, which correspond to a specific request will similarly be output to the error log file associated with the VirtualHost if CustomLog is used. The case which differs is when using sys.stderr directly, or where using the logging module since it defaults to using sys.stderr also. Because sys.stderr is global to the interpreter it isn't associated with a specific request and so cannot normally be associated with the custom log of the virtual host. This is the case because technically it is possible for requests against different virtual hosts to be directed to the same interpreter instance. Daemon mode, where WSGIDaemonProcess is used inside of a VirtualHost, is a special case because in that scenario, that the directive appears inside of the VirtualHost means that only requests bound for that virtual host could be sent to that daemon process. This means that mod_wsgi can associat sys.stderr for that daemon process with the error log for that VirtualHost rather than it going to the global Apache error log. Graham On Dec 20, 2:30 pm, Jeff Lindsay [EMAIL PROTECTED] wrote: That doesn't seem to be the case. We're using this inside our VirtualHost: ErrorLog /path/to/error_log CustomLog /path/to/access_log combined We're looking at the error_log file for this vhost and in embedded mode we *do* see Pylons errors when raised but in daemon mode we do not, which seems the opposite of what you say... except that we don't get the errors in the main apache log either when in daemon mode. This is Gentoo btw. -jeff On Dec 19, 2007 6:28 PM, Graham Dumpleton [EMAIL PROTECTED] wrote: Which Apache error log file are you looking in? Do you have VirtualHost specific CusomLog defined? When run in mod_wsgi daemon mode, the sys.stderr output will be redirected to a VirtualHost specific error log file if WSGIDaemonProcess was defined in the context of the VirtualHost. When in mod_wsgi embedded mode, the sys.stderr output will always go to the main Apache error log file even if a VirtualHost specific error log file has been defined. Graham On Dec 20, 10:30 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hey Graham, Actually, I thought I was having the same issue since I was getting no logging at all from Pylons when using mod_wsgi. However, after trying this and it not working, it looks like it has to do with using mod_wsgi in daemon mode. (No, not on FreeBSD this time). I can seem to log from the wsgi script, but once in Pylons it just doesn't spit anything out unless running in embedded mode. I'm simply using: WSGIApplicationGroup %{GLOBAL} WSGIDaemonProcess localdev-site user=me group=me WSGIProcessGroup localdev-site WSGIScriptAlias / /path/to/script.wsgi And I get nothing. WSGIApplicationGroup %{GLOBAL} #WSGIDaemonProcess
cgi.FieldStorage override
How would you let your app use a subclass of cgi.FieldStorage? I find this recipe: http://wiki.pylonshq.com/display/pylonscookbook/Hacking+Pylons+for+handling+large+file+upload has very good points, and I thank its author to share them. But I simply couldn't make them work, since passing a non-default base_wsgi_app to PylonsApp in config/middleware.py seems to not be enough: a standard WSGIRequest from paste.wsgiwrappers is still used by Routes. I worked out this traceback from a post request with multipart/form- data content: File '/usr/lib/python2.5/site-packages/Pylons-0.9.6.1-py2.5.egg/pylons/ error.py', line 245 in respond app_iter = self.application(environ, detect_start_response) File '/usr/lib/python2.5/site-packages/Pylons-0.9.6.1-py2.5.egg/pylons/ wsgiapp.py', line 315 in __call__ return self.app(environ, start_response) File '/usr/lib/python2.5/site-packages/Beaker-0.7.5-py2.5.egg/beaker/ cache.py', line 180 in __call__ return self.app(environ, start_response) File '/usr/lib/python2.5/site-packages/Beaker-0.7.5-py2.5.egg/beaker/ session.py', line 405 in __call__ response = self.wrap_app(environ, session_start_response) File '/usr/lib/python2.5/site-packages/Routes-1.7.1-py2.5.egg/routes/ middleware.py', line 58 in __call__ elif is_form_post(environ) and '_method' in req.POST: File '/usr/lib/python2.5/site-packages/Paste-1.4.2-py2.5.egg/paste/ wsgiwrappers.py', line 213 in POST params = self._POST() that obviously ends up referencing cgi.FieldStorage from standard library. Don't you believe a less hacky solution should be available? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: AuthKit problems
Hi James, I'm happy to know that I do'nt must use SAContext ... because it's non installable, at least fo me. I did try to follow the information of Mike Orr and samething is changed. Now the it seems that the 'sqlalchemy_04_driver' have some problem with 'environ' object. Could be I do'nt work correctly at the model level but i search to follow your example in '' Authentication and Authorization' to apply database users and roles at the QuickWiki. The alternative documents that Mike indicate to me do'nt seems to contain the necessary informations. What can I do? Help me. Enrico Secco [EMAIL PROTECTED]:~# paster setup-app test.ini Running setup_config() from quickwiki.websetup Traceback (most recent call last): File /usr/bin/paster, line 8, in module load_entry_point('PasteScript==1.3.6', 'console_scripts', 'paster') () File /usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg/ paste/script/command.py, line 78, in run invoke(command, command_name, options, args[1:]) File /usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg/ paste/script/command.py, line 117, in invoke exit_code = runner.run(args) File /usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg/ paste/script/appinstall.py, line 68, in run return super(AbstractInstallCommand, self).run(new_args) File /usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg/ paste/script/command.py, line 212, in run result = self.command() File /usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg/ paste/script/appinstall.py, line 456, in command self, config_file, section, self.sysconfig_install_vars(installer)) File /usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg/ paste/script/appinstall.py, line 592, in setup_config mod.setup_config(command, filename, section, vars) File /usr/lib/python2.5/site-packages/QuickWiki-0.1.5-py2.5.egg/ quickwiki/websetup.py, line 22, in setup_config users = UsersFromDatabase(model) File /usr/lib/python2.5/site-packages/AuthKit-0.4.1dev_r143- py2.5.egg/authkit/users/sqlalchemy_04_driver.py, line 100, in __init__ if not environ.has_key('sqlalchemy.model') or not environ.has_key('sqlalchemy.session'): AttributeError: 'module' object has no attribute 'has_key' On 19 Dic, 22:45, James Gardner [EMAIL PROTECTED] wrote: Hi Lythoner, You've spotted the SQLAlchemy 0.4 driver have you? AuthKit has never used SAContext ever. Cheers, James Lythoner LY wrote: Enrico, AuthKit 0.4 is not updated to use the full power of sqlalchemy 0.4. I had faced a lot of issues with UsersFromDatabase class last week. SAContext is a hook they have added temporarily to help the session management and reduce number of repetitive code. Now sqlalchemy 0.4 has improved in this area. AuthKit 0.4 code is really cruft and it has to be updated in many areas require clean up. Myself I did some changes in the UsersFromDatabase class to use the latest version of the sqlalchemy. I don't know whether it is good approach or not. I just enjoy the learning curve(with frustration). Their documentation sucks :-(. Regards, Lythoner On Dec 17, 2007 4:28 PM, enrico secco [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi Pylons people, I'm trying to test the possibility to develop a web application in Pylons and I must handle the permission at row level of my db. I did think to use AuthKit but I'm forced to use the UsersFromDatabase mode. I did try to test the funcionality on following the tutorial relative to QuickWiki in the Authentication and Authorization (PylonsBook) but I don't be aple to pass the paster setup-app development.ini The first problem was the definition of 'meta' and 'ctx'. For meta I suppose that there was e change in QuickWiki because MetaData() is assigned to a 'metadata' variable. Then i add the line meta = metadata and for ctx insert 2 lines in QuickWiki model from pylons.database import create_engine, session_context ... ctx = session_context() I know session_context is deprecated but I find no other way. Then I stop at the same point with: [EMAIL PROTECTED]:~# paster setup-app test.ini Running setup_config() from quickwiki.websetup /usr/lib/python2.5/site-packages/QuickWiki-0.1.5-py2.5.egg /quickwiki/ model/__init__.py:10: DeprecationWarning: pylons.database is deprecated, and will be removed from a future version of Pylons. SQLAlchemy 0.3.x users are recommended to migrate to SAContext (http:// cheeseshop.python.org/pypi/SAContext http://cheeseshop.python.org/pypi/SAContext) for similar functionality from pylons.database import create_engine, session_context /usr/lib/python2.5/site-packages/Pylons- 0.9.6.1-py2.5.egg/pylons/ database.py:142: SADeprecationWarning: SessionContext is deprecated. Use
How do you specify a class for link_to links
Hi all. I need to be able to set a style for the link I'm generating. I use link_to to generate links. But, you can not use class as a keyword argument :/, so I can't set a style for the generated link. Is there a way to do this that I'm overlooking? Thanks! jw --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: How do you specify a class for link_to links
On Dec 20, 2007, at 8:51 AM, programmer.py wrote: Hi all. I need to be able to set a style for the link I'm generating. I use link_to to generate links. But, you can not use class as a keyword argument :/, so I can't set a style for the generated link. Is there a way to do this that I'm overlooking? This is covered in the FAQ: http://wiki.pylonshq.com/pages/viewpage.action?pageId=9011474 -- 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: How do you specify a class for link_to links
Thanks! In the faq, err how embarrasing I didn't look there first :/. jw On Dec 20, 11:17 am, Philip Jenvey [EMAIL PROTECTED] wrote: On Dec 20, 2007, at 8:51 AM, programmer.py wrote: Hi all. I need to be able to set a style for the link I'm generating. I use link_to to generate links. But, you can not use class as a keyword argument :/, so I can't set a style for the generated link. Is there a way to do this that I'm overlooking? This is covered in the FAQ: http://wiki.pylonshq.com/pages/viewpage.action?pageId=9011474 -- 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: AuthKit problems
Hi James, Yes. I have modified sqlalchemy_driver.py file to use SqlAlchemy 0.4. Do you have the unit tests for sqlalchemy_driver?. Please spot me the location, I would give a try. I am newbie to pylons, sqlalchemy, have little programming experience in Python itself. Whatever I have done MAY NOT be correct. I have attached the modified file, which I haven't given much review. If you give me some comments/suggestions, I love to do this migration. Sorry, It was SessionContext not SAContext. Regards, Lythoner On Dec 20, 2007 3:15 AM, James Gardner [EMAIL PROTECTED] wrote: Hi Lythoner, You've spotted the SQLAlchemy 0.4 driver have you? AuthKit has never used SAContext ever. Cheers, James Lythoner LY wrote: Enrico, AuthKit 0.4 is not updated to use the full power of sqlalchemy 0.4. I had faced a lot of issues with UsersFromDatabase class last week. SAContext is a hook they have added temporarily to help the session management and reduce number of repetitive code. Now sqlalchemy 0.4 has improved in this area. AuthKit 0.4 code is really cruft and it has to be updated in many areas require clean up. Myself I did some changes in the UsersFromDatabase class to use the latest version of the sqlalchemy. I don't know whether it is good approach or not. I just enjoy the learning curve(with frustration). Their documentation sucks :-(. Regards, Lythoner On Dec 17, 2007 4:28 PM, enrico secco [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi Pylons people, I'm trying to test the possibility to develop a web application in Pylons and I must handle the permission at row level of my db. I did think to use AuthKit but I'm forced to use the UsersFromDatabase mode. I did try to test the funcionality on following the tutorial relative to QuickWiki in the Authentication and Authorization (PylonsBook) but I don't be aple to pass the paster setup-app development.ini The first problem was the definition of 'meta' and 'ctx'. For meta I suppose that there was e change in QuickWiki because MetaData() is assigned to a 'metadata' variable. Then i add the line meta = metadata and for ctx insert 2 lines in QuickWiki model from pylons.database import create_engine, session_context ... ctx = session_context() I know session_context is deprecated but I find no other way. Then I stop at the same point with: [EMAIL PROTECTED]:~# paster setup-app test.ini Running setup_config() from quickwiki.websetup /usr/lib/python2.5/site-packages/QuickWiki-0.1.5-py2.5.egg/quickwiki/ model/__init__.py:10: DeprecationWarning: pylons.database is deprecated, and will be removed from a future version of Pylons. SQLAlchemy 0.3.x users are recommended to migrate to SAContext (http:// cheeseshop.python.org/pypi/SAContext http://cheeseshop.python.org/pypi/SAContext) for similar functionality from pylons.database import create_engine, session_context /usr/lib/python2.5/site-packages/Pylons- 0.9.6.1-py2.5.egg/pylons/ database.py:142: SADeprecationWarning: SessionContext is deprecated. Use scoped_session(). scopefunc=app_scope) Traceback (most recent call last): File /usr/bin/paster, line 8, in module load_entry_point('PasteScript==1.3.6', 'console_scripts', 'paster') () File /usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg/ paste/script/command.py, line 78, in run invoke(command, command_name, options, args[1:]) File /usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg/ paste/script/command.py, line 117, in invoke exit_code = runner.run(args) File /usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg/ paste/script/appinstall.py, line 68, in run return super(AbstractInstallCommand, self).run(new_args) File /usr/lib/python2.5/site-packages/PasteScript- 1.3.6-py2.5.egg / paste/script/command.py, line 212, in run result = self.command() File /usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg/ paste/script/appinstall.py, line 456, in command self, config_file, section, self.sysconfig_install_vars(installer)) File /usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg/ paste/script/appinstall.py, line 592, in setup_config mod.setup_config(command, filename, section, vars) File /usr/lib/python2.5/site-packages/QuickWiki-0.1.5-py2.5.egg/ quickwiki/websetup.py, line 20, in setup_config import quickwiki.model as model File /usr/lib/python2.5/site-packages/QuickWiki-0.1.5-py2.5.egg/ quickwiki/model/__init__.py, line 27, in module ctx = session_context() File /usr/lib/python2.5/site-packages/SQLAlchemy- 0.4.1-py2.5.egg/
Re: AuthKit problems
Hi Lythoner, Yes. I have modified sqlalchemy_driver.py file to use SqlAlchemy 0.4. Actually what I meant was that there is already an SQLAlchemy 0.4 driver in there: http://authkit.org/trac/browser/AuthKit/trunk/authkit/users/sqlalchemy_04_driver.py It uses some experimental middleware I wrote to wrap some of the SQLAlchemy functionality in WSGI middleware - this isn't the recommended approach in Pylons though so you might prefer to use your driver instead. Do you have the unit tests for sqlalchemy_driver?. Please spot me the location, I would give a try. Yes try here: http://authkit.org/trac/browser/AuthKit/trunk/test You run them using nose. I think the command is: nose test/test.py If Trac is temperamental when following the above links just press refresh a few times and it should work. I am newbie to pylons, sqlalchemy, have little programming experience in Python itself. Whatever I have done MAY NOT be correct. I have attached the modified file, which I haven't given much review. If you give me some comments/suggestions, I love to do this migration. Thanks for the offer, do you want to take a look at the existing version and see if it meets your needs first? The version I've linked above uses a new experimental version of the API which creates a new Users instance each time it is called. The methods each have access to the WSGI environ so in principle the new API should be a lot more flexible than the old one. We could add your version in too if you are confident it will end up stable? Sorry, It was SessionContext not SAContext. Ahh, makes more sense. Cheers, James --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: AuthKit problems
Hi Enrico, Now the it seems that the 'sqlalchemy_04_driver' have some problem with 'environ' object. Ahh, you've been caught out by the different API used by the 0.4 driver. The first argument with the new API should be the WSGI environment. I can see why this doesn't quite work in the way you were expecting. If you do want to use this driver you'll need to setup the SQLAlchemyMiddleware first like this example does: http://authkit.org/trac/browser/AuthKit/trunk/examples/user/database/app.py Note this isn't the currently recommended way of using SQLAlchemy with Pylons, it is just the one I happen to like. You might be better off with Lythoner's version perhaps if that works for you? Cheers, James --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
TG2/Pylons sprint
As some of you know TurboGears 2 will be working very closely with Pylons to create a more full stack approach to python web development on top of the same infrastructure as Pylons. Our goal is to make a version of Pylons which is as easy to get started with as Django, and even more powerful. Most of the work required to make that happen has already occurred, but there's still lots of interesting stuff to do. To that end, I'm trying to organize a world wide virtual and in person TurboGears 2 sprint on the 12th and 13th of January. Ben has already suggested a few ideas for how TG2 people can help out with some of the core pylons stuff. There are quite a few TG developers who are very new to the world of Pylons, so it would be super helpful if some folks who know pylons could participate too. And there are a few areas, where I think we ought to work together on things. Right now TG2's dispatch mechanism is entirely independent from Routes, and we don't quite know how to make totally RESTful resources drop-dead easy to create and use in TG2/pylons. I want this to be easier to do than it is in Rails, and one option would be to continue to work on making rest stuff even easier in routes. But that would also mean making TG2 more routes aware, which i think would require a tool to automatically generate Routes based on walking the object tree on the root controller object. Another area where we can work together somewhat is on the web helpers module, which could use cleanup, documentation, and some general love. Anyway, I think a lot can be done on both TG2 and Pylons, and working together we can do some really great stuff. So feel free to drop by the wiki page and add ideas of projects we should work on, or to sign up to attend the sprint. http://docs.turbogears.org/SprintOrganization -- Mark Ramm-Christensen email: mark at compoundthinking dot com blog: www.compoundthinking.com/blog --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: TG2/Pylons sprint
On Dec 20, 2007 7:20 PM, Mark Ramm [EMAIL PROTECTED] wrote: I'm trying to organize a world wide virtual and in person TurboGears 2 sprint on the 12th and 13th of January. That sounds cool. I put Seattle on the list for Saturday; we have an informal sprint-or-whatever every week and can probably drum up a few people. I haven't used TG for two years so own my memory is vague, but I'll be happy to do cross-framework stuff or be a Pylons advisor. Please cc announcements here, because I don't know how long I can handle another large mailing list like TG undoubtedly is. -- Mike Orr [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---