[web2py] Best way to use a standalone DAL
I will actually call dal from within some scripts and from the webgui. What would be the best and cleanest way to do that ? -- 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/groups/opt_out.
[web2py] Re: Best way to use a standalone DAL
O well the situation is as follows, I have a database and created a web2py webinterface with it. But I also have create some commandline tools that reverence the database. So I wondered if there was a easy way to include dal in the scripts and talk to the database. So webgui is the webinterface of the deployment application. Jim I want to use the database so I guess I need the define tables I tried to to it as explained in the ebook but I got a error (with mongodb) Btw is the path_to_application_databases relative to web2py path or absolute ? On Tuesday, 4 March 2014 00:03:10 UTC+8, Anthony wrote: In a script, you can just import it like any other Python module. Not sure what you mean by calling it from the webgui. Anthony On Monday, March 3, 2014 3:58:39 AM UTC-5, Gwayne aka Mike Veltman wrote: I will actually call dal from within some scripts and from the webgui. What would be the best and cleanest way to do that ? -- 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/groups/opt_out.
Re: [web2py] 1071, 'Specified key was too long; max key length is 767 bytes'
I found it. It was in db.py db.define_table('frame', Field('framename', type='string', # #unique=True, the problem. Is it a bug ? label=T('Framename')), Field('description', type='string', label=T('Description')), Field('netboot', type='string',default=None, label=T('Netboot information')), Field('ip', type='string', #unique=True, label=T('IP Address')), Field('servermodel', type='string',default=p6, label=T('Server model')), Field('serial', type='string',default=None, label=T('Serial Number')), Field('lvname', type='string',default=FRAMEx, label=T('Frame extension for storage logical volumes')), Field('framestaterecord_ID', type='integer', label=T('Frame State record ID')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), format='%(framename)s', migrate=True) On Tuesday 08 October 2013 13:41:31 Mike Veltman wrote: Ok, I am now fighting with it for two days and it drives me crazy. My gut feeling says mysql 5.1 -- mysql 5.5 upgrade is the cause. Am I right ? And how do I solve it. :-) *Error ticket for adeploy* *Ticket ID* 192.168.2.106.2013-10-08.12-46-19.24f3f1a5-d637-4522-965b-fed4958115ed *class '_mysql_exceptions.OperationalError' (1071, 'Specified key was too long; max key length is 767 bytes')* *Version* *web2py™* Version 2.7.2-stable+timestamp.2013.10.07.13.52.24 *Traceback* 1. Traceback *(*most recent call last*): *File /srv/web-apps/web2py/gluon/restricted.py*, *line 217*, in *restricted *exec *ccode *in *environment File /srv/web-apps/web2py/applications/adeploy/compiled/models/db.py*, *line 178*, in *module* *File /srv/web-apps/web2py/gluon/dal.py*, *line 7911*, in *define_tabletable *= **self.*lazy_define_table*(*tablename*,**fields*,***args*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 7948*, in *lazy_define_table polymodel*=*polymodel*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 1029*, in *create_tablefake_migrate*=*fake_migrate*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 1136*, in *migrate_table *self.*execute*(*sub_query*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 1836*, in *execute*return self.*log_execute*(**a*, ***b*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 1830*, in *log_executeret *= **self.*cursor*.*execute*(*command*, **a*[*1*:], ***b*) *File /usr/lib64/python2.6/site-packages/MySQLdb/cursors.py*, *line 173*, in *execute*self.*errorhandler*(self, *exc*, *value*) *File /usr/lib64/python2.6/site-packages/MySQLdb/connections.py*, *line 36*, in *defaulterrorhandler*raise *errorclass*, *errorvalueOperationalError*: (*1071*, *'Specified key was too long; max key length is 767 bytes'*) * *In file: /srv/web-apps/web2py/applications/adeploy/compiled/models/db.pyc* 1. **code object **module* *at 0x168c468*, *file /srv/web-apps/web2py/applications/adeploy/compiled/models/db.py*, *line 28** -- 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/groups/opt_out.
[web2py] 1071, 'Specified key was too long; max key length is 767 bytes
My gut feeling says mysql 5.1 -- mysql 5.5 upgrade is the cause. Am I right ? And how do I solve it. :-) *Error ticket for adeploy* *Ticket ID* 192.168.2.106.2013-10-08.12-46-19.24f3f1a5-d637-4522-965b-fed4958115ed *class '_mysql_exceptions.OperationalError' (1071, 'Specified key was too long; max key length is 767 bytes')* *Version* *web2py™* Version 2.7.2-stable+timestamp.2013.10.07.13.52.24 *Traceback* 1. Traceback *(*most recent call last*): *File /srv/web-apps/web2py/gluon/restricted.py*, *line 217*, in *restricted *exec *ccode *in *environment File /srv/web-apps/web2py/applications/adeploy/compiled/models/db.py*, *line 178*, in *module* *File /srv/web-apps/web2py/gluon/dal.py*, *line 7911*, in *define_tabletable *= **self.*lazy_define_table*(*tablename*,**fields*,***args*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 7948*, in *lazy_define_table polymodel*=*polymodel*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 1029*, in *create_tablefake_migrate*=*fake_migrate*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 1136*, in *migrate_table *self.*execute*(*sub_query*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 1836*, in *execute*return self.*log_execute*(**a*, ***b*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 1830*, in *log_executeret *= **self.*cursor*.*execute*(*command*, **a*[*1*:], ***b*) *File /usr/lib64/python2.6/site-packages/MySQLdb/cursors.py*, *line 173*, in *execute*self.*errorhandler*(self, *exc*, *value*) *File /usr/lib64/python2.6/site-packages/MySQLdb/connections.py*, *line 36*, in *defaulterrorhandler*raise *errorclass*, *errorvalueOperationalError*: (*1071*, *'Specified key was too long; max key length is 767 bytes'*) * *In file: /srv/web-apps/web2py/applications/adeploy/compiled/models/db.pyc* 1. **code object **module* *at 0x168c468*, *file /srv/web-apps/web2py/applications/adeploy/compiled/models/db.py*, *line 28** -- 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/groups/opt_out.
[web2py] 1071, 'Specified key was too long; max key length is 767 bytes'
Ok, I am now fighting with it for two days and it drives me crazy. My gut feeling says mysql 5.1 -- mysql 5.5 upgrade is the cause. Am I right ? And how do I solve it. :-) *Error ticket for adeploy* *Ticket ID* 192.168.2.106.2013-10-08.12-46-19.24f3f1a5-d637-4522-965b-fed4958115ed *class '_mysql_exceptions.OperationalError' (1071, 'Specified key was too long; max key length is 767 bytes')* *Version* *web2py™* Version 2.7.2-stable+timestamp.2013.10.07.13.52.24 *Traceback* 1. Traceback *(*most recent call last*): *File /srv/web-apps/web2py/gluon/restricted.py*, *line 217*, in *restricted *exec *ccode *in *environment File /srv/web-apps/web2py/applications/adeploy/compiled/models/db.py*, *line 178*, in *module* *File /srv/web-apps/web2py/gluon/dal.py*, *line 7911*, in *define_tabletable *= **self.*lazy_define_table*(*tablename*,**fields*,***args*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 7948*, in *lazy_define_table polymodel*=*polymodel*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 1029*, in *create_tablefake_migrate*=*fake_migrate*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 1136*, in *migrate_table *self.*execute*(*sub_query*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 1836*, in *execute*return self.*log_execute*(**a*, ***b*) *File /srv/web-apps/web2py/gluon/dal.py*, *line 1830*, in *log_executeret *= **self.*cursor*.*execute*(*command*, **a*[*1*:], ***b*) *File /usr/lib64/python2.6/site-packages/MySQLdb/cursors.py*, *line 173*, in *execute*self.*errorhandler*(self, *exc*, *value*) *File /usr/lib64/python2.6/site-packages/MySQLdb/connections.py*, *line 36*, in *defaulterrorhandler*raise *errorclass*, *errorvalueOperationalError*: (*1071*, *'Specified key was too long; max key length is 767 bytes'*) * *In file: /srv/web-apps/web2py/applications/adeploy/compiled/models/db.pyc* 1. **code object **module* *at 0x168c468*, *file /srv/web-apps/web2py/applications/adeploy/compiled/models/db.py*, *line 28** -- 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/groups/opt_out.
Re: [web2py] Re: [web2pyy] Mysql 2 Mongodb
On Wednesday 24 July 2013 18:34:08 Alan Etkin wrote: Note: If you are restoring data with the DAL method import_from_csv_file (not the Table class method) using id_map={}, which is the method that should be used to keep references in sync, you should not have issues keeping reference values. I have tested it with a trivial db (a few records and a list:reference table field) and it worked. AFAIK, appadmin does not provide an interface to make dumps of or loading the entire database, but it is really simple to use them in a web2py shell. BTW: I have noticed that there is a problem on database the dump method (DAL's export_to_csv_file) and filed this issue. http://code.google.com/p/web2py/issues/detail?id=1605 With that change, you should be able to move data across databases without problems (yet not preserving id values). -- Thank you very much for the help. I think I did run into that issue. And not preserving the id values is fine. If I need to have a unique identifier across databases I can add one myself that has no relation with web2py. But I doubt that that is needed. https://groups.google.com/groups/opt_out[1]. [1] https://groups.google.com/groups/opt_out -- --- 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/groups/opt_out.
[web2py] Re: [web2pyy] Mysql 2 Mongodb
On Monday 22 July 2013 05:16:56 Alan Etkin wrote: I am just playing around with mongodb and web2py I noticed that when I just make a web2py dump of my mysql db and then upload it to mongodb some of the joins now just rec id's are right and some are newly generated. Also would it be possible to keep id to be web2py specific and to use _id for mongodb ? I was wondering if it was a bug. In this case in the setup table the pointers to the frame work fine, but the pointers in the setupprofile named lparprofile do not exist anymore in the lparprofile table. # Sorry I am a bit slow, being busy. But I did upload it from csv file. So it should keep the reverences. But it did not do so for all tables. Also I concluded that because all the references are replaced by mongodb id's it is not possible to say dump a table with references in one database and then restore it on mongodb. Because you have no relation between the records anymore. You replaced the web2py id's in mongodb with mongodb id's. I am curious about the reason, would het not be smarter to just keep the original id's ? Afterall mongodb uses _id. So it does not bite. -- --- 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/groups/opt_out.
Re: [web2py] Re: [web2pyy] Mysql 2 Mongodb
On Wednesday 24 July 2013 11:52:36 Alan Etkin wrote: Also I concluded that because all the references are replaced by mongodb id's it is not possible to say dump a table with references in one database and then restore it on mongodb. Neither you can (or should) with other adapters, for example, postgres. Here's section of the book about that issue: ... In order to make a record uniquely identifiable across databases, they must: * have a unique id (UUID), * have an event_time (to figure out which one is more recent if multiple copies), * reference the UUID instead of the id. ... Agreed, but because mongodb is a nosql you could push this away to the developer. (What I am not abviously) ... Because you have no relation between the records anymore. There's a possible bug with the import feature or the mongodb adapter. Maybe you can file an issue in the project page adding as many info as possible to reproduce the problem. While changing the id numbers, the id references should be preserved between records. I am going to see if I can create a testcase to reproduce the error, maybe its because of the order of the data in db.py #I am curious about the reason, would het not be smarter to just keep the original id's ? Afterall mongodb uses _id. So it does not bite. I did so forget about that :-) Thanks for reminding me. And thanks for taking the time to answer me. Its very much appreciated. -- --- 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/groups/opt_out[1]. [1] https://groups.google.com/groups/opt_out -- --- 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/groups/opt_out.
[web2py] [web2pyy] Mysql 2 Mongodb
I am just playing around with mongodb and web2py I noticed that when I just make a web2py dump of my mysql db and then upload it to mongodb some of the joins now just rec id's are right and some are newly generated. Also would it be possible to keep id to be web2py specific and to use _id for mongodb ? I was wondering if it was a bug. In this case in the setup table the pointers to the frame work fine, but the pointers in the setupprofile named lparprofile do not exist anymore in the lparprofile table. Mike db.define_table('frame', Field('framename', type='string', unique=True, label=T('Framename')), Field('description', type='string', label=T('Description')), Field('netboot', type='string',default=None, label=T('Netboot information')), Field('ip', type='string', unique=True, label=T('IP Address')), Field('servermodel', type='string',default=p6, label=T('Server model')), Field('serial', type='string',default=None, label=T('Serial Number')), Field('lvname', type='string',default=FRAMEx, label=T('Frame extension for storage logical volumes')), Field('framestaterecord_ID', type='integer', label=T('Frame State record ID')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), format='%(framename)s', migrate=settings.migrate) # Table rules db.frame.framename.requires = IS_NOT_EMPTY() db.frame.ip.requires = IS_NOT_EMPTY() db.frame.servermodel.requires = IS_IN_SET(['p5', 'p6']) db.define_table('setup', Field('setupname', type='string', unique=True, label=T('Setup name')), Field('description', type='string', label=T('Description')), Field('frame_id', db.frame, label=T('Frame ID')), Field('course_id', db.course, label=T('Course ID')), Field('usedstorage_id', db.storageunit, label=T('Storage ID')), Field('disksetupname_id', db.disksetupname, label=T('Disk group selection ID for storage setup')), Field('nimhost_id', db.host, label=T('Nim Host ID')), Field('hmchost_id', db.host, label=T('HMC Host ID')), Field('ready', type='boolean', default=False, label=T('Ready for use')), Field('nostorage', type='boolean', default=False, label=T('No storage needed')), Field('noprofiles', type='boolean', default=False, label=T('No profiles needed')), Field('nonim', type='boolean', default=False, label=T('No nim actions needed')), Field('securitylevel', type='integer', default=0, label=T('Security Level')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), format='%(setupname)s', migrate=settings.migrate) # Table rules for setup db.setup.setupname.requires = IS_NOT_EMPTY() db.setup.frame_id.requires = IS_IN_DB(db, 'frame.id', 'frame.framename') db.setup.course_id.requires = IS_IN_DB(db, 'course.id', 'course.coursename') db.setup.usedstorage_id.requires = IS_IN_DB(db, 'storageunit.id', 'storageunit.storagename') db.setup.nimhost_id.requires = IS_IN_DB(db, 'host.id', 'host.hostname') db.setup.hmchost_id.requires = IS_IN_DB(db, 'host.id', 'host.hostname') db.setup.disksetupname_id.requires = IS_IN_DB(db, 'disksetupname.id', 'disksetupname.disksetupnamedesc') db.define_table('setupprofile', Field('setup_id', db.setup, label=T('Setup ID')), Field('frame_id', db.frame, default=5, label=T('Frame ID')), Field('lparprofile_id', db.lparprofile, label=T('Profile ID')), Field('seq','integer', label=T('Deployment Sequence')), migrate=settings.migrate) # table rules for setup profile db.setupprofile.seq.requires = IS_INT_IN_RANGE(1, 300) db.setupprofile.setup_id.requires = IS_IN_DB(db, 'setup.id', 'setup.setupname') db.setupprofile.lparprofile_id.requires = IS_IN_DB(db, 'lparprofile.id', 'lparprofile.lparname') db.setupprofile.frame_id.requires = IS_IN_DB(db, 'frame.id', 'frame.framename') -- --- 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/groups/opt_out.
[web2py] Mongodb error in appadmin
The action I have a table/collection with 3 objects In the table this is reverenced as Field('host_id', mdb.hoststable, comment=Like nim or hmc server., label=T('Destination Host ID')), But when in appadmin I select a other object to change then it throws a error. The error Ticket ID 127.0.0.1.2013-03-21.15-46-39.9f2786b5-d69c-4e31-a6c9-dd76f3692e59 type 'exceptions.RuntimeError' uncaught exception when updating rows: MongoDB can only handle up to 8-byte ints Version web2py^(TM) Version 2.4.5-stable+timestamp.2013.03.18.22.46.22 Python Python 2.7.3: /usr/bin/python2.7 (prefix: /usr) Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. Traceback (most recent call last): File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/applications/adeploy/compiled/controllers_appadmin_update.py, line 410, in module File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/globals.py, line 194, in lambda self._caller = lambda f: f() File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/applications/adeploy/compiled/controllers_appadmin_update.py, line 277, in update File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/sqlhtml.py, line 1527, in accepts self.id_field_name]).update(**fields) File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/dal.py, line 9834, in update ret = db._adapter.update(tablename,self.query,fields) File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/dal.py, line 5450, in update raise RuntimeError(uncaught exception when updating rows: %s % e) RuntimeError: uncaught exception when updating rows: MongoDB can only handle up to 8-byte ints -- --- 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/groups/opt_out.
[web2py] Mongodb error in appadmin
Created the following table mdb.define_table('syscommands', Field('commandname', type='string', unique=True, label=T('Commandname')), Field('commandline', type='string', label=T('Command')), Field('host_id', mdb.hoststable, comment=Like nim or hmc server., label=T('Destination Host ID')), Field('description', type='string', label=T('Description')), Field('fase','string', comment=Fase 1 is storage, Fase 2 is Profile Creation, Fase 3 is VIO deployment, Fase 4 is Lpar deployment.., label=T('Fase')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), format='%(commandname)s', migrate=settings.migrate) # Table rules for command mdb.syscommands.fase.requires = IS_IN_SET(['1', '2', '3', '4']) #mdb.syscommands.host_id.requires = IS_NOT_EMPTY() mdb.syscommands.commandname.requires = IS_NOT_EMPTY() mdb.syscommands.host_id.requires = IS_IN_DB(mdb, 'hoststable.id', 'hoststable.hostname') mdb.syscommands.commandline.requires = IS_NOT_EMPTY() it revers to this table mdb.define_table('hoststable', Field('hostname', type='string', unique=True, label=T('Hostname')), Field('description', type='string', label=T('Description')), Field('netboot', type='string', label=T('Netboot information')), Field('ip', type='string', default='192.168.1.x', label=T('IP Address')), Field('connectcmd', type='string', default='ssh', label=T('Connection command')), Field('useraccount', type='string', default='root', label=T('Default User')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), format='%(hostname)s', migrate=settings.migrate) # Table Hosts rules mdb.hoststable.hostname.requires = IS_NOT_EMPTY() mdb.hoststable.ip.requires = IS_NOT_EMPTY() Then when I create a record in appadmin and after that change this item It throws this error. Ticket ID 127.0.0.1.2013-03-21.17-03-38.3cfba30b-5706-4bdb-af50-faa6be3ed179 type 'exceptions.RuntimeError' uncaught exception when updating rows: MongoDB can only handle up to 8-byte ints Version web2py^(TM) Version 2.4.5-stable+timestamp.2013.03.18.22.46.22 Python Python 2.7.3: /usr/bin/python2.7 (prefix: /usr) Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. Traceback (most recent call last): File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/applications/adeploy/compiled/controllers_appadmin_update.py, line 410, in module File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/globals.py, line 194, in lambda self._caller = lambda f: f() File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/applications/adeploy/compiled/controllers_appadmin_update.py, line 277, in update File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/sqlhtml.py, line 1527, in accepts self.id_field_name]).update(**fields) File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/dal.py, line 9834, in update ret = db._adapter.update(tablename,self.query,fields) File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/dal.py, line 5450, in update raise RuntimeError(uncaught exception when updating rows: %s % e) RuntimeError: uncaught exception when updating rows: MongoDB can only handle up to 8-byte ints -- --- 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/groups/opt_out.
Re: [web2py] Mongodb error in appadmin
Op 21-03-13 17:50, Niphlod schreef: seems to me that a lot of people are interested in using mongodb but really few are contributing back with tests and patches. BTW: you DO know that Mongo generally doesn't play well with joins, right ? Using references in mongodb is not a smart design. Mongodb as far as I know does not have joins :) But it did accept it, so I decided to post the error. But this is mysql database design that I did put over 1 on 1 I have to redo the database design to be nicer to Mongo (I am just looking up to the conversion, even though I now have both databases so its just a matter of writing a copy and past program after I created the new database structure in mongo) . I would love to have some pointers about how though define mongo in db.py in a proper nosql way. Thanks for the remark btw :) -- --- 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/groups/opt_out. -- --- 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/groups/opt_out.
Re: [web2py] Mongodb error in appadmin
On 03/21/2013 08:06 PM, Alan Etkin wrote: I would love to have some pointers about how though define mongo in db.py in a proper nosql way. Could you open an issue at the project page? Done :-) Issue 1401 https://code.google.com/p/web2py/issues/detail?id=1401: Mongodb error in appadmin If more info needed or some testing is needed just ask. I will play with mongo and web2py anyway. If you can, please provide: - The relevant part of the model - A possible set of data which would reproduce the error - Your mongodb driver, database server, web2py and Python versions The MongoDB DAL adapter does some automatic type mapping for id fields. I belive the issue could be realted to that. -- --- 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/groups/opt_out. -- --- 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/groups/opt_out.
[web2py] Mongodb and db.py
Hello People, I am looking into converting my mysql database setup into a mongodb and I was wondering about how at the moment db.py does translate the tables. Because I would like to have some control/understanding about it. --
Re: [web2py] Adding a copy option to a SQLFORM.grid
On 04/12/2012 01:08 PM, Mike Veltman wrote: Well I would like to have besides edit delete etc in my SQLFORM.grid also a copy option that copies the record and then gives me the edit so I can modify it. Anyone a idea how to do that ? Mike Aha I have to use links (RTFM) Does anybody have a example of the link and the called function for me ?
Re: [web2py] Adding a copy option to a SQLFORM.grid
ok I used this in the end :) links = [lambda row: A('Copy',_href=URL(formdb,copy_profile,args=[row.id]))] @auth.requires_login() def copy_profile(): record = db.lparprofile(request.args[0]) vals = {} for k,v in record.items(): if k in db.lparprofile.fields: if k == 'lparname': v = v + _copy recname = str(v) # Needed to redirect the page to the right record if k != 'id': vals[k] = v db.lparprofile.insert(**vals) rec = db(db.lparprofile.lparname == recname).select().first() rec_id = rec.id redirect(URL(r=request, f='manage_profile',args=str(rec_id))) return Problem solved :-) On 04/12/2012 03:19 PM, Mike Veltman wrote: On 04/12/2012 01:08 PM, Mike Veltman wrote: Well I would like to have besides edit delete etc in my SQLFORM.grid also a copy option that copies the record and then gives me the edit so I can modify it. Anyone a idea how to do that ? Mike Aha I have to use links (RTFM) Does anybody have a example of the link and the called function for me ?
[web2py] Adding a copy option to a SQLFORM.grid
Well I would like to have besides edit delete etc in my SQLFORM.grid also a copy option that copies the record and then gives me the edit so I can modify it. Anyone a idea how to do that ? Mike
Re: [web2py] SQLFORM.grid not doing what I want :)
I guessed it was something like that :-) Thanks Massimo I am going to test it. On 03/30/2012 10:51 AM, Massimo Di Pierro wrote: You have to pass it SQLFORM.grid(...,field_id=db.lvdisksetup.id,) else it does not know what table to use. On Thursday, 29 March 2012 19:58:52 UTC-5, Gwayne aka Mike Veltman wrote: On 03/30/2012 12:01 AM, Massimo Di Pierro wrote: When you say I want to manipulate db.lvdisksetup but in stead it manipulates db.lvdisk what do you mean by manipulates? That when I delete a record or do add a record it gives me the db.lvdisk table and not the db.lvdisksetup table. So I delete or add a record that is supposed to be a reverence. On Wednesday, 28 March 2012 22:58:31 UTC-5, Gwayne aka Mike Veltman wrote: Gentle people, I have the following grid: query = ( (db.lvdisksetup.lvgroupname_id == usedlvdisksetup) (db.lvgroupname.id http://db.lvgroupname.id == usedlvdisksetup) (db.lvdisksetup.lvdisk_id == db.lvdisk.id http://db.lvdisk.id) ) fields = [db.lvdisksetup.id http://db.lvdisksetup.id, db.lvgroupname.lvgroupnamedesc , db.lvdisk.lvdiskdesc, db.lvdisksetup.lunid] form = SQLFORM.grid(query, fields=fields, orderby=['lvdisksetup.lunid'], csv=False, create = False, maxtextlength=45 ) I want to manipulate db.lvdisksetup but in stead it manipulates db.lvdisk :-) What causes havoc by deleting essential table data :) Part of the db models :) # All the LV sizes will be collected in here in bytes, like 30GB, 10GB, 2GB etc db.define_table('lvsize', Field('sizename', type='string', unique=True, label=T('Lun Size')), Field('size', type='string', label=T('LV Size in bytes')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # The LV Disk groups db.define_table('lvgroupname', Field('lvgroupnamedesc', type='string', unique=True, label=T('LV Disk Groupname ')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvgroupname.lvgroupnamedesc.requires = IS_NOT_EMPTY() # Logical volume on storage db.define_table('lvdisk', Field('lvdiskdesc', type='string', unique=True, label=T('LV Disk description ')), Field('lvsize_id', db.lvsize, default=2, label=T('Size ID')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvdisk.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id http://lvsize.id', 'lvsize.sizename') db.lvdisk.lvdiskdesc.requires = IS_NOT_EMPTY() # lvdisksetup db.define_table('lvdisksetup', Field('lvdisk_id', db.lvdisk, default=1, label=T('Logical volume to be added')), Field('lvgroupname_id', db.lvgroupname, default=1, label=T('Member of Logical volume group name')), Field('lunid', type='integer', default=2, label=T('Lun ID')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvdisksetup.lvdisk_id.requires = IS_IN_DB(db, 'lvdisk.id http://lvdisk.id', 'lvdisk.lvdiskdesc') db.lvdisksetup.lvgroupname_id.requires = IS_IN_DB(db, 'lvgroupname.id http://lvgroupname.id', 'lvgroupname.lvgroupnamedesc') # hbahostgroupsetup (to add the right disks to a hba or a hostgroup
Re: [web2py] SQLFORM.grid not doing what I want :)
After testing form = SQLFORM.grid(query, fields=fields, field_id=db.lvdisksetup.id, --- orderby=['lvdisksetup.lunid'], csv=False, create = True, maxtextlength=45 ) It worked like a charm, its really great Massimo. Thanks On 03/30/2012 03:55 PM, Mike Veltman wrote: I guessed it was something like that :-) Thanks Massimo I am going to test it. On 03/30/2012 10:51 AM, Massimo Di Pierro wrote: You have to pass it SQLFORM.grid(...,field_id=db.lvdisksetup.id,) else it does not know what table to use. On Thursday, 29 March 2012 19:58:52 UTC-5, Gwayne aka Mike Veltman wrote: On 03/30/2012 12:01 AM, Massimo Di Pierro wrote: When you say I want to manipulate db.lvdisksetup but in stead it manipulates db.lvdisk what do you mean by manipulates? That when I delete a record or do add a record it gives me the db.lvdisk table and not the db.lvdisksetup table. So I delete or add a record that is supposed to be a reverence. On Wednesday, 28 March 2012 22:58:31 UTC-5, Gwayne aka Mike Veltman wrote: Gentle people, I have the following grid: query = ( (db.lvdisksetup.lvgroupname_id == usedlvdisksetup) (db.lvgroupname.id http://db.lvgroupname.id == usedlvdisksetup) (db.lvdisksetup.lvdisk_id == db.lvdisk.id http://db.lvdisk.id) ) fields = [db.lvdisksetup.id http://db.lvdisksetup.id, db.lvgroupname.lvgroupnamedesc , db.lvdisk.lvdiskdesc, db.lvdisksetup.lunid] form = SQLFORM.grid(query, fields=fields, orderby=['lvdisksetup.lunid'], csv=False, create = False, maxtextlength=45 ) I want to manipulate db.lvdisksetup but in stead it manipulates db.lvdisk :-) What causes havoc by deleting essential table data :) Part of the db models :) # All the LV sizes will be collected in here in bytes, like 30GB, 10GB, 2GB etc db.define_table('lvsize', Field('sizename', type='string', unique=True, label=T('Lun Size')), Field('size', type='string', label=T('LV Size in bytes')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # The LV Disk groups db.define_table('lvgroupname', Field('lvgroupnamedesc', type='string', unique=True, label=T('LV Disk Groupname ')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvgroupname.lvgroupnamedesc.requires = IS_NOT_EMPTY() # Logical volume on storage db.define_table('lvdisk', Field('lvdiskdesc', type='string', unique=True, label=T('LV Disk description ')), Field('lvsize_id', db.lvsize, default=2, label=T('Size ID')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvdisk.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id http://lvsize.id', 'lvsize.sizename') db.lvdisk.lvdiskdesc.requires = IS_NOT_EMPTY() # lvdisksetup db.define_table('lvdisksetup', Field('lvdisk_id', db.lvdisk, default=1, label=T('Logical volume to be added')), Field('lvgroupname_id', db.lvgroupname, default=1, label=T('Member of Logical volume group name')), Field('lunid', type='integer', default=2, label=T('Lun ID')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate
Re: [web2py] SQLFORM.grid not doing what I want :)
On 03/30/2012 12:01 AM, Massimo Di Pierro wrote: When you say I want to manipulate db.lvdisksetup but in stead it manipulates db.lvdisk what do you mean by manipulates? That when I delete a record or do add a record it gives me the db.lvdisk table and not the db.lvdisksetup table. So I delete or add a record that is supposed to be a reverence. On Wednesday, 28 March 2012 22:58:31 UTC-5, Gwayne aka Mike Veltman wrote: Gentle people, I have the following grid: query = ( (db.lvdisksetup.lvgroupname_id == usedlvdisksetup) (db.lvgroupname.id http://db.lvgroupname.id == usedlvdisksetup) (db.lvdisksetup.lvdisk_id == db.lvdisk.id http://db.lvdisk.id) ) fields = [db.lvdisksetup.id http://db.lvdisksetup.id, db.lvgroupname.lvgroupnamedesc , db.lvdisk.lvdiskdesc, db.lvdisksetup.lunid] form = SQLFORM.grid(query, fields=fields, orderby=['lvdisksetup.lunid'], csv=False, create = False, maxtextlength=45 ) I want to manipulate db.lvdisksetup but in stead it manipulates db.lvdisk :-) What causes havoc by deleting essential table data :) Part of the db models :) # All the LV sizes will be collected in here in bytes, like 30GB, 10GB, 2GB etc db.define_table('lvsize', Field('sizename', type='string', unique=True, label=T('Lun Size')), Field('size', type='string', label=T('LV Size in bytes')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # The LV Disk groups db.define_table('lvgroupname', Field('lvgroupnamedesc', type='string', unique=True, label=T('LV Disk Groupname ')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvgroupname.lvgroupnamedesc.requires = IS_NOT_EMPTY() # Logical volume on storage db.define_table('lvdisk', Field('lvdiskdesc', type='string', unique=True, label=T('LV Disk description ')), Field('lvsize_id', db.lvsize, default=2, label=T('Size ID')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvdisk.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id http://lvsize.id', 'lvsize.sizename') db.lvdisk.lvdiskdesc.requires = IS_NOT_EMPTY() # lvdisksetup db.define_table('lvdisksetup', Field('lvdisk_id', db.lvdisk, default=1, label=T('Logical volume to be added')), Field('lvgroupname_id', db.lvgroupname, default=1, label=T('Member of Logical volume group name')), Field('lunid', type='integer', default=2, label=T('Lun ID')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvdisksetup.lvdisk_id.requires = IS_IN_DB(db, 'lvdisk.id http://lvdisk.id', 'lvdisk.lvdiskdesc') db.lvdisksetup.lvgroupname_id.requires = IS_IN_DB(db, 'lvgroupname.id http://lvgroupname.id', 'lvgroupname.lvgroupnamedesc') # hbahostgroupsetup (to add the right disks to a hba or a hostgroup) db.define_table('hbahostgroupsetup', Field('hbahgdesc', type='string', label=T('LV Disk setup Description ')), Field('lvgroupname_id', db.lvgroupname, default=1, label=T('LV Disk')), Field('mapping_id', db.storagemap, default=1, label=T('HBA or Hostgroup mapping')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules
[web2py] SQLFORM.grid not doing what I expect
Gentle people, I have the following grid: query = ( (db.lvdisksetup.lvgroupname_id == usedlvdisksetup) (db.lvgroupname.id == usedlvdisksetup) (db.lvdisksetup.lvdisk_id == db.lvdisk.id) ) fields = [db.lvdisksetup.id, db.lvgroupname.lvgroupnamedesc , db.lvdisk.lvdiskdesc, db.lvdisksetup.lunid] form = SQLFORM.grid(query, fields=fields, orderby=['lvdisksetup.lunid'], csv=False, create = False, maxtextlength=45 ) I want to manipulate db.lvdisksetup but in stead it manipulates db.lvdisk :-) What causes havoc by deleting essential table data :)
[web2py] SQLFORM.grid not doing what I want :)
Gentle people, I have the following grid: query = ( (db.lvdisksetup.lvgroupname_id == usedlvdisksetup) (db.lvgroupname.id == usedlvdisksetup) (db.lvdisksetup.lvdisk_id == db.lvdisk.id) ) fields = [db.lvdisksetup.id, db.lvgroupname.lvgroupnamedesc , db.lvdisk.lvdiskdesc, db.lvdisksetup.lunid] form = SQLFORM.grid(query, fields=fields, orderby=['lvdisksetup.lunid'], csv=False, create = False, maxtextlength=45 ) I want to manipulate db.lvdisksetup but in stead it manipulates db.lvdisk :-) What causes havoc by deleting essential table data :) Part of the db models :) # All the LV sizes will be collected in here in bytes, like 30GB, 10GB, 2GB etc db.define_table('lvsize', Field('sizename', type='string', unique=True, label=T('Lun Size')), Field('size', type='string', label=T('LV Size in bytes')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # The LV Disk groups db.define_table('lvgroupname', Field('lvgroupnamedesc', type='string', unique=True, label=T('LV Disk Groupname ')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvgroupname.lvgroupnamedesc.requires = IS_NOT_EMPTY() # Logical volume on storage db.define_table('lvdisk', Field('lvdiskdesc', type='string', unique=True, label=T('LV Disk description ')), Field('lvsize_id', db.lvsize, default=2, label=T('Size ID')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvdisk.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id', 'lvsize.sizename') db.lvdisk.lvdiskdesc.requires = IS_NOT_EMPTY() # lvdisksetup db.define_table('lvdisksetup', Field('lvdisk_id', db.lvdisk, default=1, label=T('Logical volume to be added')), Field('lvgroupname_id', db.lvgroupname, default=1, label=T('Member of Logical volume group name')), Field('lunid', type='integer', default=2, label=T('Lun ID')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvdisksetup.lvdisk_id.requires = IS_IN_DB(db, 'lvdisk.id', 'lvdisk.lvdiskdesc') db.lvdisksetup.lvgroupname_id.requires = IS_IN_DB(db, 'lvgroupname.id', 'lvgroupname.lvgroupnamedesc') # hbahostgroupsetup (to add the right disks to a hba or a hostgroup) db.define_table('hbahostgroupsetup', Field('hbahgdesc', type='string', label=T('LV Disk setup Description ')), Field('lvgroupname_id', db.lvgroupname, default=1, label=T('LV Disk')), Field('mapping_id', db.storagemap, default=1, label=T('HBA or Hostgroup mapping')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.hbahostgroupsetup.lvgroupname_id.requires = IS_IN_DB(db, 'lvgroupname.id', 'lvdisk.lvgroupnamedesc') db.hbahostgroupsetup.mapping_id.requires = IS_IN_DB(db, 'storagemap.id', 'storagemap.mapping') db.hbahostgroupsetup.hbahgdesc.requires = IS_NOT_EMPTY() # disksetupname (to make it possible to have the same lv setup for different class setups) db.define_table('disksetupname', Field('disksetupnamedesc', type='string', label=T('LV Disk group selection description ')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.disksetupname.disksetupnamedesc.requires = IS_NOT_EMPTY() # hbahggroup db.define_table('hbahggroup', Field('hbahostgroupsetup_id', db.hbahostgroupsetup,
Re: [web2py] Re: A SQLFORM.grid question
I am wondering about that. mmm On 11/03/2011 10:53 PM, apple wrote: My mistake. I tend to redirect because I need some extra processing but grid does actually produce a basic edit form. If you do use the grid generated form then the submit should work as normal though. You should check where it is failing - e.g. when you press submit is it actually calling the controller? On Nov 3, 2:16 am, Mike Veltmanmike.velt...@gmail.com wrote: Now I think of it, you do not need to do a redirect because it creates its own page based on the called page. Its just that the submit does not do anything. SQLFORM.grid does not actually add the records automatically. It just calls the grid controller with args action/table. You have to do something like: if request.args(0) in (edit, new): redirect(URL(edit.html, args=[request.args(1), request.args(2)]) On Nov 2, 9:15 am, Mike Veltmanmike.velt...@gmail.com wrote: are you able to see the form? or are you getting the not authorized message? you can set user_signature=False or ensure that user is logged in. Thanks for the reaction. But no the form is generated perfectly. And the user is logged in. On Wed, Nov 2, 2011 at 6:50 AM, Mike Veltmanmike.velt...@gmail.com wrote: I have grid = SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,detai ls=T rue,searchable=True) That creates a form with the records with a add button. But when I use add I get the next screen but the record is not added. What do I miss ? Btw is the same setup with a query possible with SQLFORM.smartgrid ? With regards, Mike Veltman With regards, Mike Veltman With regards, Mike Veltman
Re: [web2py] Re: A SQLFORM.grid question
First thank you for the help, its really appreciated. Well, I create setup's for deployments of systems. :) My goal is: 1) To have a view that does not show the id's but the names of the joins 2) To be able to add a new record preferable with as defaults the same lvsize_id, and storagemap_id and the last lun_id +1 This is the first time I use the SQLFORM.grid and/or smartgrid. This form creates a view that shows the harddisk/logical volume sizes that have to be created on the storage. First I select the setup -- @auth.requires_login() def modify_lvstorage_select(): form = SQLFORM.factory( Field('setup', requires=IS_IN_DB(db(), db.setup.id, '%(setupname)s', zero=None)) ) if form.accepts(request.vars, session, keepvalues=True): session.modify_lvstorage_select = form.vars.setup redirect(URL(r=request, f='modify_lvstorage')) return dict(form=form) - Then with this information I create a grid view. Here you should be able to add records or modify records. @auth.requires_login() def modify_lvstorage(): usedsetupid = session.modify_lvstorage_select left = (db.lvsize.on(db.lvstorage.lvsize_id==db.lvsize.id),db.storagemap.on(db.lvstorage.storagemap_id==db.storagemap.id),db.setup.on(db.lvstorage.setup_id==db.setup.id)) columns = ['lvstorage.setup_id','lvstorage.storagemap_id','lvstorage.lvsize_id','lvstorage.lunid'] query = db.lvstorage.setup_id==usedsetupid grid = SQLFORM.grid(query, left = left, columns = columns, orderby = ['lvstorage.lunid'], csv = False ) return dict(usedsetupid=usedsetupid, grid=grid) --- The DB setting --- # Logical volume on storage db.define_table('lvstorage', Field('setup_id', db.setup, default=1, label=T('Setup ID')), Field('lvsize_id', db.lvsize, default=2, label=T('Size ID')), Field('lunid', type='integer', default=2, label=T('Lun ID')), Field('storagemap_id', db.storagemap, default=1, label=T('Host Group')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvstorage.setup_id.requires = IS_IN_DB(db, 'setup.id', 'setup.setupname') db.lvstorage.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id', 'lvsize.sizename') db.lvstorage.storagemap_id.requires = IS_IN_DB(db, 'storagemap.id', 'storagemap.mapping') Mike If you post some of the details of your app I'm happy to look at it. I'm using SQLFORM.smartgrid extensively and it is working really well for me. -Jim On 11/2/2011 10:47 PM, Mike Veltman wrote: Now I am even more confused :) Sorry for being a nagging person. Why does SQLFORM.grid display the name (as I want) in the setupid column, but not display the name on Size ID or hostgroup. ? Id http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage?keywords=order=lv storage.id_signature=8dbb920c257181ac6fc35485619f4345c246c296 Setup ID http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage?keywords=order=lv storage.setup_id_signature=a0a4d78cba448c29fc27a1706b56da0f45ccfba2 Size ID http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage?keywords=order=lv storage.lvsize_id_signature=95b25e5d3ea2df3c36319851611869e9185708aa Lun ID http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage?keywords=order=lv storage.lunid_signature=7153b8a143e74e602bda43f31123a9606e21e24f Host Group http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage?keywords=order=lv storage.storagemap_id_signature=eeb802acefa7a18bbd87fbda8f3d690578769d7e 1 AN10 on frame 520-1 2 2 7 View http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage/view/lvstorage/1?_ signature=145034e485ba2811bdd12f874e26cfe9144ce779Edit http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage/edit/lvstorage/1? _signature=8de6c80354940b970b0af5f4c88e7a2f3e8f838cDelete http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage#null 2 AN10 on frame 520-1 2 3 7 View http://127.0.0.1:8000/adeploy/formdb
[web2py] A SQLFORM.grid question
I have grid = SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,details=True,searchable=True) That creates a form with the records with a add button. But when I use add I get the next screen but the record is not added. What do I miss ? Btw is the same setup with a query possible with SQLFORM.smartgrid ? With regards, Mike Veltman
Re: [web2py] A SQLFORM.grid question
are you able to see the form? or are you getting the not authorized message? you can set user_signature=False or ensure that user is logged in. Thanks for the reaction. But no the form is generated perfectly. And the user is logged in. On Wed, Nov 2, 2011 at 6:50 AM, Mike Veltman mike.velt...@gmail.com wrote: I have grid = SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,details=T rue,searchable=True) That creates a form with the records with a add button. But when I use add I get the next screen but the record is not added. What do I miss ? Btw is the same setup with a query possible with SQLFORM.smartgrid ? With regards, Mike Veltman With regards, Mike Veltman
Re: [web2py] Re: A SQLFORM.grid question
Actually that makes a lot of sense. It got caught of guard because edit does do it. But with this you also answered my other question, how to change the default values in edit. :-) Thanks ! SQLFORM.grid does not actually add the records automatically. It just calls the grid controller with args action/table. You have to do something like: if request.args(0) in (edit, new): redirect(URL(edit.html, args=[request.args(1), request.args(2)]) On Nov 2, 9:15 am, Mike Veltman mike.velt...@gmail.com wrote: are you able to see the form? or are you getting the not authorized message? you can set user_signature=False or ensure that user is logged in. Thanks for the reaction. But no the form is generated perfectly. And the user is logged in. On Wed, Nov 2, 2011 at 6:50 AM, Mike Veltman mike.velt...@gmail.com wrote: I have grid = SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,detai ls=T rue,searchable=True) That creates a form with the records with a add button. But when I use add I get the next screen but the record is not added. What do I miss ? Btw is the same setup with a query possible with SQLFORM.smartgrid ? With regards, Mike Veltman With regards, Mike Veltman With regards, Mike Veltman
Re: [web2py] Re: A SQLFORM.grid question
Now I think of it, you do not need to do a redirect because it creates its own page based on the called page. Its just that the submit does not do anything. SQLFORM.grid does not actually add the records automatically. It just calls the grid controller with args action/table. You have to do something like: if request.args(0) in (edit, new): redirect(URL(edit.html, args=[request.args(1), request.args(2)]) On Nov 2, 9:15 am, Mike Veltman mike.velt...@gmail.com wrote: are you able to see the form? or are you getting the not authorized message? you can set user_signature=False or ensure that user is logged in. Thanks for the reaction. But no the form is generated perfectly. And the user is logged in. On Wed, Nov 2, 2011 at 6:50 AM, Mike Veltman mike.velt...@gmail.com wrote: I have grid = SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,detai ls=T rue,searchable=True) That creates a form with the records with a add button. But when I use add I get the next screen but the record is not added. What do I miss ? Btw is the same setup with a query possible with SQLFORM.smartgrid ? With regards, Mike Veltman With regards, Mike Veltman With regards, Mike Veltman
Re: [web2py] Re: A SQLFORM.grid question
Now I am even more confused :) Sorry for being a nagging person. Why does SQLFORM.grid display the name (as I want) in the setupid column, but not display the name on Size ID or hostgroup. ? Id Setup ID Size ID Lun ID Host Group 1 AN10 on frame 520-1 2 2 7 ViewEditDelete 2 AN10 on frame 520-1 2 3 7 ViewEditDelete 3 AN10 on frame 520-1 2 4 7 ViewEditDelete The database table db.define_table('lvstorage', Field('setup_id', db.setup, default=1, label=T('Setup ID')), Field('lvsize_id', db.lvsize, default=2, label=T('Size ID')), Field('lunid', type='integer', default=2, label=T('Lun ID')), Field('storagemap_id', db.storagemap, default=1, label=T('Host Group')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvstorage.setup_id.requires = IS_IN_DB(db, 'setup.id', 'setup.setupname') db.lvstorage.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id', 'lvsize.sizename') db.lvstorage.storagemap_id.requires = IS_IN_DB(db, 'storagemap.id', 'storagemap.mapping') Controller left = (db.lvsize.on(db.lvstorage.lvsize_id==db.lvsize.id),db.storagemap.on(db.lvstorage.storagemap_id==db.storagemap.id),db.setup.on(db.lvstorage.setup_id==db.setup.id)) query = db.lvstorage.setup_id==usedsetupid grid = SQLFORM.grid(query, left = left, csv = False ) return dict(usedsetupid=usedsetupid, grid=grid) Now I think of it, you do not need to do a redirect because it creates its own page based on the called page. Its just that the submit does not do anything. SQLFORM.grid does not actually add the records automatically. It just calls the grid controller with args action/table. You have to do something like: if request.args(0) in (edit, new): redirect(URL(edit.html, args=[request.args(1), request.args(2)]) On Nov 2, 9:15 am, Mike Veltman mike.velt...@gmail.com wrote: are you able to see the form? or are you getting the not authorized message? you can set user_signature=False or ensure that user is logged in. Thanks for the reaction. But no the form is generated perfectly. And the user is logged in. On Wed, Nov 2, 2011 at 6:50 AM, Mike Veltman mike.velt...@gmail.com wrote: I have grid = SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,det ai ls=T rue,searchable=True) That creates a form with the records with a add button. But when I use add I get the next screen but the record is not added. What do I miss ? Btw is the same setup with a query possible with SQLFORM.smartgrid ? With regards, Mike Veltman With regards, Mike Veltman With regards, Mike Veltman With regards, Mike Veltman
Re: [web2py] Re: Hide menu until after authentication.
I actually totally overlooked that it was placed in layout.html Thanks everybody for the information. I learned a lot again. With regards, Mike Veltman
Re: [web2py] Hide menu until after authentication.
On Friday, October 21, 2011 2:05:29 AM UTC-4, Gwayne aka Mike Veltman wrote: Gentle people, First a remark I started playing with SQLFORM.grid and it was very ugly, until I did throw away my application and recreated it with the wizard, and then it was fine. ;-) Along with SQLFORM.grid, the 'welcome' app was updated with some new CSS in base.css to style the grid. If you add a grid to an older app without updating the CSS, it probably won't look right. Creating a new app (with the wizard or otherwise) will use the new CSS, so should look fine. You can find the new grid-related CSS at the bottom of base.css and copy it into the CSS file of your older app to get the grid to display properly. Anthony Well, it looks very good now. Thanks for the information. With regards, Mike Veltman
[web2py] What I do with web2py.
I actually would like to know what people basically build with web2py. Not the details but globally. For me I am a IT Trainer, training people in the use of IBM hard and software like AIX and GPFS. So for me my itch was that I needed to create a new setup for each training. What involved the following steps. Remove the old class virtual machines from the power hardware, Remove all the assigned storage Create all the virtual machines on the power hardware Create all the storage and assign it to right fibre cards Assign all the resources to the virtual machines from a installation server Netboot the virtual machines and install the machines. I made with web2py (and much help of the community) the frontend and database interaction to accomplish this. Thus making it possible for me to go home while the new class is being deployed. What do other people with it ? With regards, Mike Veltman
[web2py] Hide menu until after authentication.
Gentle people, First a remark I started playing with SQLFORM.grid and it was very ugly, until I did throw away my application and recreated it with the wizard, and then it was fine. ;-) Second, I would like my response.menu to show up after authentication. What is the most elegant way of doing that ? Thanks in advance. With regards, Mike Veltman
Re: [web2py] Re: Hide menu until after authentication.
Thanks Annet, Yes I was thinking about it. But that means that I have to remove the menu.py out of the models and place it in each view individually. Thanks for the answer btw. Hi Mike, In the corresponding view you could do: {{if auth.is_logged_in():}} {{=MENU(response.menu)}} {{pass}} Kind regards, Annet. With regards, Mike Veltman
Re: [web2py] Re: Threads :-)
I found the solution, I was making it too complicated. Thank you for indirectly solving my problem. I moved the whol stuff to the cron job and make the frontend lean and mean. So no need anymore for threads the frontend. One question. when I run web2py in a cronjob can I use thread there ? Or is it also connected to the webserver ? Thanks for the response, There are two problems: - do not do print, breaks mod_wsgi - do not start threads from an action because the threads are controller by the web server and it may kill it. Good warnings. you should queue the task in database or cache and then run a background task Well actually its function is to queue tasks in redis so a cronjob can excute it. Well it seems I get errors while accessing the database File gluon/contrib/pymysql/connections.py, line 184, in defaulterrorhandler raise errorclass, errorvalue gluon.contrib.pymysql.err.InterfaceError: (0, '') . If pushing data to redis takes too long it defies the purpose of using redis. Well its collecting the data and combining it in redis that takes time. On Oct 9, 11:22 pm, Mike Veltman mike.velt...@gmail.com wrote: Ok, I need to push data in a redis database. And my problem is that it takes a while while the data is pushed in. So the screen would be waiting and a user would be irritated. My solution would be something like this. if framequeue.check_frame_lock() == False: if session.deployment == True: pass else: import thread print session.deployment print Running deployment thread.start_new_thread(default_frame_deployment,()) So the thread is running in the background and the page displays the log. But then I get gluon (database) errors in the functions. Any idea's or is there a better/ more elegant solution to this problem ? With regards, Mike Veltman With regards, Mike Veltman With regards, Mike Veltman
[web2py] Threads :-)
Ok, I need to push data in a redis database. And my problem is that it takes a while while the data is pushed in. So the screen would be waiting and a user would be irritated. My solution would be something like this. if framequeue.check_frame_lock() == False: if session.deployment == True: pass else: import thread print session.deployment print Running deployment thread.start_new_thread(default_frame_deployment,()) So the thread is running in the background and the page displays the log. But then I get gluon (database) errors in the functions. Any idea's or is there a better/ more elegant solution to this problem ? With regards, Mike Veltman
Re: [web2py] Re: Threads :-)
Thanks for the response, There are two problems: - do not do print, breaks mod_wsgi - do not start threads from an action because the threads are controller by the web server and it may kill it. Good warnings. you should queue the task in database or cache and then run a background task Well actually its function is to queue tasks in redis so a cronjob can excute it. Well it seems I get errors while accessing the database File gluon/contrib/pymysql/connections.py, line 184, in defaulterrorhandler raise errorclass, errorvalue gluon.contrib.pymysql.err.InterfaceError: (0, '') . If pushing data to redis takes too long it defies the purpose of using redis. Well its collecting the data and combining it in redis that takes time. On Oct 9, 11:22 pm, Mike Veltman mike.velt...@gmail.com wrote: Ok, I need to push data in a redis database. And my problem is that it takes a while while the data is pushed in. So the screen would be waiting and a user would be irritated. My solution would be something like this. if framequeue.check_frame_lock() == False: if session.deployment == True: pass else: import thread print session.deployment print Running deployment thread.start_new_thread(default_frame_deployment,()) So the thread is running in the background and the page displays the log. But then I get gluon (database) errors in the functions. Any idea's or is there a better/ more elegant solution to this problem ? With regards, Mike Veltman With regards, Mike Veltman
[web2py] Compile from command line
Its pretty annoying because I did know it before. Does anybody know what the command is to compile from the command line ? Also is there are website or part of the book that will collect this so I can add it ? Thanks in advance. With regards, Mike Veltman
Re: [web2py] Compile from command line
here: http://thadeusb.com/weblog/2010/4/21/compile_web2py_apps_externally python -c import gluon.compileapp; gluon.compileapp.compile_application('applications/appname') On Sun, Aug 28, 2011 at 10:05 PM, Mike Veltman mike.velt...@gmail.comwrote: Its pretty annoying because I did know it before. Does anybody know what the command is to compile from the command line ? Also is there are website or part of the book that will collect this so I can add it ? Thanks in advance. With regards, Mike Veltman That was it ! thanks :) With regards, Mike Veltman
Re: [web2py] Re: What about a few web2py server vm builds
Thanks, :-) I probably make it anyway just to play around with it. But then I do not share by default. There was discussion http://www.turnkeylinux.org/forum/general/20110107/tklpatch-web2py-framewor k On Jul 20, 8:04 pm, Mike Veltman mike.velt...@gmail.com wrote: First I dont know if someone already did it. I have been playing with suse studio for a while and I thought to build a vm/install iso for a base and test web2py server. So I do some brainstorming It will be based on a minimal server (opensuse 11.4) install. I was thinking/brainstorming to do the following. 1) create a web2py user with a few scripts for dumping and loading databases and to start a web2py shell. 2) create a default mysql database with a defaultdb database thats used in the web2py setup. 3) Place Web2py in /srv/web2py 4) The installation should not use more then 4 GB 5) The installation should use LV setup for easy increase of space 6) Web2py should be autostarting. 7) iso and vm for installation on usb or in vmware/kvm etc I was wondering if it would be smart to push web2py into a apache webserver or something else. And what other things I should add. With regards, Mike Veltman With regards, Mike Veltman
Re: [web2py] Re: What about a few web2py server vm builds
Just to be sure that its clear what I am talking about. http://susestudio.com What produces modified opensuse / sles installation disks or vm's to deploy. So it could generate a full web2py server and it will be about a 300mb download as a vmware/kvm image or as a bootable harddisk, life cd or installation cd/dvd that automaticly deploys a web2py environment. Mmmm, it does show that I am a OS man and not a developer ;-) There was discussion http://www.turnkeylinux.org/forum/general/20110107/tklpatch-web2py-framewor k On Jul 20, 8:04 pm, Mike Veltman mike.velt...@gmail.com wrote: First I dont know if someone already did it. I have been playing with suse studio for a while and I thought to build a vm/install iso for a base and test web2py server. So I do some brainstorming It will be based on a minimal server (opensuse 11.4) install. I was thinking/brainstorming to do the following. 1) create a web2py user with a few scripts for dumping and loading databases and to start a web2py shell. 2) create a default mysql database with a defaultdb database thats used in the web2py setup. 3) Place Web2py in /srv/web2py 4) The installation should not use more then 4 GB 5) The installation should use LV setup for easy increase of space 6) Web2py should be autostarting. 7) iso and vm for installation on usb or in vmware/kvm etc I was wondering if it would be smart to push web2py into a apache webserver or something else. And what other things I should add. With regards, Mike Veltman With regards, Mike Veltman
[web2py] What about a few web2py server vm builds
First I dont know if someone already did it. I have been playing with suse studio for a while and I thought to build a vm/install iso for a base and test web2py server. So I do some brainstorming It will be based on a minimal server (opensuse 11.4) install. I was thinking/brainstorming to do the following. 1) create a web2py user with a few scripts for dumping and loading databases and to start a web2py shell. 2) create a default mysql database with a defaultdb database thats used in the web2py setup. 3) Place Web2py in /srv/web2py 4) The installation should not use more then 4 GB 5) The installation should use LV setup for easy increase of space 6) Web2py should be autostarting. 7) iso and vm for installation on usb or in vmware/kvm etc I was wondering if it would be smart to push web2py into a apache webserver or something else. And what other things I should add. With regards, Mike Veltman
[web2py] How to to get SQLFORM.factory to show only a subset of records ?
This will probably a facepalm moment but I can not figure it out. My present used form function form = SQLFORM.factory( Field('setup', requires=IS_IN_DB(db, db.setup.setupname, '%(setupname)s') )) Model db.define_table('setup', Field('setupname', type='string', unique=True, label=T('Setup name')), Field('description', type='string', label=T('Description')), Field('frame_id', db.frame, label=T('Frame ID')), Field('course_id', db.course, label=T('Course ID')), Field('ready', type='boolean', default=False, label=T('Ready for use')), Field('nostorage', type='boolean', default=False, label=T('No storage needed')), Field('noprofiles', type='boolean', default=False, label=T('No profiles needed')), Field('nonim', type='boolean', default=False, label=T('No nim actions needed')), Field('securitylevel', type='integer', default=0, label=T('Security Level')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), format='%(setupname)s', migrate=settings.migrate) What I try to get is that the form only shows the setupname of the records where setup.read==True and then returns setup.id so I can use that. A addtional would be that the first selection is the first record and not empty. Thanks in advance. With regards, Mike Veltman
Re: [web2py] How to to get SQLFORM.factory to show only a subset of records ?
Thanks about 1 zillion times :) Oh, and to get rid of the empty choice at the top of the list, add zero=None: IS_IN_DB(..., zero=None) On Wednesday, July 13, 2011 9:22:50 PM UTC-4, Anthony wrote: For reference, see http://web2py.com/book/default/chapter/07#Database-Validators. On Wednesday, July 13, 2011 9:21:54 PM UTC-4, Anthony wrote: IS_IN_DB takes a DAL set, so you can limit the records returned. If you want the record ID returned, use db.setup.id. So, maybe something like this: Field('setup', requires=IS_IN_DB(db(db.setup.ready==True), db.setup.id, '%(setupname)s')) Anthony On Wednesday, July 13, 2011 9:06:03 PM UTC-4, Gwayne aka Mike Veltman wrote: This will probably a facepalm moment but I can not figure it out. My present used form function form = SQLFORM.factory( Field('setup', requires=IS_IN_DB(db, db.setup.setupname, '%(setupname)s') )) Model db.define_table('setup', Field('setupname', type='string', unique=True, label=T('Setup name')), Field('description', type='string', label=T('Description')), Field('frame_id', db.frame, label=T('Frame ID')), Field('course_id', db.course, label=T('Course ID')), Field('ready', type='boolean', default=False, label=T('Ready for use')), Field('nostorage', type='boolean', default=False, label=T('No storage needed')), Field('noprofiles', type='boolean', default=False, label=T('No profiles needed')), Field('nonim', type='boolean', default=False, label=T('No nim actions needed')), Field('securitylevel', type='integer', default=0, label=T('Security Level')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), format='%(setupname)s', migrate=settings.migrate) What I try to get is that the form only shows the setupname of the records where setup.read==True and then returns setup.id so I can use that. A addtional would be that the first selection is the first record and not empty. Thanks in advance. With regards, Mike Veltman With regards, Mike Veltman
[web2py] Strange behaviour with import.
When I dump a table from a SQLite3 db and import it in a mysql database some of the integers do not load. Interesting enough the .id do show up fine. With regards, Mike Veltman
Re: [web2py] Re: Strange behaviour with import.
This is fixed in trunk. Thanks :-) I noticed that I never added version and stuff, sorry for that. On Jun 20, 3:38 am, Mike Veltman mike.velt...@gmail.com wrote: When I dump a table from a SQLite3 db and import it in a mysql database some of the integers do not load. Interesting enough the .id do show up fine. With regards, Mike Veltman With regards, Mike Veltman
Re: [web2py] Re: SyntaxError: Object exists and cannot be redefined: lunid
On Tuesday, June 7, 2011 2:26:45 AM UTC-4, Gwayne aka Mike Veltman wrote: On Monday, June 6, 2011 9:15:27 PM UTC-4, Gwayne aka Mike Veltman wrote: And that was it... Thank you very much. Mmmm, this should go in the book.. There's also this method of pre-populating a form field: http://web2py.com/book/default/chapter/07#Pre-populating-the-form Yes I know, but I did read in the mailing list that that was not a smart idea. I wasn't aware of that. Why is it not a smart idea? I am trying to find it it was actually in the mailing list a discussion about it and the suggestion was to use the default. Also those vars do not exist before I create the form. So you would get a error if you do so. But is there any reason you couldn't make the assignment right after the form is created (i.e., instead of assigning a new default right before the form creation, assign a value to the form var right after creation)? Anthony Maybe I just do it plain wrong :-) form = SQLFORM(db.lvstorage) form.vars.lunid = 2 # Does not work Thats how I did it. Now I have a complicated system :) My goal is/was to make the lunid autoincrement with each submit. Now I use this (btw I am not a programmer so, suggestions are always welcome.) if not request.vars.newrecord: # For the newrecord button newrecord = False if request.vars.newrecord: # For the newrecord button session.lunid = 2 newrecord = True if not request.args or newrecord == True: # If called directly from menu or newmenu button if session.lunid == 2: # Default settings for the page db.lvstorage.lunid.default = 2 db.lvstorage.setup_id.default = 1 db.lvstorage.lvsize_id.default = 2 db.lvstorage.storagemap_id.default = 1 session.setup_id = 1 session.storagemap_id = 1 session.lvsize_id = 2 else: if session.lunid == 31: # Lunid 31 is managed by the controller so skip it session.lunid = 32 if request.vars.setup_id : # To make sure that if the var does not exist it will not change the session var session.setup_id = request.vars.setup_id if request.vars.lvsize_id : session.lvsize_id = request.vars.lvsize_id if request.vars.storagemap_id : session.storagemap_id = request.vars.storagemap_id db.lvstorage.lunid.default = int(session.lunid) db.lvstorage.setup_id.default = session.setup_id db.lvstorage.lvsize_id.default = session.lvsize_id db.lvstorage.storagemap_id.default = session.storagemap_id if request.vars.checkbox: # If checkbox is used do not increase lunid pass else: session.lunid = int(session.lunid) + 1 # Increase lun id form = SQLFORM(db.lvstorage) With regards, Mike Veltman
[web2py] Re: SyntaxError: Object exists and cannot be redefined: lunid
On Monday, June 6, 2011 9:15:27 PM UTC-4, Gwayne aka Mike Veltman wrote: And that was it... Thank you very much. Mmmm, this should go in the book.. There's also this method of pre-populating a form field: http://web2py.com/book/default/chapter/07#Pre-populating-the-form Yes I know, but I did read in the mailing list that that was not a smart idea. Also those vars do not exist before I create the form. So you would get a error if you do so. I still have one problem that if I do keepvalues=True it will not override. So there I probably have to use the form.vars.name = fieldvalue trick Lets test that. With regards, Mike Veltman
[web2py] SyntaxError: Object exists and cannot be redefined: lunid
I try to pre populate a form and I think I do something wrong but I stare at it for a long time and what I do wrong still does not show up. So maybe some people can make my day better. Error: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. Traceback (most recent call last): File /home/mv1965/Documents/development/eclipse/adsw2p/gluon/restricted.py, line 184, in restricted exec ccode in environment File /home/mv1965/Documents/development/eclipse/adsw2p/applications/adeploy/compiled/controllers_formdb_test_manage_lvstorage.py, line 342, in module File /home/mv1965/Documents/development/eclipse/adsw2p/gluon/globals.py, line 137, in lambda self._caller = lambda f: f() File /home/mv1965/Documents/development/eclipse/adsw2p/gluon/tools.py, line 2452, in f return action(*a, **b) File /home/mv1965/Documents/development/eclipse/adsw2p/applications/adeploy/compiled/controllers_formdb_test_manage_lvstorage.py, line 58, in test_manage_lvstorage File /home/mv1965/Documents/development/eclipse/adsw2p/gluon/dal.py, line 4630, in __setattr__ raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: lunid Controller @auth.requires_login() def test_manage_lvstorage(): db.lvstorage.lunid = 4 form = SQLFORM(db.lvstorage) return dict(form=form) # Logical volume on storage db.define_table('lvstorage', Field('setup_id', db.setup, default=1, label=T('Setup ID')), Field('lvsize_id', db.lvsize, default=2, label=T('Size ID')), Field('lunid', type='integer', default=2, label=T('Lun ID')), Field('storagemap_id', db.storagemap, default=1, label=T('Host Group')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvstorage.setup_id.requires = IS_IN_DB(db, 'setup.id', 'setup.setupname') db.lvstorage.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id', 'lvsize.sizename') db.lvstorage.storagemap_id.requires = IS_IN_DB(db, 'storagemap.id', 'storagemap.mapping') db.lvstorage.lunid.requires = IS_IN_SET([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70])
[web2py] Re: SyntaxError: Object exists and cannot be redefined: lunid
And that was it... Thank you very much. Mmmm, this should go in the book.. db.lvstorage.lunid = 4 should be (I guess) db.lvstorage.lunid.default = 4 On Jun 6, 4:12 am, Mike Veltman mike.velt...@gmail.com wrote: I try to pre populate a form and I think I do something wrong but I stare at it for a long time and what I do wrong still does not show up. So maybe some people can make my day better. Error: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. Traceback (most recent call last): File /home/mv1965/Documents/development/eclipse/adsw2p/gluon/restricted.py, line 184, in restricted exec ccode in environment File /home/mv1965/Documents/development/eclipse/adsw2p/applications/adeploy/ com piled/controllers_formdb_test_manage_lvstorage.py, line 342, in module File /home/mv1965/Documents/development/eclipse/adsw2p/gluon/globals.py, line 137, in lambda self._caller = lambda f: f() File /home/mv1965/Documents/development/eclipse/adsw2p/gluon/tools.py, line 2452, in f return action(*a, **b) File /home/mv1965/Documents/development/eclipse/adsw2p/applications/adeploy/ com piled/controllers_formdb_test_manage_lvstorage.py, line 58, in test_manage_lvstorage File /home/mv1965/Documents/development/eclipse/adsw2p/gluon/dal.py, line 4630, in __setattr__ raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: lunid Controller @auth.requires_login() def test_manage_lvstorage(): db.lvstorage.lunid = 4 form = SQLFORM(db.lvstorage) return dict(form=form) # Logical volume on storage db.define_table('lvstorage', Field('setup_id', db.setup, default=1, label=T('Setup ID')), Field('lvsize_id', db.lvsize, default=2, label=T('Size ID')), Field('lunid', type='integer', default=2, label=T('Lun ID')), Field('storagemap_id', db.storagemap, default=1, label=T('Host Group')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvstorage.setup_id.requires = IS_IN_DB(db, 'setup.id', 'setup.setupname') db.lvstorage.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id', 'lvsize.sizename') db.lvstorage.storagemap_id.requires = IS_IN_DB(db, 'storagemap.id', 'storagemap.mapping') db.lvstorage.lunid.requires = IS_IN_SET([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,2 5, 26,27,28,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50, 51, 52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70]) With regards, Mike Veltman
Re: [web2py] CRYPT validator outlawed in France?
http://www.reddit.com/r/programming/comments/gkl77/hashed_passwords_outlawe d_in_france/ I thought that by definition all encryption keys should be given to the government in France. So a source that can not be decrypted by the government is automatically illegal. With regards, Mike Veltman
[web2py] Possible bug relating creating records in appadmin with IS_IN_SET([0,1])
Database field is: Field('lunid', type='integer', default=0, label=T('Lun ID')), Database rule is db.viostorage.lunid.requires = IS_IN_SET([0,1]) Problem: In stead of giving me lun 0 as default option it selects nothing :-) Make default is 1 and it works fine. With regards, Mike Veltman Trainer and Senior Consultant, Linux and AIX Phone : +65 96212448 Phone NL : +31 878702983 DID : +65 6464 0432 Fax : +65 6464 0349 Email : mike.velt...@gmail.com Skype : m.veltman Profile : www.linkedin.com/in/mikeveltman = Information in this message is confidential. It is intended solely for the person or the entity to whom it is addressed. If you are not the intended recipient, you are not to disseminate,distribute or copy this communication. Please notify the sender and delete the message and any other record of it from your system immediately. =
Re: [web2py] Re: Possible bug relating creating records in appadmin with IS_IN_SET([0,1])
Its interesting because its only with 0 Field('lvsize_id', db.lvsize, default=1, label=T('Size ID')), Field('lunid', type='integer', default=0, label=T('Lun ID')), The other one works fine :-) It is a bug, e.g. sqlhtml.py uses if default ... to check for the existence of a field default, and that does not work for this case. Thinking cap on... On Apr 6, 4:17 am, Mike Veltman mike.velt...@gmail.com wrote: Database field is: Field('lunid', type='integer', default=0, label=T('Lun ID')), Database rule is db.viostorage.lunid.requires = IS_IN_SET([0,1]) Problem: In stead of giving me lun 0 as default option it selects nothing :-) Make default is 1 and it works fine. With regards, Mike Veltman Trainer and Senior Consultant, Linux and AIX Phone : +65 96212448 Phone NL : +31 878702983 DID : +65 6464 0432 Fax : +65 6464 0349 Email : mike.velt...@gmail.com Skype : m.veltman Profile :www.linkedin.com/in/mikeveltman = Information in this message is confidential. It is intended solely for the person or the entity to whom it is addressed. If you are not the intended recipient, you are not to disseminate,distribute or copy this communication. Please notify the sender and delete the message and any other record of it from your system immediately. = With regards, Mike Veltman Trainer and Senior Consultant, Linux and AIX Phone : +65 96212448 Phone NL : +31 878702983 DID : +65 6464 0432 Fax : +65 6464 0349 Email : mike.velt...@gmail.com Skype : m.veltman Profile : www.linkedin.com/in/mikeveltman = Information in this message is confidential. It is intended solely for the person or the entity to whom it is addressed. If you are not the intended recipient, you are not to disseminate,distribute or copy this communication. Please notify the sender and delete the message and any other record of it from your system immediately. =
Re: [web2py] Re: Possible bug relating creating records in appadmin with IS_IN_SET([0,1])
Thank you. No hurries, glad that I did not waste time. will fix it On Apr 6, 5:10 am, DenesL denes1...@yahoo.ca wrote: It is a bug, e.g. sqlhtml.py uses if default ... to check for the existence of a field default, and that does not work for this case. Thinking cap on... On Apr 6, 4:17 am, Mike Veltman mike.velt...@gmail.com wrote: Database field is: Field('lunid', type='integer', default=0, label=T('Lun ID')), Database rule is db.viostorage.lunid.requires = IS_IN_SET([0,1]) Problem: In stead of giving me lun 0 as default option it selects nothing :-) Make default is 1 and it works fine. With regards, Mike Veltman Trainer and Senior Consultant, Linux and AIX Phone : +65 96212448 Phone NL : +31 878702983 DID : +65 6464 0432 Fax : +65 6464 0349 Email : mike.velt...@gmail.com Skype : m.veltman Profile :www.linkedin.com/in/mikeveltman = Information in this message is confidential. It is intended solely for the person or the entity to whom it is addressed. If you are not the intended recipient, you are not to disseminate,distribute or copy this communication. Please notify the sender and delete the message and any other record of it from your system immediately. = With regards, Mike Veltman
[web2py] Create a new window.
Well as a beginner with web2py I first have to say that I like it. So thank you to all the people who work on it. I am also a beginner with Python so do not expect very complicated questions (yet) Well I am building a application to deploy AIX unix installs on power machines. My application creates the logical volumes on the storage, creates the virtual machines and starts the deployments. Its all coordinated with web2py. Now my question. When I start a deployment the function could take a while and one solution would be to create a new window with the status of the deployment. Would it be possible to spawn a separate window and let the original form go on ? Thanks in advance. Mike Veltman
Re: [web2py] Japan
+888 +1 2011/3/11 Massimo Di Pierro massimo.dipie...@gmail.com We all feel very close to our friends in Japan, and we are saddened by what has happened. With regards, Mike Veltman Trainer and Senior Consultant, Linux and AIX Phone : +65 96212448 Phone NL : +31 878702983 DID : +65 6464 0432 Fax : +65 6464 0349 Email : mike.velt...@gmail.com Skype : m.veltman Profile : www.linkedin.com/in/mikeveltman = Information in this message is confidential. It is intended solely for the person or the entity to whom it is addressed. If you are not the intended recipient, you are not to disseminate,distribute or copy this communication. Please notify the sender and delete the message and any other record of it from your system immediately. =