What does your routes.py file look like? On Monday, September 3, 2018 at 10:25:22 AM UTC-4, Lisandro wrote: > > This problem is getting weirder. > > I've found that passing integer numbers as args to URL() helper isn't a > problem for web2py. > I could successfully run some examples using integer and long integers as > URL args, and it always works ok. > In fact, as I stated before, my application uses URL in that way since a > long time ago, with no errors. > Even more: in the apps where the code fails, it only fails when it is run > from the scheduler, but it works ok if it is run from the controllers. > But, just to remember, it doesn't fail in all the apps, only in some of > them. But the apps are all the same, it's the same app installed several > times. > > > A quick resume: > > This sentence: > URL('default', f=f, args=[contenido.id, contenido.slug], extension='', > scheme=True, host=current.CONFIG.dominio) > > > * from a controller, it always runs ok. > * from the scheduler, it fails in some applications. > > The error points to gluon/rewrite.py: > > File "applications/pescaregional/modules/virtual_methods.py", line 248, in > contenido_url return URL(c='default', f=f, args=[contenido.id, contenido. > slug], extension='', scheme=True,host=current.CONFIG.dominio) if f else > None > File "/var/www/medios/gluon/html.py", line 391, in URL args, other, scheme > , host, port, language=language) > File "/var/www/medios/gluon/rewrite.py", line 197, in url_out function, > args, other, scheme, host, port, language) > File "/var/www/medios/gluon/rewrite.py", line 1366, in map_url_out return > map.acf() > File "/var/www/medios/gluon/rewrite.py", line 1292, in acf self.omit_acf() # > try to omit a/c/f > File "/var/www/medios/gluon/rewrite.py", line 1241, in omit_acf if self. > args[0] in self.functions or self.args[0] in self.controllers or self.args > [0] in applications: TypeError: 'in ' requires stringas left operand, not > long > > > I'm a bit lost. > Where else should I look? > > > El lunes, 3 de septiembre de 2018, 1:45:49 (UTC-3), Lisandro escribió: >> >> Thanks for that fast response. >> If the cause of the problem is passing "contenido.id" as int, then the >> error is even more weird, because my app uses URL like that in several >> situations, for example: >> >> URL('contenido', 'editar', args=contenido.id) >> URL('categoria', 'editar', args=categoria.id) >> URL('default', 'index', args=[categoria.id, page_number]) >> >> >> Now that I think it, the error that I reported happens within the >> scheduler environment. >> Could that difference be the reason? Well, even in that case, it wouldn't >> explain why it works ok in other apps. >> >> >> >> >> El lunes, 3 de septiembre de 2018, 1:25:19 (UTC-3), fiubarc escribió: >>> >>> Hello, >>> >>> I think it's more a matter of python language, contenido.id is long type >>> then self.args[0] in 'any string' raise an exception because, as the >>> message says : >>> >>> 'in ' requires string as left operand, not long >>> >>> You can do args=['%s' % contenido.id, .... or args=[str(contenido.id), >>> .... >>> >>> Dont know why in others installed apps works, is really weird >>> >>> >>> >>> El lunes, 3 de septiembre de 2018, 0:54:32 (UTC-3), Lisandro escribió: >>>> >>>> I have the same app installed several times within a web2py instance >>>> (running version 2.16.1-stable+timestamp.2017.11.14.05.54.25). >>>> >>>> In some of them, this sentence: >>>> >>>> URL(c='default', f=f, args=[contenido.id, contenido.slug], extension='' >>>> , scheme=True, host=current.CONFIG.dominio) >>>> >>>> ... throws this traceback error: >>>> >>>> Traceback (most recent call last): >>>> File "/var/www/medios/gluon/scheduler.py", line 501, in executor >>>> result = dumps(_function(*args, **vars)) >>>> File "applications/pescaregional/compiled/models.db.py", line 519, in >>>> newsletter >>>> File "applications/pescaregional/modules/globales.py", line 938, in >>>> enviar_newsletter 'url_noticia': noticia.url() + utm_vars, >>>> File "/var/www/medios/gluon/packages/dal/pydal/objects.py", line 2407, >>>> in __call__ return self.method(self.row, *args, **kwargs) >>>> File "applications/pescaregional/compiled/models.db.py", line 295, in >>>> File "applications/pescaregional/modules/virtual_methods.py", line 248, >>>> in contenido_url return URL(c='default', f=f, args=[contenido.id, >>>> contenido.slug], extension='', scheme=True, host=current.CONFIG.dominio >>>> ) if f else None >>>> File "/var/www/medios/gluon/html.py", line 391, in URL args, other, >>>> scheme, host, port, language=language) >>>> File "/var/www/medios/gluon/rewrite.py", line 197, in url_out function, >>>> args, other, scheme, host, port, language) >>>> File "/var/www/medios/gluon/rewrite.py", line 1366, in map_url_out >>>> return map.acf() >>>> File "/var/www/medios/gluon/rewrite.py", line 1292, in acf self. >>>> omit_acf() # try to omit a/c/f >>>> File "/var/www/medios/gluon/rewrite.py", line 1241, in omit_acf if self >>>> .args[0] in self.functions or self.args[0] in self.controllers or self. >>>> args[0] in applications: TypeError: 'in ' requires string as left >>>> operand, not long >>>> >>>> >>>> >>>> The problem is solved changing the sentence with this: >>>> >>>> URL(c='default', f=f, args=['%s' % contenido.id, '%s' % contenido.slug >>>> ], extension='', scheme=True, host=current.CONFIG.dominio) >>>> >>>> ... notice that the args are converted to strings. >>>> >>>> But the weird part is that *the error only happens in some of the >>>> installed apps; and, remember, it's the exact same app installed several >>>> times*. >>>> >>>> First I thought it had something to do with the values stored at >>>> "contenido", which is a row from a table. But it happens with any row. >>>> >>>> I'm using PostgreSQL 9.3. I've checked the databases' enconding and >>>> they all have the same one. I also checked the "contenido" table >>>> definition >>>> in a couple of dbs (one corresponding to an app that presents the error, >>>> and other that doesn't), and they are exactly the same. >>>> >>>> What could be the difference that makes gluon/rewrite.py throw the >>>> error in some of the apps? >>>> >>>
-- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.