Re: Sub-domain with Routes crush nosetests
Haven't anyone experienced anything like this? On May 7, 5:49 pm, Pavel Skvazh [EMAIL PROTECTED] wrote: Has anyone experienced problems with running nosetests on contoller, that is routed to the sub-domain? Here's what I've got controller/test.py class TestController(BaseController): def get(self): return True routing.py Out of the box map.connect(':controller/:action/:id') map.connect(':action/:id', controller='main') map.connect('*url', controller='template', action='view') class TestController(TestController): def test_get(self): response = self.app.get(url_for(controller='test', action='get')) r = response.body assert_true(r) This works just fine. What do i change map.connect(':controller/:action/:id', conditions=dict(sub_domain=['my'])) map.connect(':action/:id', controller='main', conditions=dict(sub_domain=['my'])) map.connect('*url', controller='template', action='view') I change in routing map.sub_domains = True map.sub_domains_ignore = ['www'] map.connect(':controller/:action/:id', conditions=dict(sub_domain=['my'])) map.connect(':action/:id', controller='main', conditions=dict(sub_domain=['my'])) map.connect('*url', controller='template', action='view') And then no matter what i do in test class TestController(TestController): def test_get(self): response = self.app.get(url_for(controller='test', action='get', sub_domain='my')) r = response.body assert_true(r) Here's what i get Traceback (most recent call last): File \tests\functional\test.py, line 10 , in setUp self.login('storos', 'explore') File \tests\functional\test.py, line 16 , in login response = self.app.post(url_for(controller='test', action='get', sub_dom ain='my'), File D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes \util.py, line 205, in url_for newargs = _screenargs(kargs) File D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes \util.py, line 55, in _screenargs memory_kargs = _subdomain_check(config, memory_kargs) File D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes \util.py, line 66, in _subdomain_check fullhost = config.environ.get('HTTP_HOST') or \ File D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes \__init__.py, line 14, in __getattr__ return getattr(self.__shared_state, name) AttributeError: 'thread._local' object has no attribute 'environ' I cann't really figure what's going on here. return h.url_for(controller='tests', action='get', sub_domain='my') returns a perfectly legal url, so i cann't really see why test cann't see it 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
get_lang/set_lang why the different signature?
Hi, I'm a bit confused as to why this is implemented like it is. set_lang is a string which inside pylons (_get_translator in translation.py) is converted to a list to make python's gettext happy. but then it's stored as a list in translator.pylons_lang which is retrieved by get_lang. not only this is misleading but it's wrong as with the current code it's not possible to have more than one lang anyway, unless you monkey patch translation.py or am I missing something? --~--~-~--~~~---~--~~ 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: Running Pylons with PHP
Noah Gift escreveu: Wow, [http://pythonpaste.org/wphp/] is cool, I forget Ian did that. You can also proxy to different servers and mounting them on different URLs. signature.asc Description: OpenPGP digital signature
Re: Running Pylons with PHP
Hi, This is a really interesting module - does anyone know what sort of overheads it has? I can see this as being quite useful for migrating legacy php code to a pylons app allowing you to reuse some existing php code in an updated pylons app, either for transitioning it or using a mix of the two that integrates cleanly. Damian On May 13, 2:40 am, Humberto Diogenes [EMAIL PROTECTED] wrote: On 12/05/2008, at 18:59, Jorge Vargas wrote: On Mon, May 12, 2008 at 4:43 PM, Syp [EMAIL PROTECTED] wrote: Hello -- Does anyone know if it's possible to run Pylons and PHP together on the same port? huh? unless you configure your apache to serve both py and php and mess around with everyrequest to see who is handling what no. I'll suggest you just run on different subdomains. for example I got www.example.comwith my pylons app and stats.example.com with my analitics tool. I would recommend the subdomain approach, too. But if you really want the first option, you can play with WPHP:http://pythonpaste.org/wphp/ -- Humberto Diógeneshttp://humberto.digi.com.br --~--~-~--~~~---~--~~ 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: Sub-domain with Routes crush nosetests
It's hard to understand what might be going on here but my only guess is that your app-setup code to populate the thread local config object is not getting run at the right time. This is tricky to get right in nose because often times parts of your app want to access config *before* it can be imported. What nose does is import just about everything in your package before it runs the tests. If your test setup is done like the pylons docs suggest, that is, at the module level of test/__init__.py -- not within setup() -- then try this and see if it helps: nosetests --where=yourapp/tests that will change dir to yourapp/tests (adjust the path as necessary) and will only import from the tests directory. However you will have to ensure that each test module says from yourapp import tests at the top so the setup code gets run. Double check that. If that still doesn't work you'd have to revert back to a version of your app where tests run OK then compare the differences. You might want to run nosetests --debug=nose.importer,nose.selector to help compare the differences in test execution. On Wed, May 7, 2008 at 8:49 AM, Pavel Skvazh [EMAIL PROTECTED] wrote: Has anyone experienced problems with running nosetests on contoller, that is routed to the sub-domain? Here's what I've got controller/test.py class TestController(BaseController): def get(self): return True routing.py Out of the box map.connect(':controller/:action/:id') map.connect(':action/:id', controller='main') map.connect('*url', controller='template', action='view') class TestController(TestController): def test_get(self): response = self.app.get(url_for(controller='test', action='get')) r = response.body assert_true(r) This works just fine. What do i change map.connect(':controller/:action/:id', conditions=dict(sub_domain=['my'])) map.connect(':action/:id', controller='main', conditions=dict(sub_domain=['my'])) map.connect('*url', controller='template', action='view') I change in routing map.sub_domains = True map.sub_domains_ignore = ['www'] map.connect(':controller/:action/:id', conditions=dict(sub_domain=['my'])) map.connect(':action/:id', controller='main', conditions=dict(sub_domain=['my'])) map.connect('*url', controller='template', action='view') And then no matter what i do in test class TestController(TestController): def test_get(self): response = self.app.get(url_for(controller='test', action='get', sub_domain='my')) r = response.body assert_true(r) Here's what i get Traceback (most recent call last): File \tests\functional\test.py, line 10 , in setUp self.login('storos', 'explore') File \tests\functional\test.py, line 16 , in login response = self.app.post(url_for(controller='test', action='get', sub_dom ain='my'), File D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes \util.py, line 205, in url_for newargs = _screenargs(kargs) File D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes \util.py, line 55, in _screenargs memory_kargs = _subdomain_check(config, memory_kargs) File D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes \util.py, line 66, in _subdomain_check fullhost = config.environ.get('HTTP_HOST') or \ File D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes \__init__.py, line 14, in __getattr__ return getattr(self.__shared_state, name) AttributeError: 'thread._local' object has no attribute 'environ' I cann't really figure what's going on here. return h.url_for(controller='tests', action='get', sub_domain='my') returns a perfectly legal url, so i cann't really see why test cann't see it 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: sys.path
[EMAIL PROTECTED] wrote: Hi all, is there a possibility to modify sys.path each time a request is processed (i.e. just before pylons is started)? You could, but it probably won't work like you want. If a module is already loaded it will not be reloaded, despite changes to sys.path. I'm not sure what you are trying to do, but maybe something like exec will work better (i.e., something that doesn't use the import machinery at all). -- Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org --~--~-~--~~~---~--~~ 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: Running Pylons with PHP
Damian wrote: This is a really interesting module - does anyone know what sort of overheads it has? I can see this as being quite useful for migrating legacy php code to a pylons app allowing you to reuse some existing php code in an updated pylons app, either for transitioning it or using a mix of the two that integrates cleanly. We don't use it in production, but instead have a complete Apache instance to run a PHP app (WordPress) and use WSGI-based HTTP proxying from Python. But the basic effect is the same, wphp just uses FastCGI proxying instead of HTTP. The overhead hasn't seemed that substantial, though passing static files through Python can add some unnecessary overhead, including stuff like taking up one of a limited number of worker threads. The actual overhead of running the PHP scripts (especially something complex) will usually be much more than the proxying overhead. Incidentally, there's also a similar setup for running CGI scripts, which you can use to run, for example, Mailman. You get all the normal CGI overhead in this case, but again that's probably less than the overhead of a Python intermediary. -- Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Routes (1.8) quote_plus issue?
Hi (Ben, Mike :), First of all, excuse me for not digging into the issue deeply enough myself (will do that when I reach home.) Routes 1.8 takes a href=/one+%2B+oneone + one/a and passes to my controller the undesirable id u'one+++one' I did notice from a quick grep through my site-packages/ that there are only a few quote_plus with no unquote_plus -- ~/lib/python2.5/site-packages$ grep --include=*.py -r quote_plus . | egrep -i paste|pylons|routes ./Routes-1.8-py2.5.egg/routes/util.py:A Unicode handling version of urllib.quote_plus. ./Routes-1.8-py2.5.egg/routes/util.py:return urllib.quote_plus(s, '/') ./Routes-1.8-py2.5.egg/routes/util.py: urllib.quote_plus(unicode(key).encode(encoding)), ./Routes-1.8-py2.5.egg/routes/util.py: urllib.quote_plus(unicode(value).encode(encoding ./Routes-1.8-py2.5.egg/routes/util.py: urllib.quote_plus(unicode(key).encode(encoding)), ./Routes-1.8-py2.5.egg/routes/util.py: urllib.quote_plus(unicode(val).encode(encoding Could that be a (known) Routes bug? Many 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Running Pylons with PHP
Thanks for everyone's suggestions! I'll start with the sub-domain approach. On May 13, 1:11 pm, Ian Bicking [EMAIL PROTECTED] wrote: Damian wrote: This is a really interesting module - does anyone know what sort of overheads it has? I can see this as being quite useful for migrating legacy php code to a pylons app allowing you to reuse some existing php code in an updated pylons app, either for transitioning it or using a mix of the two that integrates cleanly. We don't use it in production, but instead have a complete Apache instance to run a PHP app (WordPress) and use WSGI-based HTTP proxying from Python. But the basic effect is the same, wphp just uses FastCGI proxying instead of HTTP. The overhead hasn't seemed that substantial, though passing static files through Python can add some unnecessary overhead, including stuff like taking up one of a limited number of worker threads. The actual overhead of running the PHP scripts (especially something complex) will usually be much more than the proxying overhead. Incidentally, there's also a similar setup for running CGI scripts, which you can use to run, for example, Mailman. You get all the normal CGI overhead in this case, but again that's probably less than the overhead of a Python intermediary. -- Ian Bicking : [EMAIL PROTECTED] :http://blog.ianbicking.org --~--~-~--~~~---~--~~ 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: Routes (1.8) quote_plus issue?
On May 13, 2008, at 3:28 PM, jerry wrote: First of all, excuse me for not digging into the issue deeply enough myself (will do that when I reach home.) Routes 1.8 takes a href=/one+%2B+oneone + one/a and passes to my controller the undesirable id u'one+++one' Generally, web servers will decode %2B before Routes even sees it. So quite likely, Routes sees /one+++one, and has no idea there was originally a %2B in there at all. This has been brought up before and there's nothing really that can be done about the fact that Routes will see the URL *after* its been decoded. Cheers, Ben smime.p7s Description: S/MIME cryptographic signature
Re: mako marco? webhelpers plugin?
On Tue, May 13, 2008 at 6:07 PM, lasizoillo [EMAIL PROTECTED] wrote: Hi 2008/5/11 [EMAIL PROTECTED]: i am new to pylons and found the webhelpers are quite handy. i need to program on other javascript lib(dhtml calendar) which is not include in webhelpers. if i want to make something reusable other than hardcode the js everytime, i can think of marco of the template system or extend the webhelpers myself. can anyone please show me some lights? any example or sample available? The problem is enterely in presentation layer. Why not resolve it in this layer. I believe this is true, although for this matter I'll prefer the webhelpers approach as it's template agnostic. That said the only advantage either of them is to centralize JS calls because as Christoph said you just can't make JQuery calls smaller. http://www.makotemplates.org/docs/defs.html#defs_remotedefs You can write your custom mako library for write your things (form elements whith tooltips, microformats, ...). But maybe a better option make your own jquery plugin. It's a great thing to reuse js code ;-) agreed there too. Excuse my poor english Reggards Javi --~--~-~--~~~---~--~~ 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: get_lang/set_lang why the different signature?
On May 13, 2008, at 3:03 AM, Jorge Vargas wrote: set_lang is a string which inside pylons (_get_translator in translation.py) is converted to a list to make python's gettext happy. but then it's stored as a list in translator.pylons_lang which is retrieved by get_lang. not only this is misleading but it's wrong as with the current code it's not possible to have more than one lang anyway, unless you monkey patch translation.py set_lang should also be able to take a list as well. There's also an add_fallback function in pylons.i18n to add another language after the fact. -- 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: Routes (1.8) quote_plus issue?
Hi Ben, I recently posted this message: http://groups.google.com/group/pylons-discuss/msg/fa8507fbb7ea6173 I think the issue is webhelper uses quote_plus to encode url while Paste uses unquote to decode url. So 1 + 1 gets encoded to 1+%2b+1 and it gets decoded to 1+++1. Is there any particular reason Paste doesn't use unquote_plus? Thanks! --Michi On May 13, 4:13 pm, Ben Bangert [EMAIL PROTECTED] wrote: On May 13, 2008, at 3:28 PM, jerry wrote: First of all, excuse me for not digging into the issue deeply enough myself (will do that when I reach home.) Routes 1.8 takes a href=/one+%2B+oneone + one/a and passes to my controller the undesirable id u'one+++one' Generally, web servers will decode %2B before Routes even sees it. So quite likely, Routes sees /one+++one, and has no idea there was originally a %2B in there at all. This has been brought up before and there's nothing really that can be done about the fact that Routes will see the URL *after* its been decoded. Cheers, Ben smime.p7s 3KDownload --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---