Re: url_for() constrcut URL with MultiDict parameters?
On Mon, Apr 28, 2008 at 10:38 PM, Jonathan Vanasco [EMAIL PROTECTED] wrote: On Apr 29, 12:38 am, Mike Orr [EMAIL PROTECTED] wrote: On Mon, Apr 28, 2008 at 6:19 PM, jerry [EMAIL PROTECTED] wrote: Is there a way to construct URLs like /controller/action/id? q=1q=2 with url_for()? I don't think so. If there's demand for this we can turn a list of values into multiple parameters. Does MultiDict offer anything that would help with this? i have a function in helpers, my_url_for , which wraps url_for and does some misc stuff depending on context. an approach like that might help you get your task done. What else does it do? -- 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 -~--~~~~--~~--~--~---
pylons, unicode and german umlauts in urls
Hi, I have already reached a dead end, although I am still at the beginning of my project. Perhaps somebody can help me out of this mess: I am trying to write a tool to browse data in databases. Unfortunately the database I am working with is a ms-sql database which has german umlauts in its table- and cloumn names. When reflecting tables from this database I have to overwrite the columnames with ascii-names to allow sqlalchemy to map the tables to classes. sqlalchemy.convert_unicode is true and sqlalchemy.encoding is set to cp1252. So far so good. Now I want to display my tables in a generic way: [Controller] c.table=table column = request.GET.get('column') c.columns = meta.metadata.tables.get(table).c c.items = meta.metadata.tables.get(table).select().order_by(column).limit(10).execute() return render('/databrowse/table.html') [View] table tr % for column in c.columns: th a href=${h.url_for(controller=databrowse, action=table, table=c.table, column=column.name)}${column.name}/a /th % endfor /tr % for item in c.items: tr % for column in c.columns: td${item[column.name]}/td % endfor /tr % endfor /table but routes produces some unicode error when calling h.url_for(controller=databrowse, action=table, table=c.table, column=column.name in the template: File 'c:\\TTL\\ttl\\controllers\\databrowse.py', line 29 in table return render('/databrowse/table.html') File 'c:\\python25\\lib\\site-packages\\pylons-0.9.6.1-py2.5.egg\ \pylons\\templating.py', line 343 in render format=format, namespace=kargs, **cache_args) File 'c:\\python25\\lib\\site-packages\\pylons-0.9.6.1-py2.5.egg\ \pylons\\templating.py', line 228 in render **options) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\\ext \\turbogears.py', line 49 in render return template.render(**info) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \template.py', line 114 in render return runtime._render(self, self.callable_, args, data) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \runtime.py', line 287 in _render _render_context(template, callable_, context, *args, **_kwargs_for_callable(callable_, data)) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \runtime.py', line 304 in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \runtime.py', line 337 in _exec_template callable_(context, *args, **kwargs) File 'c:\\TTL\\data\\templates\\databrowse\\site.html.py', line 26 in render_body context.write(unicode(self.body())) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \runtime.py', line 193 in lambda return lambda *args, **kwargs:callable_(self.context, *args, **kwargs) File 'c:\\TTL\\data\\templates\\databrowse\\table.html.py', line 38 in render_body context.write(unicode(h.url_for(controller=databrowse, action=table, table=c.table, column=column.name))) File 'c:\\python25\\lib\\site-packages\\routes-1.7.1-py2.5.egg\\routes\ \util.py', line 189 in url_for url = config.mapper.generate(*route_args, **newargs) File 'c:\\python25\\lib\\site-packages\\routes-1.7.1-py2.5.egg\\routes\ \base.py', line 949 in generate path = route.generate(**kargs) File 'c:\\python25\\lib\\site-packages\\routes-1.7.1-py2.5.egg\\routes\ \base.py', line 544 in generate (key != 'action' or key != 'controller')]) File 'C:\\Python25\\lib\\urllib.py', line 1250 in urlencode v = quote_plus(str(v)) UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 6: ordinal not in range(128) Can anybody explain me what I am doing wrong? Thanks in advance! --~--~-~--~~~---~--~~ 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: pylons, unicode and german umlauts in urls
Hi, Saibot wrote: v = quote_plus(str(v)) UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 6: ordinal not in range(128) Can anybody explain me what I am doing wrong? Wrong encoding. \xdf is from cp125x or similar encoding. Try following: v.decode('cp1250') or v.decode('cp1250').encode('utf-8') HTH, Dalius --~--~-~--~~~---~--~~ 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: is there a good way to stash a global var, that doesn't use g/app_globals
Previously Contact 42 wrote: what's wrong with a normal python module. Thread safety. Wichert. -- Wichert Akkerman [EMAIL PROTECTED]It is simple to make things. http://www.wiggy.net/ It is hard to make things simple. --~--~-~--~~~---~--~~ 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: is there a good way to stash a global var, that doesn't use g/app_globals
Wichert Akkerman wrote: Previously Contact 42 wrote: what's wrong with a normal python module. Thread safety. Wichert true, but for config stuff that never changes i.e constants, I don't see a problem. Huy --~--~-~--~~~---~--~~ 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: is there a good way to stash a global var, that doesn't use g/app_globals
because i won't know the name of appconfig.py i'm creating a subclassable framework for distribution DerivedApp/ DerivedApp/model BaseApp/ BaseApp/lib/helpers I'm trying to get the BaseApp/lib/helpers to access Globals, so that it can access objects in DerivedApp/model (which might have overrides) --~--~-~--~~~---~--~~ 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: pylons, unicode and german umlauts in urls
On Tue, Apr 29, 2008 at 1:56 AM, Saibot [EMAIL PROTECTED] wrote: Hi, I have already reached a dead end, although I am still at the beginning of my project. Perhaps somebody can help me out of this mess: I am trying to write a tool to browse data in databases. Unfortunately the database I am working with is a ms-sql database which has german umlauts in its table- and cloumn names. When reflecting tables from this database I have to overwrite the columnames with ascii-names to allow sqlalchemy to map the tables to classes. sqlalchemy.convert_unicode is true and sqlalchemy.encoding is set to cp1252. So far so good. Now I want to display my tables in a generic way: [Controller] c.table=table column = request.GET.get('column') c.columns = meta.metadata.tables.get(table).c c.items = meta.metadata.tables.get(table).select().order_by(column).limit(10).execute() return render('/databrowse/table.html') [View] table tr % for column in c.columns: th a href=${h.url_for(controller=databrowse, action=table, table=c.table, column=column.name)}${column.name}/a right here, you need: ${h.url_for(... table=c.table.encode('cp1252'), column=column.name.encode('cp1252'))} because Routes is not expecting query string parameters to be Unicode. Should it? I'm not sure, but sqlalchemy is doing the right thing, it has converted those values to Unicode for you already. for a broader explanation of the magic Python is doing behind the scenes that caused your error, this may help: http://farmdev.com/talks/unicode/ /th % endfor /tr % for item in c.items: tr % for column in c.columns: td${item[column.name]}/td % endfor /tr % endfor /table but routes produces some unicode error when calling h.url_for(controller=databrowse, action=table, table=c.table, column=column.name in the template: File 'c:\\TTL\\ttl\\controllers\\databrowse.py', line 29 in table return render('/databrowse/table.html') File 'c:\\python25\\lib\\site-packages\\pylons-0.9.6.1-py2.5.egg\ \pylons\\templating.py', line 343 in render format=format, namespace=kargs, **cache_args) File 'c:\\python25\\lib\\site-packages\\pylons-0.9.6.1-py2.5.egg\ \pylons\\templating.py', line 228 in render **options) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\\ext \\turbogears.py', line 49 in render return template.render(**info) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \template.py', line 114 in render return runtime._render(self, self.callable_, args, data) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \runtime.py', line 287 in _render _render_context(template, callable_, context, *args, **_kwargs_for_callable(callable_, data)) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \runtime.py', line 304 in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \runtime.py', line 337 in _exec_template callable_(context, *args, **kwargs) File 'c:\\TTL\\data\\templates\\databrowse\\site.html.py', line 26 in render_body context.write(unicode(self.body())) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \runtime.py', line 193 in lambda return lambda *args, **kwargs:callable_(self.context, *args, **kwargs) File 'c:\\TTL\\data\\templates\\databrowse\\table.html.py', line 38 in render_body context.write(unicode(h.url_for(controller=databrowse, action=table, table=c.table, column=column.name))) File 'c:\\python25\\lib\\site-packages\\routes-1.7.1-py2.5.egg\\routes\ \util.py', line 189 in url_for url = config.mapper.generate(*route_args, **newargs) File 'c:\\python25\\lib\\site-packages\\routes-1.7.1-py2.5.egg\\routes\ \base.py', line 949 in generate path = route.generate(**kargs) File 'c:\\python25\\lib\\site-packages\\routes-1.7.1-py2.5.egg\\routes\ \base.py', line 544 in generate (key != 'action' or key != 'controller')]) File 'C:\\Python25\\lib\\urllib.py', line 1250 in urlencode v = quote_plus(str(v)) UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 6: ordinal not in range(128) Can anybody explain me what I am doing wrong? Thanks in advance! --~--~-~--~~~---~--~~ 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: url_for() constrcut URL with MultiDict parameters?
Hi Mike, Thanks for the response. I mentioned MultiDict as a convenient term to convey the idea in my question, not that I know or thought it would help with the implementation. As for the demand, I have a form with a list of checkbox input items for viewing the details of selected one(s). The receiving controller will naturally have multi-parameter URL like /details?q=1q=2 . Now I want to further enable adding more items in the details viewing list and need to have another form with probably hidden input items q=1 and q=2, finally when paging is involved for this form, the pager links will have to inherit the information of the existing parameters q=1q=2, hence the demand. However, it really doesn't seem to be an appealing design and I think I'm probably better off sticking with the more RESTful URL like details/1;2 Cheers, Jerry On Apr 29, 12:38 am, Mike Orr [EMAIL PROTECTED] wrote: On Mon, Apr 28, 2008 at 6:19 PM, jerry [EMAIL PROTECTED] wrote: Is there a way to construct URLs like /controller/action/id? q=1q=2 with url_for()? I don't think so. If there's demand for this we can turn a list of values into multiple parameters. Does MultiDict offer anything that would help with this? -- 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 -~--~~~~--~~--~--~---
Re: pylons, unicode and german umlauts in urls
Sorry for bothering you with this crap. I have just upgraded to routes 1.8 and everything works fine now. Thank you none the less. On 29 Apr., 08:56, Saibot [EMAIL PROTECTED] wrote: Hi, I have already reached a dead end, although I am still at the beginning of my project. Perhaps somebody can help me out of this mess: I am trying to write a tool to browse data in databases. Unfortunately the database I am working with is a ms-sql database which has german umlauts in its table- and cloumn names. When reflecting tables from this database I have to overwrite the columnames with ascii-names to allow sqlalchemy to map the tables to classes. sqlalchemy.convert_unicode is true and sqlalchemy.encoding is set to cp1252. So far so good. Now I want to display my tables in a generic way: [Controller] c.table=table column = request.GET.get('column') c.columns = meta.metadata.tables.get(table).c c.items = meta.metadata.tables.get(table).select().order_by(column).limit(10).execute() return render('/databrowse/table.html') [View] table tr % for column in c.columns: th a href=${h.url_for(controller=databrowse, action=table, table=c.table, column=column.name)}${column.name}/a /th % endfor /tr % for item in c.items: tr % for column in c.columns: td${item[column.name]}/td % endfor /tr % endfor /table but routes produces some unicode error when calling h.url_for(controller=databrowse, action=table, table=c.table, column=column.name in the template: File 'c:\\TTL\\ttl\\controllers\\databrowse.py', line 29 in table return render('/databrowse/table.html') File 'c:\\python25\\lib\\site-packages\\pylons-0.9.6.1-py2.5.egg\ \pylons\\templating.py', line 343 in render format=format, namespace=kargs, **cache_args) File 'c:\\python25\\lib\\site-packages\\pylons-0.9.6.1-py2.5.egg\ \pylons\\templating.py', line 228 in render **options) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\\ext \\turbogears.py', line 49 in render return template.render(**info) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \template.py', line 114 in render return runtime._render(self, self.callable_, args, data) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \runtime.py', line 287 in _render _render_context(template, callable_, context, *args, **_kwargs_for_callable(callable_, data)) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \runtime.py', line 304 in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \runtime.py', line 337 in _exec_template callable_(context, *args, **kwargs) File 'c:\\TTL\\data\\templates\\databrowse\\site.html.py', line 26 in render_body context.write(unicode(self.body())) File 'c:\\python25\\lib\\site-packages\\mako-0.1.8-py2.5.egg\\mako\ \runtime.py', line 193 in lambda return lambda *args, **kwargs:callable_(self.context, *args, **kwargs) File 'c:\\TTL\\data\\templates\\databrowse\\table.html.py', line 38 in render_body context.write(unicode(h.url_for(controller=databrowse, action=table, table=c.table, column=column.name))) File 'c:\\python25\\lib\\site-packages\\routes-1.7.1-py2.5.egg\\routes\ \util.py', line 189 in url_for url = config.mapper.generate(*route_args, **newargs) File 'c:\\python25\\lib\\site-packages\\routes-1.7.1-py2.5.egg\\routes\ \base.py', line 949 in generate path = route.generate(**kargs) File 'c:\\python25\\lib\\site-packages\\routes-1.7.1-py2.5.egg\\routes\ \base.py', line 544 in generate (key != 'action' or key != 'controller')]) File 'C:\\Python25\\lib\\urllib.py', line 1250 in urlencode v = quote_plus(str(v)) UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 6: ordinal not in range(128) Can anybody explain me what I am doing wrong? Thanks in advance! --~--~-~--~~~---~--~~ 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: pylons, unicode and german umlauts in urls
After upgrading to routes 1.8, everything works as it should! Thank you! On 29 Apr., 11:26, Dalius Dobravolskas [EMAIL PROTECTED] wrote: Hi, Saibot wrote: v = quote_plus(str(v)) UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 6: ordinal not in range(128) Can anybody explain me what I am doing wrong? Wrong encoding. \xdf is from cp125x or similar encoding. Try following: v.decode('cp1250') or v.decode('cp1250').encode('utf-8') HTH, Dalius --~--~-~--~~~---~--~~ 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: Paginate module
Hi, I am using paginate and have some problems with it. Thats my controller code: items = meta.metadata.tables.get(table).select().order_by(column) c.page = paginate.Page(items, sqlalchemy_session=meta.Session, current_page=current_page) return render('/databrowse/table.html') executing this an error occurs: File 'c:\\TTL\\ttl\\controllers\\databrowse.py', line 22 in table c.page = paginate.Page(items, sqlalchemy_session=meta.Session, current_page=current_page) File 'C:\\Python25\\lib\\site-packages\\paginate-0.3.2-py2.5.egg\ \paginate\\__init__.py', line 251 in __init__ self.item_count = len(self.collection) ValueError: __len__() should return = 0 this happens, when calulating the length of the _SQLAlechemySelect Collection: def __len__(self): return self.sqlalchemy_session.execute(self.obj).rowcount which returns -1. What am I doing wrong? Thanks in advance! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
AW: Re: Crash after coockie expired
Today I have massive troubles with the crashes. Nearly every 5m. It's not the same error as Jonathan experiences (object has no attribute...). The error is raised from the cPickle class: ValueError: could not convert string to float Since I don't have any floats in my classes I would guess this happens inside Beaker. I did some digging and played around with pickle instead of cPickle inside the Python shell: x = pickle.load(fh) Traceback (most recent call last): File stdin, line 1, in ? File C:\Panda3D-1.3.2\python\lib\pickle.py, line 1390, in load return Unpickler(file).load() File C:\Panda3D-1.3.2\python\lib\pickle.py, line 872, in load dispatch[key](self) File C:\Panda3D-1.3.2\python\lib\pickle.py, line 968, in load_float self.append(float(self.readline()[:-1])) ValueError: invalid literal for float(): 1209482697,7030001 Ahh so we seem to have a , instead of a Let's have a look where the culprit sits - excerpt from the .cache file: '_accessed_time' 1209482697,7030001 Hmmm wondering - Beaker just pickles the float - it must be somehow a bug inside cPickle... why does cPickle write floats with ,??? Digging further... , is the German version for . in US... so it may be connected with LOCALE... And yes, it is If LOCALE is set to Germany cPickle writes , instead of . (I tried it out...). What happened? Since I need the German locale for my figures I set the locale accordingly - somewhere in my software. cPickle writes the _session_time float with , after session.save(). I restart the server - the LOCALE is not set - Beaker tries to read the file and crashes because the float is wrongly formatted... ARG... Does it make sense that cPickle uses the LOCALE settings? - I don't know (and don't care)... Andrew --~--~-~--~~~---~--~~ 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: url_for() constrcut URL with MultiDict parameters?
jerry wrote: Hi Mike, Thanks for the response. I mentioned MultiDict as a convenient term to convey the idea in my question, not that I know or thought it would help with the implementation. As for the demand, I have a form with a list of checkbox input items for viewing the details of selected one(s). The receiving controller will naturally have multi-parameter URL like /details?q=1q=2 . Now I want to further enable adding more items in the details viewing list and need to have another form with probably hidden input items q=1 and q=2, finally when paging is involved for this form, the pager links will have to inherit the information of the existing parameters q=1q=2, hence the demand. I'm not 100% clear on what you want to do, but probably {'q': ['1', '2']} will get this for you. You can get a dictionary like this from a MultiDict with req.POST.mixed(). -- 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: is there a good way to stash a global var, that doesn't use g/app_globals
Jonathan Vanasco wrote: I need to run an import like such: model = getattr(__import__(g.APPNAME, {}, {}, ['']), 'model') the problem is that I get a bunch of errors like this: TypeError: No object (name: G) has been registered for this thread because of the import order can anyone suggest a good way to handle stashing the APPNAME for an import of this type? Use g but make sure it is accessed in this way after load_environment is called. Alberto --~--~-~--~~~---~--~~ 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: is there a good way to stash a global var, that doesn't use g/app_globals
Jonathan Vanasco wrote: because i won't know the name of appconfig.py i'm creating a subclassable framework for distribution DerivedApp/ DerivedApp/model BaseApp/ BaseApp/lib/helpers I'm trying to get the BaseApp/lib/helpers to access Globals, so that it can access objects in DerivedApp/model (which might have overrides) You'll need to use a function to get the variable from g. The only way to import things like that is if you use another proxy (the pylons.g and pylons.request objects are proxies), and that's really not worth it. Or, you might be able to do something with subclassing, e.g., have your model subclass by DerivedApp. In the case of helpers, of course, it's pretty easy: just have lib.helpers in DerivedApp do from baseapp.lib.helpers import *. No need to get too fancy there. That is, you might generally find things to be easier if you simply phrase BaseApp as a library and not anything more fancy. You could make the library itself mostly a class, and have the class instantiated by DerivedApp with whatever customizations it needs. -- 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: None option for options_for_select_* helpers
actually, i like the notion of options_for_select supporting a none option i'd like to see that supported at some time. --~--~-~--~~~---~--~~ 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: is there a good way to stash a global var, that doesn't use g/app_globals
my DerivedApp/model is a subclass of BaseApp/model , etc etc i've got helpers working as you suggested too the issue i was hitting, is that in the BaseApp/helpers i'm trying to create a function that interacts with DerivedApp/Model i got around it by just passing in model, this will work for now... i'll need to spend some time working this out before i make BaseApp a public project --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Extra / normalization
Hello Pyloneers, I try to implement a gdata like category search in my app but I have a hard time embedding an url inside the url and getting it back unmangled. Here is how I want to express search for an item that is also a bar with type 42 but not a foo number 1: http://xmpl.com/items/-/{http://xmpl.com/bar}42/-{http://xmpl.com/foo}/1 In other words, I map Atom categories to {scheme}term This is all mostly working except that some part of Pylons converts all occurences of // to /. This is probably not routes since I do get the extra slashes when I call match() directly: In [5]: import routes In [6]: m = routes.Mapper() In [7]: m.connect(/foo/*url, controller=bar, action=asd) In [8]: m.match(/foo/qwe///qwe/qux1) Out[8]: {'action': u'asd', 'controller': u'bar', 'url': u'qwe///qwe/qux1'} Passing the slashes as %2f do not help: it seems that the stripping occurs after the URL decoding. Does anyone know where this stripping occurs and if it's possible to selectively disable it? -- Yannick Gingras --~--~-~--~~~---~--~~ 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: AW: Re: Crash after coockie expired
On Apr 29, 2008, at 9:18 AM, Andrew Smart wrote: Digging further... , is the German version for . in US... so it may be connected with LOCALE... And yes, it is If LOCALE is set to Germany cPickle writes , instead of . (I tried it out...). What happened? Since I need the German locale for my figures I set the locale accordingly - somewhere in my software. cPickle writes the _session_time float with , after session.save(). I restart the server - the LOCALE is not set - Beaker tries to read the file and crashes because the float is wrongly formatted... ARG... Does it make sense that cPickle uses the LOCALE settings? - I don't know (and don't care)... That's the most bizarre thing I've seen. And apparently it isn't using the LOCALE when loading, or was that not set yet? This apparently is a known bug as of 2 years ago: http://mail.python.org/pipermail/python-bugs-list/2006-April/033125.html There appears to be a PEP related: http://www.python.org/dev/peps/pep-0331/ Not sure whether they've actually fixed it, what version of Python are you using? Cheers, Ben smime.p7s Description: S/MIME cryptographic signature
Re: pylons, unicode and german umlauts in urls
On Apr 29, 2008, at 6:55 AM, Saibot wrote: After upgrading to routes 1.8, everything works as it should! Thank you! Also note that the mapper (defined in routing.py) can have its encoding set should you not be using the 'utf-8' charset that it defaults to. map.encoding = 'cp1250' Will set the default encoding/decoding system to use when handling the conversion to/from raw strings and Python unicode objects. Cheers, Ben smime.p7s Description: S/MIME cryptographic signature
Re: url_for() constrcut URL with MultiDict parameters?
On Tue, Apr 29, 2008 at 9:44 AM, Ian Bicking [EMAIL PROTECTED] wrote: jerry wrote: Hi Mike, Thanks for the response. I mentioned MultiDict as a convenient term to convey the idea in my question, not that I know or thought it would help with the implementation. As for the demand, I have a form with a list of checkbox input items for viewing the details of selected one(s). The receiving controller will naturally have multi-parameter URL like /details?q=1q=2 . Now I want to further enable adding more items in the details viewing list and need to have another form with probably hidden input items q=1 and q=2, finally when paging is involved for this form, the pager links will have to inherit the information of the existing parameters q=1q=2, hence the demand. I'm not 100% clear on what you want to do, but probably {'q': ['1', '2']} will get this for you. You can get a dictionary like this from a MultiDict with req.POST.mixed(). Added to the Routes 2 spec for consideration. (No promises yet.) http://wiki.pylonshq.com/display/routes/Routes+2+Spec Ben might implement it in Routes 1; I don't deal with that. You can increase the chances of getting it done by filing a bug report at routes.groovie.org. On second thought, I don't think MultiDict will help because these are keyword args passed by the user, so they'll come in an ordinary dict. -- 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 -~--~~~~--~~--~--~---
Re: url_for() constrcut URL with MultiDict parameters?
Mike Orr wrote: Added to the Routes 2 spec for consideration. (No promises yet.) http://wiki.pylonshq.com/display/routes/Routes+2+Spec Ben might implement it in Routes 1; I don't deal with that. You can increase the chances of getting it done by filing a bug report at routes.groovie.org. On second thought, I don't think MultiDict will help because these are keyword args passed by the user, so they'll come in an ordinary dict. Correct, but **request.POST.mixed() should work okay. -- 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: Extra / normalization
On Apr 29, 2008, at 12:29 PM, Yannick Gingras wrote: Passing the slashes as %2f do not help: it seems that the stripping occurs after the URL decoding. Does anyone know where this stripping occurs and if it's possible to selectively disable it? Unfortunately you can't disable it, WSGI servers must decode the URL's path portion before passing it to WSGI apps. Either an RFC or the CGI spec (which WSGI 1 stays compatible with) mandates this, I can't recall which -- Ben Bangert or Ian Bicking might remember. All you can do is include that value as parameter instead, or use WSGI 2 (which of course doesn't exist yet, but somewhere we've penned this 'feature' to be removed in version 2 of the spec). -- 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: Extra / normalization
Philip Jenvey wrote: Passing the slashes as %2f do not help: it seems that the stripping occurs after the URL decoding. Does anyone know where this stripping occurs and if it's possible to selectively disable it? Unfortunately you can't disable it, WSGI servers must decode the URL's path portion before passing it to WSGI apps. Either an RFC or the CGI spec (which WSGI 1 stays compatible with) mandates this, I can't recall which -- Ben Bangert or Ian Bicking might remember. It's in the CGI spec -- SCRIPT_NAME and PATH_INFO are url-decoded, so you can't distinguish between %2f and /. All you can do is include that value as parameter instead, or use WSGI 2 (which of course doesn't exist yet, but somewhere we've penned this 'feature' to be removed in version 2 of the spec). It's mentioned as an issue that WSGI 2 could address, but there hasn't been any proposed solution. -- 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 -~--~~~~--~~--~--~---