[web2py] Re: memory leak - model remains in memory after requests
I monitored my own app running under Rocket in development mode with Ubuntu System Monitor and the RSS memory size started at about 26 MB. After pushing every link in the interface it had grown to 38.5 MB and then stopped at that size. It has been running for over a day now with no further increase in RSS memory. If you are using ram cache in a db().select() statement then the memory build up could be because every query selects a different set of records due to different query conditions resulting in every query adding a new cached item to the ram cache. Is there any chance you have code in the modules directory that is creating new global objects on every invocation of the model which is per request? The module code is imported, the model code is run by exec so that might account for a difference. With modules unless the reload=True parameter is supplied on local_import they cannot be edited without a server restart so they behave like a long life addition to the server. Ron
[web2py] Re: Help with function call
You could consider putting common code in files under modules and use a local_import to pull it in. During development set the optional reload=True parameter or you have to restart the server to make a modification in a module file visible.
Re: [web2py] Getting Started...
On Sunday, December 26, 2010 12:05:59 AM UTC-5, David J wrote: Thanks; I am slowly understanding it. I created an app called app1; seems like when I go to the url localhost:8000/app1/default/index it redirects me to the welcome app? I saw somewhere that the welcome app is the Default app; wondering why its not finding the app when I try the url? Thanks Are you saying it literally redirects you to localhost:8000/welcome/default/index (which shouldn't happen), or just that app1 looks like the welcome app? If you create a new app via the web-based admin interface, it will simply copy the welcome app, so your new app will start out looking like the welcome app (the purpose of the welcome app is to serve as a scaffolding app that you can modify). Anthony
Re: [web2py] Getting Started...
Yes its just the scaffolding of the app; I didn't realize it. I am going to play more today. I really like what I see; It seems more and more intuitive as I go forward. Sometimes you over complicate things just because thats the way it works in other frameworks. Thanks for your help. On 12/26/10 10:18 AM, Anthony wrote: On Sunday, December 26, 2010 12:05:59 AM UTC-5, David J wrote: Thanks; I am slowly understanding it. I created an app called app1; seems like when I go to the url localhost:8000/app1/default/index it redirects me to the welcome app? I saw somewhere that the welcome app is the Default app; wondering why its not finding the app when I try the url? Thanks Are you saying it literally redirects you to localhost:8000/welcome/default/index (which shouldn't happen), or just that app1 looks like the welcome app? If you create a new app via the web-based admin interface, it will simply copy the welcome app, so your new app will start out looking like the welcome app (the purpose of the welcome app is to serve as a scaffolding app that you can modify). Anthony
Re: [web2py] Re: It is done GPL2 - LGPL3
Thank you for your christmas Present! +5 , Merry Christmas! On 12/22/10, vihang vihan...@gmail.com wrote: +3 LGPL ! Will make web2py more acceptable... ! On Dec 22, 7:38 am, Luis Díaz diazluis2...@gmail.com wrote: +1 2010/12/22 R. Strusberg strusb...@gmail.com Another reason to switch from *webframework to web2py!. +1 :-) Merry Christmas +1 2010/12/21 mdipierro mdipie...@cs.depaul.edu: For now trunk only. This will propagate to stable since 1.91.1 -- Díaz Luis TSU Analisis de Sistemas Universidad de Carabobo http://web2pyfacil.blogspot.com/ Facultad de Odontologíahttp://www.odontologia.uc.edu.ve/index.php?option=com_contentview=ar...
[web2py] Re: It is done GPL2 - LGPL3
+1 excellent! On Dec 26, 10:40 am, Phyo Arkar phyo.arkarl...@gmail.com wrote: Thank you for your christmas Present! +5 , Merry Christmas! On 12/22/10, vihang vihan...@gmail.com wrote: +3 LGPL ! Will make web2py more acceptable... ! On Dec 22, 7:38 am, Luis Díaz diazluis2...@gmail.com wrote: +1 2010/12/22 R. Strusberg strusb...@gmail.com Another reason to switch from *webframework to web2py!. +1 :-) Merry Christmas +1 2010/12/21 mdipierro mdipie...@cs.depaul.edu: For now trunk only. This will propagate to stable since 1.91.1 -- Díaz Luis TSU Analisis de Sistemas Universidad de Carabobo http://web2pyfacil.blogspot.com/ Facultad de Odontologíahttp://www.odontologia.uc.edu.ve/index.php?option=com_contentview=ar...
[web2py] How to deploy on gae with example.appspot.com directly map to my application?
I saw the py2web.appspot.com directly map to the reddish application, and I want to do the same for my deployment. I already deployed the cookbook application tutorial to http://tempappz.appspot.com/cookbook/test , how do I shorten the url so my application is mapped directly from http://tempappz.appspot.com/ Is the changes in the app.yaml url mapping or in the py2web routing? Thanks
Re: [web2py] How to deploy on gae with example.appspot.com directly map to my application?
The easiest way is renaming your app to 'init' or changing default app in routes.py Enviado via iPhone Em 26/12/2010, às 07:17, jinlin wilkin...@gmail.com escreveu: I saw the py2web.appspot.com directly map to the reddish application, and I want to do the same for my deployment. I already deployed the cookbook application tutorial to http://tempappz.appspot.com/cookbook/test , how do I shorten the url so my application is mapped directly from http://tempappz.appspot.com/ Is the changes in the app.yaml url mapping or in the py2web routing? Thanks
[web2py] Re: Help with function call
Thanks for the response, ron_m. However, the issue is a little more nuanced than my message might have stated originally. As a general rule, ajax(...) and web2py_ajax_page(...) look to a controller for a callback. I was thinking it might be nice for the ajax call to be serviced from a global space, since the same callback may be used by multiple controllers. The problem with putting the callback in modules or models is that *I think* I need a callback stub in each of the controllers, said stub then calling the function stored under models or modules. Is this really the case, or is there a better way? Can the web2py_ajax_page() or ajax() functions access callbacks in a global space? If yes, what would the syntax be for such a call?
[web2py] Re: Help with function call
Of course, the other problem with using modules is that, especially with components, I really need to get to the global variable space. Yes, I can always pass global() and db to the module, but within the module, it makes the code bloat up a bit with constantly having to do global['session'].xyz and global['request'].args and such, which is an added pain.
Re: [web2py] Re: Help with function call
Make a controller named system or global? -- Thadeus On Sun, Dec 26, 2010 at 2:29 PM, weheh richard_gor...@verizon.net wrote: Of course, the other problem with using modules is that, especially with components, I really need to get to the global variable space. Yes, I can always pass global() and db to the module, but within the module, it makes the code bloat up a bit with constantly having to do global['session'].xyz and global['request'].args and such, which is an added pain.
[web2py] Re: Help with function call
Yes, that's a possibility, too. I need to experiment a bit more to find the optimal approach. My web2py horizons are expanding daily. On Dec 26, 3:43 pm, Thadeus Burgess thade...@thadeusb.com wrote: Make a controller named system or global? -- Thadeus On Sun, Dec 26, 2010 at 2:29 PM, weheh richard_gor...@verizon.net wrote: Of course, the other problem with using modules is that, especially with components, I really need to get to the global variable space. Yes, I can always pass global() and db to the module, but within the module, it makes the code bloat up a bit with constantly having to do global['session'].xyz and global['request'].args and such, which is an added pain.
[web2py] Default Values.
How do I specify Default DB values; ie: I have a db field created_at which is datetime and should be a timestamp of when the user was created. Normally in mysql; we use created_at timestamp default now() where do I specify this default value? Or do I specify it when I create the object? Thanks.
Re: [web2py] Default Values.
Field http://web2py.com/book/default/docstring/Field('created_on', 'datetime', default=request http://web2py.com/book/default/docstring/request.now), Field http://web2py.com/book/default/docstring/Field('created_by', db.auth_user, default=auth.user_id), Field http://web2py.com/book/default/docstring/Field('updated_on', 'datetime', update=request http://web2py.com/book/default/docstring/request.now), Field http://web2py.com/book/default/docstring/Field('updated_by', db.auth_user, update=auth.user_id)) http://web2py.com/book/default/chapter/06#Table-Inheritance http://web2py.com/book/default/chapter/06#Table-Inheritance 2010/12/26 David J. da...@styleflare.com How do I specify Default DB values; ie: I have a db field created_at which is datetime and should be a timestamp of when the user was created. Normally in mysql; we use created_at timestamp default now() where do I specify this default value? Or do I specify it when I create the object? Thanks. -- Bruno Rocha http://about.me/rochacbruno/bio
Re: [web2py] Default Values.
Thanks; just what I was looking for. On 12/26/10 6:19 PM, Bruno Rocha wrote: Field http://web2py.com/book/default/docstring/Field('created_on','datetime',default=request http://web2py.com/book/default/docstring/request.now), Field http://web2py.com/book/default/docstring/Field('created_by',db.auth_user,default=auth.user_id), Field http://web2py.com/book/default/docstring/Field('updated_on','datetime',update=request http://web2py.com/book/default/docstring/request.now), Field http://web2py.com/book/default/docstring/Field('updated_by',db.auth_user,update=auth.user_id)) http://web2py.com/book/default/chapter/06#Table-Inheritance 2010/12/26 David J. da...@styleflare.com mailto:da...@styleflare.com How do I specify Default DB values; ie: I have a db field created_at which is datetime and should be a timestamp of when the user was created. Normally in mysql; we use created_at timestamp default now() where do I specify this default value? Or do I specify it when I create the object? Thanks. -- Bruno Rocha http://about.me/rochacbruno/bio
Re: [web2py] Default Values.
Definitely suggest running through chapter 3 of the book (and all chapters if possible).
[web2py] gql broken in latest version (1.91.4) ?
Could you tell me an older version of web2py that has working gql support, and where to get it? I only have gae as a hosting option, and I need to complete a small project asap. At first I am getting errors because contrib/gql.py is refering to gluon.sql.DEFAULT gluon.sql.Reference gluon.sql.validators which is not imported in gluon/sql.py After adding these three, I am getting this error (gql.Field class doesn't have db attribute) File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ applications/redditpy/models/db.py, line 7, in module session.connect(request,response,db=db) File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ gluon/globals.py, line 319, in connect migrate=table_migrate, File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ gluon/contrib/gql.py, line 136, in define_table t = self[tablename] = Table(self, tablename, *fields) File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ gluon/contrib/gql.py, line 219, in __init__ field.requires = gluon.sql.sqlhtml_validators(field) File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ gluon/dal.py, line 2993, in sqlhtml_validators elif field.db and field_type.startswith('reference') and \ AttributeError: 'Field' object has no attribute 'db' Thanks
Re: [web2py] Default Values.
Thanks for the Tips; Does this have sqlite have some sort of limitations? I seem to get this exception; Traceback (most recent call last): File /Users/book/Desktop/python-projects/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /Users/book/Desktop/python-projects/web2py/applications/app/models/db.py, line 97, in module Field('updated_at','datetime',default=request.now,update=request.now),) File /Users/book/Desktop/python-projects/web2py/gluon/dal.py, line 3321, in define_table polymodel=polymodel) File /Users/book/Desktop/python-projects/web2py/gluon/dal.py, line 410, in create_table elif field.type[:10] == 'reference ': TypeError: 'NoneType' object is unsubscriptable ERROR SNAPSHOT type 'exceptions.TypeError'('NoneType' object is unsubscriptable) On 12/26/10 6:19 PM, Bruno Rocha wrote: db.auth_user,default=auth.user_id
Re: [web2py] Default Values.
Have you tried ``str(field.type[:10])``? Just a wild guess. I think just saying ``field.type[:10]`` would actually return a class instance, not a string. On Mon, Dec 27, 2010 at 2:05 AM, David J. da...@styleflare.com wrote: Thanks for the Tips; Does this have sqlite have some sort of limitations? I seem to get this exception; Traceback (most recent call last): File /Users/book/Desktop/python-projects/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /Users/book/Desktop/python-projects/web2py/applications/app/models/db.py, line 97, in module Field('updated_at','datetime',default=request.now,update=request.now),) File /Users/book/Desktop/python-projects/web2py/gluon/dal.py, line 3321, in define_table polymodel=polymodel) File /Users/book/Desktop/python-projects/web2py/gluon/dal.py, line 410, in create_table elif field.type[:10] == 'reference ': TypeError: 'NoneType' object is unsubscriptable ERROR SNAPSHOT type 'exceptions.TypeError'('NoneType' object is unsubscriptable) On 12/26/10 6:19 PM, Bruno Rocha wrote: db.auth_user, default=auth.user_id -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/
Re: [web2py] Default Values.
Oops. Correction: str(field.type)[:10] 2010/12/27 Branko Vukelić stu...@brankovukelic.com: Have you tried ``str(field.type[:10])``? Just a wild guess. I think just saying ``field.type[:10]`` would actually return a class instance, not a string. On Mon, Dec 27, 2010 at 2:05 AM, David J. da...@styleflare.com wrote: Thanks for the Tips; Does this have sqlite have some sort of limitations? I seem to get this exception; Traceback (most recent call last): File /Users/book/Desktop/python-projects/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /Users/book/Desktop/python-projects/web2py/applications/app/models/db.py, line 97, in module Field('updated_at','datetime',default=request.now,update=request.now),) File /Users/book/Desktop/python-projects/web2py/gluon/dal.py, line 3321, in define_table polymodel=polymodel) File /Users/book/Desktop/python-projects/web2py/gluon/dal.py, line 410, in create_table elif field.type[:10] == 'reference ': TypeError: 'NoneType' object is unsubscriptable ERROR SNAPSHOT type 'exceptions.TypeError'('NoneType' object is unsubscriptable) On 12/26/10 6:19 PM, Bruno Rocha wrote: db.auth_user, default=auth.user_id -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/ -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/
[web2py] Re: Help with where to put stuff [Closed]
OK, finally decided that all the common ajax stuff should be under models, not modules, because of their heavy use of globals(). So far, I have only needed one stub in one controller, so not as big after all.
[web2py] Re: gql broken in latest version (1.91.4) ?
gluon/contrib/gql.py no longer works with web2py. and you do not need it any more because its functions are now provided in the new DAL. db=DAL('gae') db.define_table('mytable',Field('name')) etc. Yet you raise a good issue. You are probably using the very old syntax from gluon.contrib import gql db=gql.GQLDB() db.define_table('mytable',gql.Field('name')) I forgot about this and I did not add a compatibility layer. I suggest you change your code you can also edit gql.py and replace its entire content with begin __all__ = ['DAL','Field','drivers'] from dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, drivers, BaseAdapter, SQLField, SQLTable, SQLXorable, SQLQuery, SQLSet, SQLRows, SQLStorage, SQLDB, GQLDB, SQLALL, SQLCustomType - end - and your code should work as it is. On Dec 26, 6:38 pm, jinlin wilkin...@gmail.com wrote: Could you tell me an older version of web2py that has working gql support, and where to get it? I only have gae as a hosting option, and I need to complete a small project asap. At first I am getting errors because contrib/gql.py is refering to gluon.sql.DEFAULT gluon.sql.Reference gluon.sql.validators which is not imported in gluon/sql.py After adding these three, I am getting this error (gql.Field class doesn't have db attribute) File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ applications/redditpy/models/db.py, line 7, in module session.connect(request,response,db=db) File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ gluon/globals.py, line 319, in connect migrate=table_migrate, File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ gluon/contrib/gql.py, line 136, in define_table t = self[tablename] = Table(self, tablename, *fields) File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ gluon/contrib/gql.py, line 219, in __init__ field.requires = gluon.sql.sqlhtml_validators(field) File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ gluon/dal.py, line 2993, in sqlhtml_validators elif field.db and field_type.startswith('reference') and \ AttributeError: 'Field' object has no attribute 'db' Thanks
[web2py] Re: Default Values.
please check trunk On Dec 26, 7:49 pm, Branko Vukelić stu...@brankovukelic.com wrote: Oops. Correction: str(field.type)[:10] 2010/12/27 Branko Vukelić stu...@brankovukelic.com: Have you tried ``str(field.type[:10])``? Just a wild guess. I think just saying ``field.type[:10]`` would actually return a class instance, not a string. On Mon, Dec 27, 2010 at 2:05 AM, David J. da...@styleflare.com wrote: Thanks for the Tips; Does this have sqlite have some sort of limitations? I seem to get this exception; Traceback (most recent call last): File /Users/book/Desktop/python-projects/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /Users/book/Desktop/python-projects/web2py/applications/app/models/db.py, line 97, in module Field('updated_at','datetime',default=request.now,update=request.now),) File /Users/book/Desktop/python-projects/web2py/gluon/dal.py, line 3321, in define_table polymodel=polymodel) File /Users/book/Desktop/python-projects/web2py/gluon/dal.py, line 410, in create_table elif field.type[:10] == 'reference ': TypeError: 'NoneType' object is unsubscriptable ERROR SNAPSHOT type 'exceptions.TypeError'('NoneType' object is unsubscriptable) On 12/26/10 6:19 PM, Bruno Rocha wrote: db.auth_user, default=auth.user_id -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/ -- Branko Vukelic stu...@brankovukelic.comhttp://www.brankovukelic.com/
[web2py] Re: gql broken in latest version (1.91.4) ?
I think this is now fixed in trunk. On Dec 26, 6:38 pm, jinlin wilkin...@gmail.com wrote: Could you tell me an older version of web2py that has working gql support, and where to get it? I only have gae as a hosting option, and I need to complete a small project asap. At first I am getting errors because contrib/gql.py is refering to gluon.sql.DEFAULT gluon.sql.Reference gluon.sql.validators which is not imported in gluon/sql.py After adding these three, I am getting this error (gql.Field class doesn't have db attribute) File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ applications/redditpy/models/db.py, line 7, in module session.connect(request,response,db=db) File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ gluon/globals.py, line 319, in connect migrate=table_migrate, File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ gluon/contrib/gql.py, line 136, in define_table t = self[tablename] = Table(self, tablename, *fields) File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ gluon/contrib/gql.py, line 219, in __init__ field.requires = gluon.sql.sqlhtml_validators(field) File /Users/wilkin_ng/Documents/project/appengine/web2py/web2py/ gluon/dal.py, line 2993, in sqlhtml_validators elif field.db and field_type.startswith('reference') and \ AttributeError: 'Field' object has no attribute 'db' Thanks
[web2py] Re: gql broken in latest version (1.91.4) ?
Thanks for the quick fix, I am pretty new with web2py, but had done some python programming on gae before. The changes for gql.py has a syntax error. from dal should be changed to from gluon.dal There is another problem with GAENoSqlAdapter class. It doesn't handle a query like db().select(db.category.ALL) The method GAENoSqlAdapter.select_raw assume query is not empty, so it will error in self.get_table(query) when it can not get the table. def select_raw(self,query,fields=[],attributes={}): tablename = self.get_table(query) tableobj = self.db[tablename]._tableobj Comparing with the old qgl it has code to check like so if fields and isinstance(fields[0], SQLALL): self._tables.insert(0, fields[0].table._tablename) To reproduce the error, it is from the Reddish appliance. I changed the db() creation in db.py like you suggested. Here is the stack trace if len(db().select(db.category.ALL))==0: File /Documents/project/appengine/web2py/web2py/gluon/dal.py, line 4480, in select return self.db._adapter.select(self.query,fields,attributes) File /Documents/project/appengine/web2py/web2py/gluon/dal.py, line 2654, in select (items, tablename, fields) = self.select_raw(query,fields,attributes) File /Documents/project/appengine/web2py/web2py/gluon/dal.py, line 2611, in select_raw tablename = self.get_table(query) File /Documents/project/appengine/web2py/web2py/gluon/dal.py, line 894, in get_table raise RuntimeError, No table selected RuntimeError: No table selected
[web2py] A bug or am I doing something wrong
Aapche 2, wsgi, MySQL 5.0, web2py 1.91.4, python 2.6.5 I have defined in my model: Field('f_total_sum_all', type='decimal', label=T('Total Sum')), Even floeat gives the same error. Only integer works. Version web2py™ Version 1.91.4 (2010-12-22 17:31:23) Python Python 2.6.5: /usr/bin/python Traceback (most recent call last): File /web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /web2py/applications/kenneths/models/db_wizard.py, line 70, in module migrate=settings.migrate) File /web2py/gluon/dal.py, line 3321, in define_table polymodel=polymodel) File /web2py/gluon/dal.py, line 444, in create_table precision, scale = [int(x) for x in field.type[8:-1].split(',')] ValueError: invalid literal for int() with base 10: '' Error snapshot help Detailed traceback description type 'exceptions.ValueError'(invalid literal for int() with base 10: '') inspect attributes Exception instance attributes __setattr__ method-wrapper '__setattr__' of exceptions.ValueError object __reduce_ex__ built-in method __reduce_ex__ of exceptions.ValueError object __getslice__ method-wrapper '__getslice__' of exceptions.ValueError object __getitem__ method-wrapper '__getitem__' of exceptions.ValueError object __setstate__ built-in method __setstate__ of exceptions.ValueError object __getattribute__ method-wrapper '__getattribute__' of exceptions.ValueError object __str__ method-wrapper '__str__' of exceptions.ValueError object args (invalid literal for int() with base 10: '',) __reduce__ built-in method __reduce__ of exceptions.ValueError object __format__ built-in method __format__ of exceptions.ValueError object __class__ type 'exceptions.ValueError' __dict__ {} __delattr__ method-wrapper '__delattr__' of exceptions.ValueError object __subclasshook__ built-in method __subclasshook__ of type object __repr__ method-wrapper '__repr__' of exceptions.ValueError object __init__ method-wrapper '__init__' of exceptions.ValueError object __hash__ method-wrapper '__hash__' of exceptions.ValueError object __sizeof__ built-in method __sizeof__ of exceptions.ValueError object __doc__ 'Inappropriate argument value (of correct type).' __unicode__ built-in method __unicode__ of exceptions.ValueError object __new__ built-in method __new__ of type object Frames File /web2py/gluon/restricted.py in restricted at line 188 code arguments variables Function argument list (code=### we prepend t_ to tablenames and f_ to fieldn...Field('current_record','reference t_bill_item'))\n, environment={'A': class 'gluon.html.A', 'Auth': class 'gluon.tools.Auth', 'B': class 'gluon.html.B', 'BEAUTIFY': class 'gluon.html.BEAUTIFY', 'BODY': class 'gluon.html.BODY', 'BR': class 'gluon.html.BR', 'CENTER': class 'gluon.html.CENTER', 'CLEANUP': class 'gluon.validators.CLEANUP', 'CODE': class 'gluon.html.CODE', 'CRYPT': class 'gluon.validators.CRYPT', ...}, layer='/web2py/applications/kenneths/models/db_wizard.py') Code listing if type(code) == types.CodeType: ccode = code else: ccode = compile2(code,layer) exec ccode in environment except HTTP: raise except Exception: # XXX Show exception in Wing IDE if running in debugger Variables environment {'A': class 'gluon.html.A', 'Auth': class 'gluon.tools.Auth', 'B': class 'gluon.html.B', 'BEAUTIFY': class 'gluon.html.BEAUTIFY', 'BODY': class 'gluon.html.BODY', 'BR': class 'gluon.html.BR', 'CENTER': class 'gluon.html.CENTER', 'CLEANUP': class 'gluon.validators.CLEANUP', 'CODE': class 'gluon.html.CODE', 'CRYPT': class 'gluon.validators.CRYPT', ...} ccode code object module at 0x2aaab001f6c0, file /...plications/kenneths/models/db_wizard.py, line 5 * File /web2py/applications/kenneths/models/db_wizard.py in module at line 70 code arguments variables Function argument list () Code listing label=T('Created By'),writable=False,readable=False), Field('modified_by',db.auth_user,default=auth.user_id, label=T('Modified By'),writable=False,readable=False, update=auth.user_id), format='%(f_name)s', migrate=settings.migrate) db.define_table('t_receipt_archive',db.t_receipt,Field('current_record','reference t_receipt')) Variables migrate undefined settings.migrate True settings Storage {'layout_theme': 'Clicker', 'subtitle':...l_server': 'localhost', 'login_method': 'local'} * File /web2py/gluon/dal.py in define_table at line 3321 code arguments variables Function argument list (self=DAL {'auth_permission': Table {'ALL': gluon.d...ab0014c90}, '_migrate': True, '_pool_size': 0}, tablename='t_receipt', *fields=(gluon.dal.Field object, gluon.dal.Field object, gluon.dal.Field object, gluon.dal.Field object, gluon.dal.Field object, gluon.dal.Field object, gluon.dal.Field object, gluon.dal.Field object, gluon.dal.Field object, gluon.dal.Field object, gluon.dal.Field object, gluon.dal.Field object), **args={'format': '%(f_name)s', 'migrate': True}) Code listing if migrate or self._uri=='gae': try:
[web2py] Re: problem with ajax search
I have been able to duplicate this error with latest version of web2py (1.91.4) and the exact wiki app in Chapter 3 of the book. To recap, if you use the ajax search recipe described in Chapter 3, you can not have a trailing slash (bug described above). This means no arguments are can be passed to this controller. Curiously, variables (request.vars) can be passed in without having this problem. (This tells me there's something about the slash.)
[web2py] Re: problem with ajax search
I think it's likely that this is the same bug reported by http://groups.google.com/group/web2py/browse_thread/thread/9707f3d66d859893/5785831e673afd2b?lnk=gstq=ajax+search#5785831e673afd2b If true, it's interesting to note that this bug has lived for almost 2 years; possibly more.
Re: [web2py] Re: Server slow
What part of the model would you like to see? This? db.define_table('orders', db.Field('name', 'string', length=40, requires=IS_NOT_EMPTY()), db.Field('district', db.district, required=True), db.Field('edited_by', db[user_table], required=True), db.Field('edited_date', 'datetime', required=True), db.Field('reward_selected', 'integer', default=0), db.Field('members', 'integer', default=0), db.Field('memb_no', 'string', default=0), db.Field('locked', 'integer', default=False, required=True), db.Field('cow_id', 'string', default=''), migrate=settings.migrate) So far there was no view defined for this controller. If I define a empty one it takes like 2-3 seconds to show a empty page, controller changed to dict(orders=orders). If I define the view to be {{=orders}} it takes again 40 seconds to show. The strange thing is if I change the view to {{ for order in orders: =XML(order) pass }} it only takes about 2-3 seconds to show all orders. Not as nice as =orders but very strange anyhow. Kenneth I have never seen this before. Can I see the model? massimo On Dec 25, 3:51 pm, Kenneth Lundströmkenneth.t.lundst...@gmail.com wrote: Is this reproducible? This happens all the time, if I do it ten times in a row every time it takes 38-39 seconds. Even with lynx on the server itself it takes about 40 seconds. If I use: t0=time.time() orders = db(db.orders.id0).select() logging.info('time to fetch %s' % (time.time()-t0)) The time is 1.75 - 1.90 seconds to fetch the data from database I change the controller to this sql = db(db.orders.id0)._select() t0=time.time() db.executesql(sql) logging.info('time to fetch %s' % (time.time()-t0)) orders=[] now I get times like 0.38 - 0.39 seconds If I instead of db.orders.id490) to get half the rows all times drops to half, even 40 seconds is now 20 seconds. Just testing I tried with: t0=time.time() orders = db(db.orders.id0).select() orders1 = db(db.orders.id0).select() orders2 = db(db.orders.id0).select() orders3 = db(db.orders.id0).select() orders4 = db(db.orders.id0).select() logging.info('time to fetch %s' % (time.time()-t0)) return orders This takes about, 5x1,8s (to fetch data) + 35 seconds = 45 seconds I tried with a different table that contains about 1250 rows, 6 columns. It takes 1.2-1.3 seconds to fetch the data, but then over 60 seconds to display it. Kenneth
[web2py] Re: Server slow
Now I understand. The problem is here: Field('edited_by', db[user_table], required=True), When you do {{=orders}} is uses a default representation for edited_by. The field contains a user id and the default representation is the user name. So for each record it has to do a database lookup (980 of them). If you want to represent users by name, you should either cache them. Something like this: db.orders.edited_by.represent = lambda id: cache.ram('user: %i'%id,lambda:db.auth_user(id).first_name,3600) or turn your query into a join. Massimo On Dec 26, 11:37 pm, Kenneth Lundström kenneth.t.lundst...@gmail.com wrote: What part of the model would you like to see? This? db.define_table('orders', db.Field('name', 'string', length=40, requires=IS_NOT_EMPTY()), db.Field('district', db.district, required=True), db.Field('edited_by', db[user_table], required=True), db.Field('edited_date', 'datetime', required=True), db.Field('reward_selected', 'integer', default=0), db.Field('members', 'integer', default=0), db.Field('memb_no', 'string', default=0), db.Field('locked', 'integer', default=False, required=True), db.Field('cow_id', 'string', default=''), migrate=settings.migrate) So far there was no view defined for this controller. If I define a empty one it takes like 2-3 seconds to show a empty page, controller changed to dict(orders=orders). If I define the view to be {{=orders}} it takes again 40 seconds to show. The strange thing is if I change the view to {{ for order in orders: =XML(order) pass }} it only takes about 2-3 seconds to show all orders. Not as nice as =orders but very strange anyhow. Kenneth I have never seen this before. Can I see the model? massimo On Dec 25, 3:51 pm, Kenneth Lundstr�mkenneth.t.lundst...@gmail.com wrote: Is this reproducible? This happens all the time, if I do it ten times in a row every time it takes 38-39 seconds. Even with lynx on the server itself it takes about 40 seconds. If I use: t0=time.time() orders = db(db.orders.id 0).select() logging.info('time to fetch %s' % (time.time()-t0)) The time is 1.75 - 1.90 seconds to fetch the data from database I change the controller to this sql = db(db.orders.id 0)._select() t0=time.time() db.executesql(sql) logging.info('time to fetch %s' % (time.time()-t0)) orders=[] now I get times like 0.38 - 0.39 seconds If I instead of db.orders.id 490) to get half the rows all times drops to half, even 40 seconds is now 20 seconds. Just testing I tried with: t0=time.time() orders = db(db.orders.id 0).select() orders1 = db(db.orders.id 0).select() orders2 = db(db.orders.id 0).select() orders3 = db(db.orders.id 0).select() orders4 = db(db.orders.id 0).select() logging.info('time to fetch %s' % (time.time()-t0)) return orders This takes about, 5x1,8s (to fetch data) + 35 seconds = 45 seconds I tried with a different table that contains about 1250 rows, 6 columns. It takes 1.2-1.3 seconds to fetch the data, but then over 60 seconds to display it. Kenneth
[web2py] Re: problem with ajax search
It is not a bug. The URL is incomplete ajax('{{=URL('add_issue_find')}}',['keyword'],'target');) On Dec 26, 11:35 pm, VP vtp2...@gmail.com wrote: I think it's likely that this is the same bug reported byhttp://groups.google.com/group/web2py/browse_thread/thread/9707f3d66d... If true, it's interesting to note that this bug has lived for almost 2 years; possibly more.
[web2py] Re: gql broken in latest version (1.91.4) ?
Can you please post a googlecode report and I will fix this asap? Thanks On Dec 26, 11:08 pm, jinlin wilkin...@gmail.com wrote: Thanks for the quick fix, I am pretty new with web2py, but had done some python programming on gae before. The changes for gql.py has a syntax error. from dal should be changed to from gluon.dal There is another problem with GAENoSqlAdapter class. It doesn't handle a query like db().select(db.category.ALL) The method GAENoSqlAdapter.select_raw assume query is not empty, so it will error in self.get_table(query) when it can not get the table. def select_raw(self,query,fields=[],attributes={}): tablename = self.get_table(query) tableobj = self.db[tablename]._tableobj Comparing with the old qgl it has code to check like so if fields and isinstance(fields[0], SQLALL): self._tables.insert(0, fields[0].table._tablename) To reproduce the error, it is from the Reddish appliance. I changed the db() creation in db.py like you suggested. Here is the stack trace if len(db().select(db.category.ALL))==0: File /Documents/project/appengine/web2py/web2py/gluon/dal.py, line 4480, in select return self.db._adapter.select(self.query,fields,attributes) File /Documents/project/appengine/web2py/web2py/gluon/dal.py, line 2654, in select (items, tablename, fields) = self.select_raw(query,fields,attributes) File /Documents/project/appengine/web2py/web2py/gluon/dal.py, line 2611, in select_raw tablename = self.get_table(query) File /Documents/project/appengine/web2py/web2py/gluon/dal.py, line 894, in get_table raise RuntimeError, No table selected RuntimeError: No table selected
[web2py] Re: problem with ajax search
Just plug it in. Doesn't seem to work at all. def search(): an ajax wiki search page return dict(form=FORM(INPUT(_id='keyword',_name='keyword', _onkeyup=ajax('{{=URL('bg_find')}}', ['keyword'],'target');)), target_div=DIV(_id='target')) On Dec 26, 11:51 pm, mdipierro mdipie...@cs.depaul.edu wrote: It is not a bug. The URL is incomplete ajax('{{=URL('add_issue_find')}}',['keyword'],'target');) On Dec 26, 11:35 pm, VP vtp2...@gmail.com wrote: I think it's likely that this is the same bug reported byhttp://groups.google.com/group/web2py/browse_thread/thread/9707f3d66d... If true, it's interesting to note that this bug has lived for almost 2 years; possibly more.
[web2py] Re: problem with ajax search
Sorry, my mistake... def search(): an ajax wiki search page return dict(form=FORM(INPUT(_id='keyword',_name='keyword', _onkeyup=ajax('%s',['keyword'],'target'); % URL('bg_find'))), target_div=DIV(_id='target')) On Dec 27, 12:03 am, VP vtp2...@gmail.com wrote: Just plug it in. Doesn't seem to work at all. def search(): an ajax wiki search page return dict(form=FORM(INPUT(_id='keyword',_name='keyword', _onkeyup=ajax('{{=URL('bg_find')}}', ['keyword'],'target');)), target_div=DIV(_id='target')) On Dec 26, 11:51 pm, mdipierro mdipie...@cs.depaul.edu wrote: It is not a bug. The URL is incomplete ajax('{{=URL('add_issue_find')}}',['keyword'],'target');) On Dec 26, 11:35 pm, VP vtp2...@gmail.com wrote: I think it's likely that this is the same bug reported byhttp://groups.google.com/group/web2py/browse_thread/thread/9707f3d66d... If true, it's interesting to note that this bug has lived for almost 2 years; possibly more.
Re: [web2py] Re: Server slow
So it rather fast not slow :=) But the edited_by column is not showing a name, it shows a number. But that is not very intresting as I don´t need a list like that, it was just a test. I´m trying to optimize some reporting functions. I´ll have to start from an other angle. Kenneth Now I understand. The problem is here: Field('edited_by', db[user_table], required=True), When you do {{=orders}} is uses a default representation for edited_by. The field contains a user id and the default representation is the user name. So for each record it has to do a database lookup (980 of them). If you want to represent users by name, you should either cache them. Something like this: db.orders.edited_by.represent = lambda id: cache.ram('user: %i'%id,lambda:db.auth_user(id).first_name,3600) or turn your query into a join. Massimo On Dec 26, 11:37 pm, Kenneth Lundströmkenneth.t.lundst...@gmail.com wrote: What part of the model would you like to see? This? db.define_table('orders', db.Field('name', 'string', length=40, requires=IS_NOT_EMPTY()), db.Field('district', db.district, required=True), db.Field('edited_by', db[user_table], required=True), db.Field('edited_date', 'datetime', required=True), db.Field('reward_selected', 'integer', default=0), db.Field('members', 'integer', default=0), db.Field('memb_no', 'string', default=0), db.Field('locked', 'integer', default=False, required=True), db.Field('cow_id', 'string', default=''), migrate=settings.migrate) So far there was no view defined for this controller. If I define a empty one it takes like 2-3 seconds to show a empty page, controller changed to dict(orders=orders). If I define the view to be {{=orders}} it takes again 40 seconds to show. The strange thing is if I change the view to {{ for order in orders: =XML(order) pass }} it only takes about 2-3 seconds to show all orders. Not as nice as =orders but very strange anyhow. Kenneth I have never seen this before. Can I see the model? massimo On Dec 25, 3:51 pm, Kenneth Lundstr�mkenneth.t.lundst...@gmail.com wrote: Is this reproducible? This happens all the time, if I do it ten times in a row every time it takes 38-39 seconds. Even with lynx on the server itself it takes about 40 seconds. If I use: t0=time.time() orders = db(db.orders.id 0).select() logging.info('time to fetch %s' % (time.time()-t0)) The time is 1.75 - 1.90 seconds to fetch the data from database I change the controller to this sql = db(db.orders.id 0)._select() t0=time.time() db.executesql(sql) logging.info('time to fetch %s' % (time.time()-t0)) orders=[] now I get times like 0.38 - 0.39 seconds If I instead of db.orders.id 490) to get half the rows all times drops to half, even 40 seconds is now 20 seconds. Just testing I tried with: t0=time.time() orders = db(db.orders.id 0).select() orders1 = db(db.orders.id 0).select() orders2 = db(db.orders.id 0).select() orders3 = db(db.orders.id 0).select() orders4 = db(db.orders.id 0).select() logging.info('time to fetch %s' % (time.time()-t0)) return orders This takes about, 5x1,8s (to fetch data) + 35 seconds = 45 seconds I tried with a different table that contains about 1250 rows, 6 columns. It takes 1.2-1.3 seconds to fetch the data, but then over 60 seconds to display it. Kenneth
[web2py] Re: problem with ajax search
Massimo, It now works as a charm. Thank you so, so much for your help!!! On Dec 27, 12:07 am, mdipierro mdipie...@cs.depaul.edu wrote: Sorry, my mistake... def search(): an ajax wiki search page return dict(form=FORM(INPUT(_id='keyword',_name='keyword', _onkeyup=ajax('%s',['keyword'],'target'); % URL('bg_find'))), target_div=DIV(_id='target')) On Dec 27, 12:03 am, VP vtp2...@gmail.com wrote: Just plug it in. Doesn't seem to work at all. def search(): an ajax wiki search page return dict(form=FORM(INPUT(_id='keyword',_name='keyword', _onkeyup=ajax('{{=URL('bg_find')}}', ['keyword'],'target');)), target_div=DIV(_id='target')) On Dec 26, 11:51 pm, mdipierro mdipie...@cs.depaul.edu wrote: It is not a bug. The URL is incomplete ajax('{{=URL('add_issue_find')}}',['keyword'],'target');) On Dec 26, 11:35 pm, VP vtp2...@gmail.com wrote: I think it's likely that this is the same bug reported byhttp://groups.google.com/group/web2py/browse_thread/thread/9707f3d66d... If true, it's interesting to note that this bug has lived for almost 2 years; possibly more.