[web2py] Re: powertable problem
i re-download the plugin from bitbucket and now it work (powertable.blouweb.com is not update!) but now i have another little problem... when i open the details of a record i see the logo of my template ... how i can personalize the interface of the details? and a new question... i can have 2 or more green plus button ... i want to make one button for deatils one for edit... one for duplicate record (and if it is possible with another button icon) On 4 Feb, 08:51, ceriox cer...@gmail.com wrote: Kenneth - i just copy the code from a powertable example app (web2py.app.skrywer_powertable.w2p) now i try to delete .load Bruno Rocha - i download it yesterday from your websitehttp://powertable.blouweb.com/, now i try to re-download the plugin from bitbucket thanks for help! Bruno Rocha - there is a guide with all the powertable parameters ?
Re: [web2py] http and https
Yes - I should have said that I was assuming it was running behind Apache. With the standard setup as created by the 'setup-ubuntu.sh' or 'setup-fedora.sh' scripts (in the scripts folder) you'll already be set with a self-sigend certificate and Apache configured to send https requests to web2py. On 3 February 2011 23:37, Jonathan Lundell jlund...@pobox.com wrote: On Feb 3, 2011, at 2:43 PM, Vasile Ermicioi wrote: there are 2 ports, so I think he must run 2 instances, he can use router if he uses a proxy like nginx which will pass all requests to the web2py It should work for Apache, too, as long as Apache is configured to go to web2py for both domains/ports. Speaking of which, there's no real need for separate subdomains, I don't think. some.domain.com should be able to serve both http and https.
Re: [web2py] Re: powertable problem
It should not be a problem, you need to create more virtual fields. If you look at http://powertable.blouweb.com/products and The Code, starting from row 8 you see how a new virtualfield is created. Kenneth i re-download the plugin from bitbucket and now it work (powertable.blouweb.com is not update!) but now i have another little problem... when i open the details of a record i see the logo of my template ... how i can personalize the interface of the details? and a new question... i can have 2 or more green plus button ... i want to make one button for deatils one for edit... one for duplicate record (and if it is possible with another button icon) On 4 Feb, 08:51, cerioxcer...@gmail.com wrote: Kenneth - i just copy the code from a powertable example app (web2py.app.skrywer_powertable.w2p) now i try to delete .load Bruno Rocha - i download it yesterday from your websitehttp://powertable.blouweb.com/, now i try to re-download the plugin from bitbucket thanks for help! Bruno Rocha - there is a guide with all the powertable parameters ?
[web2py] Re: powertable problem
oh ok... but how i can associate a function link to the button? @virtualsettings(label=T('Small Picture')) def smallpicture(self): picture = IMG(_src=URL('default','download',args=self.products.picture), _border='0', _height='30px', _width=None, _alt=T('A small picture for %s' % self.products.name), _title=T('This is the category small picture')) return picture _URL='myfunction' ?? On 4 Feb, 09:15, Kenneth Lundström kenneth.t.lundst...@gmail.com wrote: It should not be a problem, you need to create more virtual fields. If you look athttp://powertable.blouweb.com/productsand The Code, starting from row 8 you see how a new virtualfield is created. Kenneth i re-download the plugin from bitbucket and now it work (powertable.blouweb.com is not update!) but now i have another little problem... when i open the details of a record i see the logo of my template ... how i can personalize the interface of the details? and a new question... i can have 2 or more green plus button ... i want to make one button for deatils one for edit... one for duplicate record (and if it is possible with another button icon) On 4 Feb, 08:51, cerioxcer...@gmail.com wrote: Kenneth - i just copy the code from a powertable example app (web2py.app.skrywer_powertable.w2p) now i try to delete .load Bruno Rocha - i download it yesterday from your websitehttp://powertable.blouweb.com/, now i try to re-download the plugin from bitbucket thanks for help! Bruno Rocha - there is a guide with all the powertable parameters ?
[web2py] Re: Unicity condition and database update
Yes I understand that :) And it asks also for triggerValue if not given, but it's a bit annoying. Isn't it possible for it to get those existing values directly ? Thanks. On Feb 3, 7:38 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: The problem is that unicity must be computed but it needs triggename. You are not passing triggername when you do the update_rector and web2y does not do what to do. web2py wants you to be explicit: row=db.alarms(2) row.update_record(message='rz',triggerName=row.triggerName) On Feb 3, 4:40 am, Joseph.Piron joseph.pi...@gmail.com wrote: Hi guys, I'm currently facing a strange thing :) I make use of datatables (jquery datatables.net) and jeditable to update values in my db. If the user clicks on a value, he changes it and sends it, thus, only the value of this field. On the server part, i then do a db.alarms[request.vars.id].update_record(field=value). Unfortunately, i have to have a unicity condition for this table, and thus, with the previous statement, i get an error. Here's some code to help understand.. db.define_table('alarms', Field('triggerName', type = 'string', label = T('Trigger Name'), required = True, notnull = True), Field('triggerValue', type = 'integer', label = T('Trigger Value'), required = True, notnull = True), Field('message', type = 'string', label = T('Message'), required = True, notnull = True), Field('alarmScope', type = 'string', label = T('Alarm Scope'), required = True, notnull = True), Field('unicity', type = 'string', compute = lambda x: x.triggerName + str(x.triggerValue), unique = True), format = '%(triggerName)s - %(triggerValue)s', migrate = settings.migrate) db.alarms.triggerValue.requires = IS_NOT_IN_DB(db(db.alarms.triggerName == request.vars.triggerName), 'alarms.triggerValue') If i want to update one of the fields, I have absolutely to also update (even if the don't change) triggerName and triggerValue (fields for unicity condition), and thus I need some test dependent on which field is updated.. Here's an exemple: In [15]: db.alarms[2].update_record(message='rz') --- KeyError Traceback (most recent call last) /Users/joseph/Documents/workspace/web2py/ipython console in module() /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in lambda(_, **a) 1245 if field_type == 'id': 1246 id = colset[field.name] - 1247 colset.update_record = lambda _ = (colset, table, id), **a: update_record(_, a) 1248 colset.delete_record = lambda t = table, i = id: t._db(t._id==i).delete() 1249 for (referee_table, referee_name) in \ /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in update_record(pack, a) 4433 c = dict([(k,v) for (k,v) in b.items() \ 4434 if k in table.fields and not k=='id']) - 4435 table._db(table._id==id).update(**c) 4436 for (k, v) in c.items(): 4437 colset[k] = v /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in update(self, **update_fields) 4392 def update(self, **update_fields): 4393 tablename = self.db._adapter.get_table(self.query) - 4394 fields = self.db[tablename]._listify(update_fields,update=True) 4395 self.delete_uploaded_files(update_fields) 4396 return self.db._adapter.update(tablename,self.query,fields) /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in _listify(self, fields, update) 3748 new_fields.append((ofield,ofield.update)) 3749 elif ofield.compute: - 3750 new_fields.append((ofield,ofield.compute(Row(fields 3751 elif not update and ofield.required: 3752 raise SyntaxError,'Table: missing required field: %s' % name /Users/joseph/Documents/workspace/web2py/applications/hmiwebsite/ models/model_alarms.py in lambda(x) 7 Field('message', type = 'string', label = T('Message'), required = True, notnull = True), 8 Field('alarmScope', type = 'string', label = T('Alarm Scope'), required = True, notnull = True), 9 Field('unicity', type = 'string', compute = lambda x: x.triggerName + str(x.triggerValue), unique = True), 10 format = '%(triggerName)s - %(triggerValue)s', 11 migrate = settings.migrate) /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in __getattr__(self, key) 3061 3062 def __getattr__(self, key): - 3063 return dict.__getitem__(self,key) 3064 3065 def __setattr__(self, key, value): KeyError: 'triggerName' Could anyone help me out of this one ? :)
[web2py] Database design challenge
I would like to invite web2py users who enjoy such challenges to think with me about solving the following problem: Take two tables: db.define_table('article', Field(author_id, 'list:reference outeur'), Field(title)) db.define_table('author', Field('surname'), Field('initials')) Table 'article' contains 137000 records and author about 108000. The field definition of 'author_id' as list:reference would be ideal but in this case the list is too large and breaks javascript in the browser causing any crud.create or crud.update to take about 70 seconds to show the form. I am looking for a solution to be able to enter a new article while the same screen the user can either select an existing entry in 'author' or add a new author linked to the article if the author does not exist in the database. Keep in mind that one article can have several authors of which some may be in the database already and we try to avoid duplicate entries for the same author. Using an autocompletion widget for the author might have been useful if only one author per article was allowed. One possible solution is to create a third table for many-to-many relations: db.define_table('author_article', Field('article_id', db.article,requires = IS_IN_DB(db,'article.id')), Field('author_id', db.author,requires = IS_IN_DB(db,' author.id'))) In such a case how would one approach the entry forms in such a way that the user does not nead to choose different screens/menu options when the author is new or already in the database or when there are many authors for the same article? Regards Johann Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
[web2py] Re: powertable problem
another questions... how can manage parameters in function call ? details={'detailscallback':URL('myfunction.load')} ) i want to have my row id in myfunction On 4 Feb, 09:28, ceriox cer...@gmail.com wrote: oh ok... but how i can associate a function link to the button? @virtualsettings(label=T('Small Picture')) def smallpicture(self): picture = IMG(_src=URL('default','download',args=self.products.picture), _border='0', _height='30px', _width=None, _alt=T('A small picture for %s' % self.products.name), _title=T('This is the category small picture')) return picture _URL='myfunction' ?? On 4 Feb, 09:15, Kenneth Lundström kenneth.t.lundst...@gmail.com wrote: It should not be a problem, you need to create more virtual fields. If you look athttp://powertable.blouweb.com/productsandThe Code, starting from row 8 you see how a new virtualfield is created. Kenneth i re-download the plugin from bitbucket and now it work (powertable.blouweb.com is not update!) but now i have another little problem... when i open the details of a record i see the logo of my template ... how i can personalize the interface of the details? and a new question... i can have 2 or more green plus button ... i want to make one button for deatils one for edit... one for duplicate record (and if it is possible with another button icon) On 4 Feb, 08:51, cerioxcer...@gmail.com wrote: Kenneth - i just copy the code from a powertable example app (web2py.app.skrywer_powertable.w2p) now i try to delete .load Bruno Rocha - i download it yesterday from your websitehttp://powertable.blouweb.com/, now i try to re-download the plugin from bitbucket thanks for help! Bruno Rocha - there is a guide with all the powertable parameters ?
Re: [web2py] Re: powertable problem
On 4 February 2011 11:50, ceriox cer...@gmail.com wrote: another questions... how can manage parameters in function call ? details={'detailscallback':URL('myfunction.load')} ) i want to have my row id in myfunction You can specify the sql-query in myfunction. I have the following: key = None for k in request.vars.keys(): if k[:3] == 'dt_': key = request.vars[k] art_id = None art_id = key.split('.')[-1] obj = DIV() obj.append(SQLTABLE(db((db.outeur_art_ekw.artikel == art_id) (db.outeur.id == db.outeur_art_ekw.skrywer)).select(db.outeur.ALL,orderby= db.outeur.van))) where the function shows entries in db.outeur related to db.artikel.id. Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
[web2py] bug?
I am setting a table column 'code' as Unique. When I insert repeated rows it doesn't raise exception. db.define_table('tag', Field('code', 'string', length=24, unique=True, requires=[ IS_HEX24(error_message=err_is_hex24)]), Field('of_client', 'reference client', requires=IS_IN_DB(db, 'client.id', '%(name)s',error_message=err_is_in_db), ondelete='SET NULL'), Field('of_batch', 'reference batch', requires=IS_IN_DB(db, 'batch.id', '%(name)s',error_message=err_is_in_db), ondelete='SET NULL'), Field('active', 'boolean', default=True) )
[web2py] Re: powertable problem
thanks, it works but now i have another step to do ... the CRUD don't save on db the operations.. for example it don't delete any item ... and why i have 2 id field in my form this is my function: def myfunction(): return a custom object to be inserted in detail for table key = None for k in request.vars.keys(): if k[:3] == 'dt_': key = request.vars[k] item_id = None item_id = key.split('.')[-1] obj = DIV() obj.append(H1(T('Title for my details'))) obj.append(crud.update(db.auth_user,item_id)) db.auth_user.update() return dict(obj=obj) On 4 Feb, 11:02, Johann Spies johann.sp...@gmail.com wrote: On 4 February 2011 11:50, ceriox cer...@gmail.com wrote: another questions... how can manage parameters in function call ? details={'detailscallback':URL('myfunction.load')} ) i want to have my row id in myfunction You can specify the sql-query in myfunction. I have the following: key = None for k in request.vars.keys(): if k[:3] == 'dt_': key = request.vars[k] art_id = None art_id = key.split('.')[-1] obj = DIV() obj.append(SQLTABLE(db((db.outeur_art_ekw.artikel == art_id) (db.outeur.id == db.outeur_art_ekw.skrywer)).select(db.outeur.ALL,orderby= db.outeur.van))) where the function shows entries in db.outeur related to db.artikel.id. Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
Re: [web2py] Re: powertable problem
2011/2/4 ceriox cer...@gmail.com thanks, it works but now i have another step to do ... the CRUD don't save on db the operations.. for example it don't delete any item ... and why i have 2 id field in my form I guess datatables JavaScript is in conflict with the JavaScript for the crud form, I have some issues reported to solve regarding JavaScript. Can you email-me your app or just your controllers code? I will try to figure it out.
[web2py] Re: bug?
Never mind. I think this is due to IS_HEX24 function. On Feb 4, 10:39 am, vortex billyara...@gmail.com wrote: I am setting a table column 'code' as Unique. When I insert repeated rows it doesn't raise exception. db.define_table('tag', Field('code', 'string', length=24, unique=True, requires=[ IS_HEX24(error_message=err_is_hex24)]), Field('of_client', 'reference client', requires=IS_IN_DB(db, 'client.id', '%(name)s', error_message=err_is_in_db), ondelete='SET NULL'), Field('of_batch', 'reference batch', requires=IS_IN_DB(db, 'batch.id', '%(name)s', error_message=err_is_in_db), ondelete='SET NULL'), Field('active', 'boolean', default=True) )
[web2py] Re: SQLFORM and read-only references
I´m having the same problem. In a SQLFORM I have a Field that is sometimes writable and sometimes not. If you are admin you can modify this field but not as user. Field is a reference to and other table, so admin gets a dropdown but the user gets None but he should get the selection that admin has made. Kenneth On Jan 26, 11:48 pm, Pawel Jasinski pawel.jasin...@gmail.com wrote: Hi, Are you sure you want the form readonly? Yes What if you remove readonly? The 'None' changes into drop down with ids or whatever is in the format argument of the field. If you want readonly you do not need accepts Good point, changed. It does not help with the main problem. I also have another use case, where form is used on the confirmation screen. Kind of are you really sure ... All fields are made read only with db.table.filed.writable=False. The references are also rendered as None. Cheers, Pawel
Re: [web2py] postgresql error ... class 'psycopg2.ProgrammingError'(relation auth_user already exists)
I am getting the same error as reported by Carlos and cannot fix it. I have just set up a new server (Ubuntu 10.04 - postgres 8.4, Python 2.6.5) and have web2py trunk up and running fine. I have an unmodified 'welcome' app which runs perfectly with sqlite. I then delete all the files in databases, cache and sessions. Next I create a postgresql database and grant permissions to the appropriate user. I have double checked this and the user can create tables on the database. Next change the connection details in the welcome app db.py to: db = DAL('postgres://myuser:mypasswordlocalhost/mydb') Then visit the URL and I get the ticket below. Any help gratefully appreciated. (I had this running fine on a previous server) Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /home/www-data/web2py/applications/welcome/models/db.py, line 32, in module auth.define_tables() # creates all needed tables File /home/www-data/web2py/gluon/tools.py, line 1177, in define_tables format='%(first_name)s %(last_name)s (%(id)s)') File /home/www-data/web2py/gluon/dal.py, line 3489, in define_table polymodel=polymodel) File /home/www-data/web2py/gluon/dal.py, line 531, in create_table self.create_sequence_and_triggers(query,table) File /home/www-data/web2py/gluon/dal.py, line 1512, in create_sequence_and_triggers self.execute('CREATE SEQUENCE %s;' % sequence_name) File /home/www-data/web2py/gluon/dal.py, line 1078, in execute return self.log_execute(*a, **b) File /home/www-data/web2py/gluon/dal.py, line 1075, in log_execute return self.cursor.execute(*a,**b) ProgrammingError: relation auth_user_id_seq already exists ERROR SNAPSHOT class 'psycopg2.ProgrammingError'(relation auth_user_id_seq already exists Frames File /home/www-data/web2py/gluon/restricted.py in restricted at line 188 code arguments variables File /home/www-data/web2py/applications/welcome/models/db.py in module at line 32 code arguments variables File /home/www-data/web2py/gluon/tools.py in define_tables at line 1177 code arguments variables File /home/www-data/web2py/gluon/dal.py in define_table at line 3489 code arguments variables File /home/www-data/web2py/gluon/dal.py in create_table at line 531 code arguments variables File /home/www-data/web2py/gluon/dal.py in create_sequence_and_triggers at line 1512 code arguments variables File /home/www-data/web2py/gluon/dal.py in execute at line 1078 code arguments variables File /home/www-data/web2py/gluon/dal.py in log_execute at line 1075 code arguments variables Function argument list (self=gluon.dal.PostgreSQLAdapter object, *a=('CREATE SEQUENCE auth_user_id_Seq;',), **b={}) Code listing 1070. 1071. 1072. 1073. 1074. 1075. 1076. 1077. 1078. 1079. def create_sequence_and_triggers(self, query, table, **args): self.execute(query) def log_execute(self,*a,**b): self.db._lastsql = a[0] return self.cursor.execute(*a,**b) def execute(self,*a,**b): return self.log_execute(*a, **b) Variables a('CREATE SEQUENCE auth_user_id_Seq;',) self.cursorcursor object at 0xba1152cc; closed: 0 selfgluon.dal.PostgreSQLAdapter object b{} self.cursor.executebuilt-in method execute of psycopg2._psycopg.cursor object
Re: [web2py] postgresql error ... class 'psycopg2.ProgrammingError'(relation auth_user already exists)
(PS I have tried auth.define_tables(migrate='False') and it doesn't help) On 4 February 2011 13:22, Tom Atkins minkto...@gmail.com wrote: I am getting the same error as reported by Carlos and cannot fix it. I have just set up a new server (Ubuntu 10.04 - postgres 8.4, Python 2.6.5) and have web2py trunk up and running fine. I have an unmodified 'welcome' app which runs perfectly with sqlite. I then delete all the files in databases, cache and sessions. Next I create a postgresql database and grant permissions to the appropriate user. I have double checked this and the user can create tables on the database. Next change the connection details in the welcome app db.py to: db = DAL('postgres://myuser:mypasswordlocalhost/mydb') Then visit the URL and I get the ticket below. Any help gratefully appreciated. (I had this running fine on a previous server) Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /home/www-data/web2py/applications/welcome/models/db.py, line 32, in module auth.define_tables() # creates all needed tables File /home/www-data/web2py/gluon/tools.py, line 1177, in define_tables format='%(first_name)s %(last_name)s (%(id)s)') File /home/www-data/web2py/gluon/dal.py, line 3489, in define_table polymodel=polymodel) File /home/www-data/web2py/gluon/dal.py, line 531, in create_table self.create_sequence_and_triggers(query,table) File /home/www-data/web2py/gluon/dal.py, line 1512, in create_sequence_and_triggers self.execute('CREATE SEQUENCE %s;' % sequence_name) File /home/www-data/web2py/gluon/dal.py, line 1078, in execute return self.log_execute(*a, **b) File /home/www-data/web2py/gluon/dal.py, line 1075, in log_execute return self.cursor.execute(*a,**b) ProgrammingError: relation auth_user_id_seq already exists ERROR SNAPSHOT class 'psycopg2.ProgrammingError'(relation auth_user_id_seq already exists Frames File /home/www-data/web2py/gluon/restricted.py in restricted at line 188 code arguments variables File /home/www-data/web2py/applications/welcome/models/db.py in module at line 32 code arguments variables File /home/www-data/web2py/gluon/tools.py in define_tables at line 1177 code arguments variables File /home/www-data/web2py/gluon/dal.py in define_table at line 3489 code arguments variables File /home/www-data/web2py/gluon/dal.py in create_table at line 531 code arguments variables File /home/www-data/web2py/gluon/dal.py in create_sequence_and_triggers at line 1512 code arguments variables File /home/www-data/web2py/gluon/dal.py in execute at line 1078 code arguments variables File /home/www-data/web2py/gluon/dal.py in log_execute at line 1075 code arguments variables Function argument list (self=gluon.dal.PostgreSQLAdapter object, *a=('CREATE SEQUENCE auth_user_id_Seq;',), **b={}) Code listing 1070. 1071. 1072. 1073. 1074. 1075. 1076. 1077. 1078. 1079. def create_sequence_and_triggers(self, query, table, **args): self.execute(query) def log_execute(self,*a,**b): self.db._lastsql = a[0] return self.cursor.execute(*a,**b) def execute(self,*a,**b): return self.log_execute(*a, **b) Variables a('CREATE SEQUENCE auth_user_id_Seq;',) self.cursorcursor object at 0xba1152cc; closed: 0 selfgluon.dal.PostgreSQLAdapter object b{} self.cursor.executebuilt-in method execute of psycopg2._psycopg.cursor object
Re: [web2py] Database design challenge
I think the solution is use the third table article_author with both, author_id and article_id having an autocomplete widget. Then, add a button there to [create author if not exist][1]. I think all this can be performed in a [single form][2] kind regards. [1] http://www.web2pyslices.com/main/slices/take_slice/65 [2] http://www.web2pyslices.com/main/slices/take_slice/102 2011/2/4 Johann Spies johann.sp...@gmail.com: I would like to invite web2py users who enjoy such challenges to think with me about solving the following problem: Take two tables: db.define_table('article', Field(author_id, 'list:reference outeur'), Field(title)) db.define_table('author', Field('surname'), Field('initials')) Table 'article' contains 137000 records and author about 108000. The field definition of 'author_id' as list:reference would be ideal but in this case the list is too large and breaks javascript in the browser causing any crud.create or crud.update to take about 70 seconds to show the form. I am looking for a solution to be able to enter a new article while the same screen the user can either select an existing entry in 'author' or add a new author linked to the article if the author does not exist in the database. Keep in mind that one article can have several authors of which some may be in the database already and we try to avoid duplicate entries for the same author. Using an autocompletion widget for the author might have been useful if only one author per article was allowed. One possible solution is to create a third table for many-to-many relations: db.define_table('author_article', Field('article_id', db.article,requires = IS_IN_DB(db,'article.id')), Field('author_id', db.author,requires = IS_IN_DB(db,'author.id'))) In such a case how would one approach the entry forms in such a way that the user does not nead to choose different screens/menu options when the author is new or already in the database or when there are many authors for the same article? Regards Johann Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
[web2py] Book: Why Web2py
http://www.web2py.com/book/default/chapter/01#Why-web2py There must be an error... how one can compare Apache+mod_proxy speed Vs. Rocket?? Should that be Apache+mod_wsgi? mic
[web2py] Re: plugin_wiki routes.py
Hello Plumo, I used a solution to bypass the routes.py configuration... Instead create controllers and call those methods, I created some objects on models, instantiated them (using a file called z.py) and then called them on my default.py (like use Auth) So the only route I had to create is the one to my_app/default I don't know if it was the best solution, but I could create my own routes like: url - home url/posts/slug - show the posts using Slugs url/dashboard - call my dashboard and the methods associated etc... Regards, Igor Ps: Sorry for my bad english... On 3 fev, 23:19, Plumo richar...@gmail.com wrote: The default URL's when using plugin_wiki are ugly: /welcome/plugin_wiki/page/about Does anyone have a good routes.py for this?
[web2py] MySQL and web2py
Lets say I am running the web2py Server in windows. And for my mySQL database i am using http://www.uwamp.com/ Can web2py connect to that database using the connection string it has given in the example. What would i have to do to get the database working with web2py.
Re: [web2py] Re: form / subform / adding row (field)...
Here a other design I would implement... http://developer.android.com/resources/articles/contacts.html http://developer.android.com/resources/articles/contacts.htmlMaybe not the MIME type, but to normalize the relation in : Entity : Master result Repeated result Relation Master result one2many Repeated result With this schema the repeated result will be normalize level 1 since you have to identify each record refer to wich time point for example... So you get : Attributes Master result : Date Tech Comment Repeated result result time point FK master result Example many results in repeated result : result1, tp0, FK1 result2, tp1, FK1 result3, tp2, FK1 result1, tp0, FK2 result2, tp1, FK2 result3, tp2, FK2 Normalize level 1 cause of TP So I would do this : Entity : Master result Repeated result Time point Relation Master result one2many Repeated result Repeated result one2many Time point So now : Repeated result result1, FK1, FKTP1 result2, FK1, FKTP2 result3, FK1, FKTP3 result1, FK2, FKTP1 result2, FK2, FKTP2 result3, FK2, FKTP3 Time point id, tp 1, TP0 2, TP1 3, TP2 The form has to manage the insertion, update, read in 2 tables at a time since the time point records should be pretty much fixed. I think the Android contact interface and the google Contact are pretty much good example of what I would achieve. Richard On Wed, Feb 2, 2011 at 10:57 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: Ref about my search on this topic : RANDOM : NO ORDER Here the funding thread of WTForms FormBase : http://groups.google.com/group/wtforms/browse_frm/thread/c8b5f5d98c41a6d2/6e69c5c4e820fd7b?lnk=gstq=subform#6e69c5c4e820fd7b http://groups.google.com/group/wtforms/browse_frm/thread/c8b5f5d98c41a6d2/6e69c5c4e820fd7b?lnk=gstq=subform#6e69c5c4e820fd7b Subform seems a long awaiting feature : http://groups.google.com/group/web2py/browse_thread/thread/8d50fd87d0f2e233?pli=1 http://groups.google.com/group/web2py/browse_thread/thread/4cc5d30600c628bb http://web2py.uservoice.com/forums/42577-general/suggestions/525773-create-a-new-form-system-?ref=title Here the funding thread of WTForms FormBase : http://groups.google.com/group/wtforms/browse_frm/thread/c8b5f5d98c41a6d2/6e69c5c4e820fd7b?lnk=gstq=subform#6e69c5c4e820fd7b Looks like a solution : http://wtforms.simplecodes.com/ Django inline formset : http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-formsets There is also this : http://code.google.com/p/django-dynamic-formset/ That I already post above... That is something like what I did on cocaine for django ;-) Richard On Wed, Feb 2, 2011 at 10:34 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: The app I had attached in the preceding email works, but it broke the workflow. I can't get the added inputs values in form.vars, so I take them from request.vars or somewhere else don't remember... There is also an other problem with this hack... It not uses de validators for all the inputs... So as long as there is one filled input the form submit and the other added inputs will let pass empty value or if you prefer NULL will be inserted. But at least you will be able to add all the field you want no matter how many field the subform contain... Remove the added field you no more want if you add to much inputs. Submit and the data will be all linked or related to the id of the record of the master table or the base table form. The jQuery script has to be edited by hand for each subform (or subtable you use). If you modify your subtable (add a field) you will have to go change the jQuery script... I just tried to make a proof of concept and see what were the limits... So nothing fancy with the code. There is also a couple of jQuery lines that were not working properly in this version I think. Ha yeah there is an other issue on read or update... There is no way to make it works with crud.read or crud.update (I did not try anything about that when I realize I broked the workflow). Also, there is no way to make SQLFORM.factory works on update or read (edit your linked data)... At least there is no easy already available way. You have to crud.update on subtable and master table independantly to make any change after the first seizure. I did not have time last week to continue to work on that. I identified differents alternatives that I did not explored in details yet : 1) There is a lib in django for doing exactly that. I don't know django, but the basic (tutorial 1, 2, 3, 4). 2) There is also Pyjamas that could be use into web2py... It seems to me the most cumbersome alternative, since I have to learn many differents things. 3) WTForms... I also have to learn a lot to figure out if it could work with web2py or if it has to be stand alone. If it needs work separately I actualy think to explore if a loosely coupled framework could be more reliable for my needs (Flask, WTForms, WSGI, jinja...) That
Re: [web2py] MySQL and web2py
I do not know how uwamp works, but for sure, web2py will connect to mysql using the connection string: mysql://username:password@localhost/test Just take the username, password, ip or host name and datatabase name in your model file define: db = DAL('mysql://username:password@localhost/test') http://www.web2py.com/book/default/chapter/06#Connection-Strings -- Bruno Rocha http://about.me/rochacbruno/bio 2011/2/4 stargate kyoukh...@gmail.com Lets say I am running the web2py Server in windows. And for my mySQL database i am using http://www.uwamp.com/ Can web2py connect to that database using the connection string it has given in the example. What would i have to do to get the database working with web2py.
[web2py] Re: postgresql error ... class 'psycopg2.ProgrammingError'(relation auth_user already exists)
You are using web2py trunk right? Did you set a sequence_name manually? On Feb 4, 7:22 am, Tom Atkins minkto...@gmail.com wrote: I am getting the same error as reported by Carlos and cannot fix it. I have just set up a new server (Ubuntu 10.04 - postgres 8.4, Python 2.6.5) and have web2py trunk up and running fine. I have an unmodified 'welcome' app which runs perfectly with sqlite. I then delete all the files in databases, cache and sessions. Next I create a postgresql database and grant permissions to the appropriate user. I have double checked this and the user can create tables on the database. Next change the connection details in the welcome app db.py to: db = DAL('postgres://myuser:mypasswordlocalhost/mydb') Then visit the URL and I get the ticket below. Any help gratefully appreciated. (I had this running fine on a previous server) Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /home/www-data/web2py/applications/welcome/models/db.py, line 32, in module auth.define_tables() # creates all needed tables File /home/www-data/web2py/gluon/tools.py, line 1177, in define_tables format='%(first_name)s %(last_name)s (%(id)s)') File /home/www-data/web2py/gluon/dal.py, line 3489, in define_table polymodel=polymodel) File /home/www-data/web2py/gluon/dal.py, line 531, in create_table self.create_sequence_and_triggers(query,table) File /home/www-data/web2py/gluon/dal.py, line 1512, in create_sequence_and_triggers self.execute('CREATE SEQUENCE %s;' % sequence_name) File /home/www-data/web2py/gluon/dal.py, line 1078, in execute return self.log_execute(*a, **b) File /home/www-data/web2py/gluon/dal.py, line 1075, in log_execute return self.cursor.execute(*a,**b) ProgrammingError: relation auth_user_id_seq already exists ERROR SNAPSHOT class 'psycopg2.ProgrammingError'(relation auth_user_id_seq already exists Frames File /home/www-data/web2py/gluon/restricted.py in restricted at line 188 code arguments variables File /home/www-data/web2py/applications/welcome/models/db.py in module at line 32 code arguments variables File /home/www-data/web2py/gluon/tools.py in define_tables at line 1177 code arguments variables File /home/www-data/web2py/gluon/dal.py in define_table at line 3489 code arguments variables File /home/www-data/web2py/gluon/dal.py in create_table at line 531 code arguments variables File /home/www-data/web2py/gluon/dal.py in create_sequence_and_triggers at line 1512 code arguments variables File /home/www-data/web2py/gluon/dal.py in execute at line 1078 code arguments variables File /home/www-data/web2py/gluon/dal.py in log_execute at line 1075 code arguments variables Function argument list (self=gluon.dal.PostgreSQLAdapter object, *a=('CREATE SEQUENCE auth_user_id_Seq;',), **b={}) Code listing 1070. 1071. 1072. 1073. 1074. 1075. 1076. 1077. 1078. 1079. def create_sequence_and_triggers(self, query, table, **args): self.execute(query) def log_execute(self,*a,**b): self.db._lastsql = a[0] return self.cursor.execute(*a,**b) def execute(self,*a,**b): return self.log_execute(*a, **b) Variables a('CREATE SEQUENCE auth_user_id_Seq;',) self.cursorcursor object at 0xba1152cc; closed: 0 selfgluon.dal.PostgreSQLAdapter object b{} self.cursor.executebuilt-in method execute of psycopg2._psycopg.cursor object
Re: [web2py] MySQL and web2py
you need to define your models before using dal expressions or you can execute raw sql db = DAL('mysql://username:password@localhost/test') list_of_dicts = db.executesql(SELECT * FROM mytable, as_dict=True)
[web2py] How do I explicitly close a database connection?
How do I explicitly close a database connection?
Re: [web2py] Form to Email
a sample (in portuguese, just change the name or fields): in controller: def fale_conosco(): form = SQLFORM.factory( Field('nome', requires=IS_NOT_EMPTY(error_message='Preencha o seu nome')), Field('email', requires=IS_EMAIL()), Field('motivo',requires=IS_EMPTY_OR(IS_IN_SET(['Sugestão','Reclamação','Elogio','Dúvida','Outros']))), Field('titulo', label = 'Título', requires=IS_NOT_EMPTY(error_message='Preencha o título')), Field('mensagem','text', label= 'Descrição', requires=IS_NOT_EMPTY(error_message='Escreva sua mensagem')), submit_button=Enviar) if form.accepts(request.vars, session): mensagem = form.vars.nome+' '+form.vars.email+'brEnviou '+form.vars.motivo+': br'+form.vars.mensagem context = dict(person=form.vars.email) status = mail.send(to=['y...@email.com'],reply_to=form.vars.email, subject=form.vars.tipo+' - '+form.vars.titulo , message=[None,mensagem]) if status == True: response.flash='Obrigado por entrar em contato. Responderemos em breve' else: response.flash='Ocorreu um erro e não foi possível enviar sua mensagem' else: response.flash='Preencha os campos solicitados no formulário' return dict(form=form) in the view, just use: {{=form}} 2011/2/3 bee beeg...@hotmail.com I expect that I am going about this the wrong way but here it goes.. I am currently designing a form for my web2py website. When the user clicks submit I would like my application to send me the form fields via email. My hosting provider will supply form mail.php files: On Linux hosting accounts, this will re-install the gdform.php, webformmailer.php, and gdform.cgi (this is in the cgi directory) form-mailer scripts for your hosting account Can I utilize these? -- Atenciosamente Alexandre Andrade Hipercenter.com Classificados Gratuitos e Inteligentes
[web2py] dal to use a limited number of connections
hi, I use dal standalone with gevent for a high io bound program, there are thousands of users each with his own database (mysql), I update some tables with info from the web, and to make it fast I use a few hundreds greenlets, that means each has a db (DAL) object, which use a db connection how to use only a few connections with dal, or what I need to change to do so even if that means to use just one connection, database operations are much faster so it doesn't affect too much overall performance usin pool_size doesn't help because it reuse connections for the same connection string, that means it can use a few connections for the same database, but I need a pool for all databases
Re: [web2py] http and https
you just need to setup it in apache, like in the book: http://web2py.com/book/default/chapter/11#mod_wsgi http://web2py.com/book/default/chapter/11#mod_wsgiand: http://web2py.com/book/default/chapter/11#mod_wsgi-and-SSL http://web2py.com/book/default/chapter/11#mod_wsgi-and-SSLOr if you use ubuntu/debian, just: http://web2py.com/book/default/chapter/11#One-Step-Production-Deployment http://web2py.com/book/default/chapter/11#One-Step-Production-Deployment 2011/2/3 Martin Weissenboeck mweis...@gmail.com Hi, I want to use one server with two addresses, e.g. http://www.mydomain.org:80 and https://secure.mydomain.org:443 What shall I do: - start two instances of web2py - or use URL-rewrite? Regards, Martin -- Atenciosamente Alexandre Andrade Hipercenter.com Classificados Gratuitos e Inteligentes
[web2py] Re: Few general questions
Thanks for your reply. Regarding the first answer: does it mean that every model from my app will be called on every page refresh? Do the names of the model files have any effect? I.e. if I rename db.py to mydb.py, or change 0.py to something else - what will happen behind the scene? Regarding my third question: the tree structure is something that I did understand. The problem is an error which makes me think that I do something wrong. While trying to perform the described above, I the following traceback: Traceback (most recent call last): File C:\Users\viu\Desktop\web2py\gluon\restricted.py, line 188, in restricted exec ccode in environment File C:\Users\viu\Desktop\web2py\applications\Registrar/views \default/index.html, line 99, in module AttributeError: 'NoneType' object has no attribute 'replace'. I have index.html with include 'default/user.html'. user.html doesn't have extend. Regarding my last question, I will try to clarify: I found out that after uploading the app to GAE, the example records are being added to my app at GAE. I.e. I have: Sacemoso Mamaduco Dacotata papapato@exam in my online app. I have already cleared my GAE datastore once. Thanks again. On Feb 4, 6:10 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: On Feb 3, 8:27 pm, devGS vitali@geniestills.com wrote: Hi, I have a few general questions, answers for which I didn't find in the book: 1. How does the model work in web2py's MVC? What is the workflow? When does the code from those files called? The only relevant information I found was the sequence diagram from the book. yes this is an important omission. at every http request, all models are executed in the same environment. Then environment is copied. The requested controller is executed and the called function is called. The output dict() is added to the copied environment and passed to the view. The output is returned to the visitor. 2. How does the following form of passing arguments in Python work: cache.ram.clear(regex='...')? I come from Java, as I understand regex is some kind of an optional value to be passed? regex is any regular expression. All keys in the cache matching the regular expression are deleted from the cache. 3. How do the layouts work (layout as a pattern that is being used in the views)? I tried to do the following, which sometimes works and sometimes not, providing errors: remove the {{extend 'layout.html'}} from some view, i.e. myview.html and add {{include myview.html}} into a second view. Mainly, it works, but when I try to remove {{extend 'layout.html'}} from default/user.html and add {{include 'default/user.html'}} into index.html, it fails. Why, and how to do it properly? Think of a tree. Each node is an HTML file. You move up by calling extend. You move down by calling include. The parent should have a simple {{include}} not {{include child.html}} where the extending child is to be inserted. This is in the book in some detail. 4. I understood that in order to manipulate my database from GAE, I need to index my tables. Where can I find information about indexing and what is it? You only need this for speed. You have to do this in sql db.executesql() 5. While uploading my app into GAE, I find the example entries inside my online GAE app. Why is that and how to prevent it? I am not sure I understand this question.
[web2py] Create databases folder
Isn't web2py supposed to create the databases, sessions, uploads, etc folders if they don't exist? -- Thadeus
Re: [web2py] Re: Few general questions
The model files will be executed in alfabetical order. So there is a difference. Kenneth - Ursprungsmeddelande - Thanks for your reply. Regarding the first answer: does it mean that every model from my app will be called on every page refresh? Do the names of the model files have any effect? I.e. if I rename db.py to mydb.py, or change 0.py to something else - what will happen behind the scene? Regarding my third question: the tree structure is something that I did understand. The problem is an error which makes me think that I do something wrong. While trying to perform the described above, I the following traceback: Traceback (most recent call last): File C:\Users\viu\Desktop\web2py\gluon\restricted.py, line 188, in restricted exec ccode in environment File C:\Users\viu\Desktop\web2py\applications\Registrar/views \default/index.html, line 99, in module AttributeError: 'NoneType' object has no attribute 'replace'. I have index.html with include 'default/user.html'. user.html doesn't have extend. Regarding my last question, I will try to clarify: I found out that after uploading the app to GAE, the example records are being added to my app at GAE. I.e. I have: Sacemoso Mamaduco Dacotata papapato@exam in my online app. I have already cleared my GAE datastore once. Thanks again. On Feb 4, 6:10 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: On Feb 3, 8:27 pm, devGS vitali@geniestills.com wrote: Hi, I have a few general questions, answers for which I didn't find in the book: 1. How does the model work in web2py's MVC? What is the workflow? When does the code from those files called? The only relevant information I found was the sequence diagram from the book. yes this is an important omission. at every http request, all models are executed in the same environment. Then environment is copied. The requested controller is executed and the called function is called. The output dict() is added to the copied environment and passed to the view. The output is returned to the visitor. 2. How does the following form of passing arguments in Python work: cache.ram.clear(regex='...')? I come from Java, as I understand regex is some kind of an optional value to be passed? regex is any regular expression. All keys in the cache matching the regular expression are deleted from the cache. 3. How do the layouts work (layout as a pattern that is being used in the views)? I tried to do the following, which sometimes works and sometimes not, providing errors: remove the {{extend 'layout.html'}} from some view, i.e. myview.html and add {{include myview.html}} into a second view. Mainly, it works, but when I try to remove {{extend 'layout.html'}} from default/user.html and add {{include 'default/user.html'}} into index.html, it fails. Why, and how to do it properly? Think of a tree. Each node is an HTML file. You move up by calling extend. You move down by calling include. The parent should have a simple {{include}} not {{include child.html}} where the extending child is to be inserted. This is in the book in some detail. 4. I understood that in order to manipulate my database from GAE, I need to index my tables. Where can I find information about indexing and what is it? You only need this for speed. You have to do this in sql db.executesql() 5. While uploading my app into GAE, I find the example entries inside my online GAE app. Why is that and how to prevent it? I am not sure I understand this question.
[web2py] is this possible with computed
Hello Dear web2py users, I would like to achieve this. I have a referenced field 1 to many The referenced table is mostly for storing the dropdown option. So I have : IS_IN_DB(choice1, choice2, etc.) I would like to add on the same form a empty choice field that could populate the referenced choice table... Field ('choice_id', db.choice), db.choice # That let add new choice. But 1) If the db.choice input is empty don't want add NULL value 2) I would if no choice is made and a new choice is added that choice_id takes the id of the new added choice... Can I get something to work with compute that seems reserved for only one table. How to prevent a empty db.choice input to be inserted... Is there any validator that could applied?? Thanks Richard
[web2py] Re: How do I explicitly close a database connection?
db._adapter.connection.close() On Feb 4, 10:24 am, vortex billyara...@gmail.com wrote: How do I explicitly close a database connection?
[web2py] Re: Create databases folder
yes. Except on GAE. Is it not? On Feb 4, 11:36 am, Thadeus Burgess thade...@thadeusb.com wrote: Isn't web2py supposed to create the databases, sessions, uploads, etc folders if they don't exist? -- Thadeus
Re: [web2py] Create databases folder
2011/2/4 Thadeus Burgess thade...@thadeusb.com Isn't web2py supposed to create the databases, sessions, uploads, etc folders if they don't exist? in which case? running from terminal I do: ## $ python web2py.py -S myapp -M -P web2py Enterprise Web Framework Created by Massimo Di Pierro, Copyright 2007-2011 Version 1.91.6 (2011-01-30 18:30:25) Database drivers available: SQLite3, pymysql, CouchDB application myapp does not exist, create (y/n)?y ## web2py created the files for me: ### $ pwd ../web2py/applications/myapp $ ls ABOUT controllers databases __init__.py LICENSE modules sessions uploads cache cron errors languagesmodels private static views if I delete i.e session folder ## $ rm -R sessions/ $ ls ABOUT controllers databases __init__.py LICENSE modules static views cache cron errors languagesmodels private uploads # then I run web2py again ## $python web2py.py -a 1234 ## Sessions folder is created for me ## $ ls ABOUT controllers databases __init__.py LICENSE modules sessions uploads cache cron errors languagesmodels private static views ### I tried with database and upload, all running fine using web2py from trunk.
Re: [web2py] Create databases folder
I now removed ['cache','cron','uploads','databases','sessions'] ran web2py and it created all folders for me.
Re: [web2py] Re: postgresql error ... class 'psycopg2.ProgrammingError'(relation auth_user already exists)
On 4 February 2011 14:33, Massimo Di Pierro massimo.dipie...@gmail.comwrote: You are using web2py trunk right? Yes - just a clean version of web2py pulled by Hg from Google code. Did you set a sequence_name manually? No (not even sure what sequence_name is!) - I tried another app of my own and get the same result.
[web2py] Re: postgresql error ... class 'psycopg2.ProgrammingError'(relation auth_user already exists)
This is a trunk bug. The problem does should be there in stable. I will fix this tonight. On Feb 4, 12:50 pm, Tom Atkins minkto...@gmail.com wrote: On 4 February 2011 14:33, Massimo Di Pierro massimo.dipie...@gmail.comwrote: You are using web2py trunk right? Yes - just a clean version of web2py pulled by Hg from Google code. Did you set a sequence_name manually? No (not even sure what sequence_name is!) - I tried another app of my own and get the same result.
[web2py] Re: LIKE case sensitivity: Postgres differs to MySQL = DAL not portable
On 29 янв, 04:53, Thadeus Burgess thade...@thadeusb.com wrote: IMHO This breaks backwards compatibility... If .like() should match case-insensitive then this is bug fix. At http://web2py.com/book/ this does not specified explicitly. PS. .ilike for case insensitive? I think the question is, to make it available for all supported databases.
[web2py] IS_NOT_IN_DB failing to create a dropdown?
Hi, First off, I've already fixed my problem by coding it differently. However, I was curious as to the proper way to set up this validator so it shows a dropdown. I have two models, which can be simplified to: db.define_table('booth', Field('name','string',length=10,required=True,notnull=True,unique=True)) db.define_table('lease', Field('booth',db.booth), Field('end_date','date')) When creating a new lease, the SQLFORM field to pick a booth to attach should only show booths which have no lease. So I added this in the controller: def new(): db.lease.booth.requires = IS_NOT_IN_DB(db(db.lease.end_date == None)),'lease.booth') This promptly transformed the booth dropdown into a text box. It worked fine if, when testing, I used IS_IN_DB instead (showing only booths with current leases, which is of course backwards, but it showed them as a dropdown). I know that if you put the validators in a list they will not create dropdowns, and I made sure that my validator was not in a list. So instead I switched to this: def new(): leased_booths = db(db.lease.end_date == None)._select(db.lease.booth) db.lease.booth.requires = IS_IN_DB(db(~(db.booth.id.belongs(leased_booths))),'booth.id','% (name)s') which is a bit less efficient but displays the desired behavior. Is there a more web2py-ish way to accomplish this, or is IS_NOT_IN_DB not supposed to display a dropdown? From my reading of the documentation, I thought it was supposed to do so.
[web2py] drop support for python 2.4?
@web2py-developers we have discussing the possibility of dropping support for Python 2.4. So far we have put a great effor t in having web2py run on 2.4 because this is the default python version on CentOS for shared hosts. Yet by dropping support we could improve the code base, make it more readable and expose new syntax to users. Who strongly opposes? Make your case.
Re: [web2py] Create databases folder
Nope not working for me. A raw checkout of a branch, there is no NEWINSTALL file, nor a welcome.w2p file since we don't need it. The app only contains controllers, cron, languages, models, modules, static, tests, views, __init__.py. From this state, when starting web2py just by python web2py.py. Navigate to the app in firefox or other web browser, and it crashes because it cannot connect to the sqlite database 5 times, this is because the databases folder does not exist from a raw checkout of our app, and web2py does not seem to be creating any of the folders. If I navigate into my app directory, and run ``mkdir databases`` then navigate to the app, everything is fine, and web2py ends up making the uploads, private, cache, sessions, and errors folders. -- Thadeus On Fri, Feb 4, 2011 at 12:06 PM, Bruno Rocha rochacbr...@gmail.com wrote: I now removed ['cache','cron','uploads','databases','sessions'] ran web2py and it created all folders for me.
[web2py] Re: Few general questions
Thanks! I'd be glad to get help about the last two issues I described. On Feb 4, 7:43 pm, Kenneth Lundström kenneth.t.lundst...@gmail.com wrote: The model files will be executed in alfabetical order. So there is a difference. Kenneth - Ursprungsmeddelande - Thanks for your reply. Regarding the first answer: does it mean that every model from my app will be called on every page refresh? Do the names of the model files have any effect? I.e. if I rename db.py to mydb.py, or change 0.py to something else - what will happen behind the scene? Regarding my third question: the tree structure is something that I did understand. The problem is an error which makes me think that I do something wrong. While trying to perform the described above, I the following traceback: Traceback (most recent call last): File C:\Users\viu\Desktop\web2py\gluon\restricted.py, line 188, in restricted exec ccode in environment File C:\Users\viu\Desktop\web2py\applications\Registrar/views \default/index.html, line 99, in module AttributeError: 'NoneType' object has no attribute 'replace'. I have index.html with include 'default/user.html'. user.html doesn't have extend. Regarding my last question, I will try to clarify: I found out that after uploading the app to GAE, the example records are being added to my app at GAE. I.e. I have: Sacemoso Mamaduco Dacotata papapato@exam in my online app. I have already cleared my GAE datastore once. Thanks again. On Feb 4, 6:10 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: On Feb 3, 8:27 pm, devGS vitali@geniestills.com wrote: Hi, I have a few general questions, answers for which I didn't find in the book: 1. How does the model work in web2py's MVC? What is the workflow? When does the code from those files called? The only relevant information I found was the sequence diagram from the book. yes this is an important omission. at every http request, all models are executed in the same environment. Then environment is copied. The requested controller is executed and the called function is called. The output dict() is added to the copied environment and passed to the view. The output is returned to the visitor. 2. How does the following form of passing arguments in Python work: cache.ram.clear(regex='...')? I come from Java, as I understand regex is some kind of an optional value to be passed? regex is any regular expression. All keys in the cache matching the regular expression are deleted from the cache. 3. How do the layouts work (layout as a pattern that is being used in the views)? I tried to do the following, which sometimes works and sometimes not, providing errors: remove the {{extend 'layout.html'}} from some view, i.e. myview.html and add {{include myview.html}} into a second view. Mainly, it works, but when I try to remove {{extend 'layout.html'}} from default/user.html and add {{include 'default/user.html'}} into index.html, it fails. Why, and how to do it properly? Think of a tree. Each node is an HTML file. You move up by calling extend. You move down by calling include. The parent should have a simple {{include}} not {{include child.html}} where the extending child is to be inserted. This is in the book in some detail. 4. I understood that in order to manipulate my database from GAE, I need to index my tables. Where can I find information about indexing and what is it? You only need this for speed. You have to do this in sql db.executesql() 5. While uploading my app into GAE, I find the example entries inside my online GAE app. Why is that and how to prevent it? I am not sure I understand this question.
[web2py] How do I create a new child process from controller?
Hi All, Sorry for the bother. I would like to consult if there is a way to create a totally separated child process process unsing popen class (subprocess module) from a controller. I would like to be able to launch a new child process outside web2py execution environment when an SOAP message arrives to the web2py server. I am planning to build an web application to control process creation and termination. any help will be appreciated! Thanks and best regards, Martin
[web2py] Re: How do I create a new child process from controller?
Don't because the parent process is created by the web server (and that may not be rocket) and the web server can kill and restart processes at will. Have a separate background process make children. have the app simply queue tasks (using a task table for example) and have the background process pick-up the tasks and act on them. On Feb 4, 4:08 pm, Martin mbertol...@gmail.com wrote: Hi All, Sorry for the bother. I would like to consult if there is a way to create a totally separated child process process unsing popen class (subprocess module) from a controller. I would like to be able to launch a new child process outside web2py execution environment when an SOAP message arrives to the web2py server. I am planning to build an web application to control process creation and termination. any help will be appreciated! Thanks and best regards, Martin
[web2py] Re: Create databases folder
If migrate is True on your Fields then web2py will want to have the databases directory existing first as it tries to open databases/ sql.log first. If this directory doesn't exist then an exception is thrown. web2py$ ls -FC applications/newapp/ ABOUT __init__.py controllers/ languages/ modules/views/ LICENSE cache/ cron/ models/ static/ wizard.metadata web2py$ python web2py.py -S newapp -M web2py Enterprise Web Framework Created by Massimo Di Pierro, Copyright 2007-2011 Version 1.91.6 (2011-02-01 17:13:19) Database drivers available: SQLite3, pymysql, PostgreSQL Traceback (most recent call last): File /Users/grutz/src/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File applications/newapp/models/db.py, line 80, in module auth.define_tables(migrate=settings.migrate) # creates all needed tables File /Users/grutz/src/web2py/gluon/tools.py, line 1198, in define_tables format = '%(role)s (%(id)s)') File /Users/grutz/src/web2py/gluon/dal.py, line 3490, in define_table polymodel=polymodel) File /Users/grutz/src/web2py/gluon/dal.py, line 522, in create_table logfile = self.file_open(table._loggername, 'a') File /Users/grutz/src/web2py/gluon/dal.py, line 359, in file_open fileobj = open(filename,mode) IOError: [Errno 2] No such file or directory: 'applications/newapp/ databases/sql.log' web2py$ mkdir applications/newapp/databases web2py$ python web2py.py -S newapp -M web2py Enterprise Web Framework Created by Massimo Di Pierro, Copyright 2007-2011 Version 1.91.6 (2011-02-01 17:13:19) Database drivers available: SQLite3, pymysql, PostgreSQL Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32) Type copyright, credits or license for more information. IPython 0.10.1 -- An enhanced Interactive Python. ? - Introduction and overview of IPython's features. %quickref - Quick reference. help - Python's own help system. object? - Details about 'object'. ?object also works, ?? prints more. In [1]:
Re: [web2py] Re: Create databases folder
I know. I thought that this had been patched in web2py, and I was just wondering the feature got lost in the translation to the new DAL. -- Thadeus On Fri, Feb 4, 2011 at 4:16 PM, Kurt Grutzmacher gr...@jingojango.netwrote: If migrate is True on your Fields then web2py will want to have the databases directory existing first as it tries to open databases/ sql.log first. If this directory doesn't exist then an exception is thrown. web2py$ ls -FC applications/newapp/ ABOUT __init__.py controllers/ languages/ modules/views/ LICENSE cache/ cron/ models/ static/ wizard.metadata web2py$ python web2py.py -S newapp -M web2py Enterprise Web Framework Created by Massimo Di Pierro, Copyright 2007-2011 Version 1.91.6 (2011-02-01 17:13:19) Database drivers available: SQLite3, pymysql, PostgreSQL Traceback (most recent call last): File /Users/grutz/src/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File applications/newapp/models/db.py, line 80, in module auth.define_tables(migrate=settings.migrate) # creates all needed tables File /Users/grutz/src/web2py/gluon/tools.py, line 1198, in define_tables format = '%(role)s (%(id)s)') File /Users/grutz/src/web2py/gluon/dal.py, line 3490, in define_table polymodel=polymodel) File /Users/grutz/src/web2py/gluon/dal.py, line 522, in create_table logfile = self.file_open(table._loggername, 'a') File /Users/grutz/src/web2py/gluon/dal.py, line 359, in file_open fileobj = open(filename,mode) IOError: [Errno 2] No such file or directory: 'applications/newapp/ databases/sql.log' web2py$ mkdir applications/newapp/databases web2py$ python web2py.py -S newapp -M web2py Enterprise Web Framework Created by Massimo Di Pierro, Copyright 2007-2011 Version 1.91.6 (2011-02-01 17:13:19) Database drivers available: SQLite3, pymysql, PostgreSQL Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32) Type copyright, credits or license for more information. IPython 0.10.1 -- An enhanced Interactive Python. ? - Introduction and overview of IPython's features. %quickref - Quick reference. help - Python's own help system. object? - Details about 'object'. ?object also works, ?? prints more. In [1]:
[web2py] Re: How do I create a new child process from controller?
Thank you very much Massimo for your reply! Take care!
Re: [web2py] Create databases folder
On Feb 4, 2011, at 1:19 PM, Thadeus Burgess wrote: Nope not working for me. A raw checkout of a branch, there is no NEWINSTALL file, nor a welcome.w2p file since we don't need it. The app only contains controllers, cron, languages, models, modules, static, tests, views, __init__.py. From this state, when starting web2py just by python web2py.py. Navigate to the app in firefox or other web browser, and it crashes because it cannot connect to the sqlite database 5 times, this is because the databases folder does not exist from a raw checkout of our app, and web2py does not seem to be creating any of the folders. If I navigate into my app directory, and run ``mkdir databases`` then navigate to the app, everything is fine, and web2py ends up making the uploads, private, cache, sessions, and errors folders. Odd. The admin.create_missing_app_folders() call in main.wsgibase should be creating the folder. Could you throw a couple of strategic debug prints into that function and see what's going on?
Re: [web2py] http and https
On Feb 4, 2011, at 1:54 AM, Martin Weissenboeck wrote: Thanks for all answers. A second question: If I want to use port 8000 for http and 8001 for https: is it possible to write routers = dict( BASE = dict( domains = { 'http://www.domain.com:8000' : 'myappname1', 'https://www.domain.com:8001' : 'myappname2', } ), ) Or: how does web2py know which protocol should be used? The domains dict does not support the scheme string. Your example above needs to be: routers = dict( BASE = dict( domains = { 'www.domain.com:8000' : 'myappname1', 'www.domain.com:8001' : 'myappname2', } ), ) web2py doesn't need to know what the protocol is (and for that matter has no guaranteed way of finding out, though often it's available from the server). But if both http and https are supported, they can't both be on the same domain:port combination. So (as above) use the port to distinguish.
[web2py] Pull user out of gluon?
Pardon me if this is a naive question but I'm wondering if it would make sense to pull all of the user functionality out of gluon and put it in the app? I ask because there are quite a few customizations I'd like to do and am not really sure where to start. Could not user be delivered from an app controller user.py (plus views)?
[web2py] Re: Create databases folder
As Jonathan says, it is main that creates the missing folders, the first time the app is accessed. dal just assumes it is there. On Feb 4, 4:56 pm, Jonathan Lundell jlund...@pobox.com wrote: On Feb 4, 2011, at 1:19 PM, Thadeus Burgess wrote: Nope not working for me. A raw checkout of a branch, there is no NEWINSTALL file, nor a welcome.w2p file since we don't need it. The app only contains controllers, cron, languages, models, modules, static, tests, views, __init__.py. From this state, when starting web2py just by python web2py.py. Navigate to the app in firefox or other web browser, and it crashes because it cannot connect to the sqlite database 5 times, this is because the databases folder does not exist from a raw checkout of our app, and web2py does not seem to be creating any of the folders. If I navigate into my app directory, and run ``mkdir databases`` then navigate to the app, everything is fine, and web2py ends up making the uploads, private, cache, sessions, and errors folders. Odd. The admin.create_missing_app_folders() call in main.wsgibase should be creating the folder. Could you throw a couple of strategic debug prints into that function and see what's going on?
[web2py] Re: Pull user out of gluon?
You can do that. At three levels: 1) in models from gluon.tools import Auth class MyAuth(Auth): pass # extend as needed Auth=MyAuth 2) in controllers: normally in default.py there is def user(): return dict(form=auth()) you can move this code in another controller and break it up into seperate actions for example def login(): return dict(form=auth.login()) 3) in views there is a default/user.html again you can rewrite this as you see fit and break it into multiple views. On Feb 4, 6:25 pm, pbreit pbreitenb...@gmail.com wrote: Pardon me if this is a naive question but I'm wondering if it would make sense to pull all of the user functionality out of gluon and put it in the app? I ask because there are quite a few customizations I'd like to do and am not really sure where to start. Could not user be delivered from an app controller user.py (plus views)?
[web2py] How to get request
I define a decorator into the modules folder and try get request.args. How to do correct import of request and use it in my decorator? I try something like this: env = globals() args = env.request.args
Re: [web2py] How to get request
On Feb 4, 2011, at 2:28 PM, walter wrote: I define a decorator into the modules folder and try get request.args. How to do correct import of request and use it in my decorator? I try something like this: env = globals() args = env.request.args An imported module has its own namespace, so it doesn't know about request. Can you pass it in?
[web2py] Auth message internationalizaton
My last question has been solved. I dont remember the original message, but the problem is how to tranlate the message Registration needs vefificaiton initialized at Auth. Simply put the line T = self.environment.T and parenthese the phrases in this function. Thank you
[web2py] Re: IS_MATCH() changing a valid value ?
That change would have prevented my problem. However, would it guaranty that the returned (accepted) match.group() value would never differ from the input value? I am worried about more complex queries now. I still think that if IS_MATCH() finds that it has accepted something that is not the input value, it should return an error. Ken On Feb 3, 6:35 pm, Jonathan Lundell jlund...@pobox.com wrote: On Feb 3, 2011, at 3:03 PM, Ken wrote: You are right. Having (re)read the documentation for re, I find that it is working as advertised. My original regex was wrong. However, I would argue that if the match found by regex.match() is different from the input value, IS_MATCH should return an error. That is, in the IS_MATCH.__call__ definition, if match: should be if match and (value == match.group():. That change would raise an error that would force a user like me to correct a regex that was matching in an unexpected way. I would never want IS_MATCH to silently change data between a form and insertion into a database. IS_MATCH is already implicitly anchored at the beginning of the field, since it uses re.match. I think it'd make sense to implicitly anchor at the end as well. We could change this: self.regex = re.compile(expression) to this: self.regex = re.compile('(%s)$' % expression) Ken On Feb 2, 9:13 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: This is the correct behavio of regular expressions. Anyway, good that you are pointing this out since others may find it counter intuitive. Massimo On Feb 2, 6:33 pm, Ken kenma...@mac.com wrote: I have been having trouble with truncation of data from one field of a form. The culprit turned out to be the IS_MATCH() validator, which was truncating a valid value to return a shorter valid value. I'm not sure whether to call this a bug or just unexpected behavior, but if I had trouble with it, someone else may. The data in question were spreadsheet-style coordinate values with letters for rows and numbers for columns, in the range A1 to J10. Initially, I used a validator like IS_MATCH('^[A-J][1-9]|[A-J]10$'). This checks first for the two-character combinations A1 to J9, then checks for A10 to J10. If I test this in a web2py shell, it accepts and returns the two-character combinations, but it accepts and truncates any values ending in 10. In [1] : vdtr = IS_MATCH('^[A-J][1-9]|[A-J]10$') In [2] : vdtr('A1') ('A1', None) In [3] : vdtr('J1') ('J1', None) In [4] : vdtr('A10') ('A1', None) In [5] : vdtr('J10') ('J1', None) It seems to me that A1 and J1 are not proper matches because the '1' does not appear at the end of the validated string. In any case, I am surprised that IS_MATCH() would modify a value under any circumstances. If I turn the regex around, so that it tests for the three-character combinations first, like IS_MATCH('^[A-J]10|[A-J][1-9]$'), then things work better. In [6] : vdtr = IS_MATCH('^[A-J]10|[A-J][1-9]$') In [7] : vdtr('A1') ('A1', None) In [8] : vdtr('J1') ('J1', None) In [9] : vdtr('A10') ('A10', None) In [10] : vdtr('J10') ('J10', None)
[web2py] Re: IS_MATCH() changing a valid value ?
Validators are filters. They do not always return what is passed as input. It is a feature. For example IS_INT_IN_RANGE() takes a string and returns an int. IS_DATE, takes a string in the internationalization format and returns a datetime.date(). IS_SLUG(), sluggifies (probably the verb does not exist). There is no reason why IS_MATH should not be allowed to transform the input. On Feb 4, 8:17 pm, Ken kenma...@mac.com wrote: That change would have prevented my problem. However, would it guaranty that the returned (accepted) match.group() value would never differ from the input value? I am worried about more complex queries now. I still think that if IS_MATCH() finds that it has accepted something that is not the input value, it should return an error. Ken On Feb 3, 6:35 pm, Jonathan Lundell jlund...@pobox.com wrote: On Feb 3, 2011, at 3:03 PM, Ken wrote: You are right. Having (re)read the documentation for re, I find that it is working as advertised. My original regex was wrong. However, I would argue that if the match found by regex.match() is different from the input value, IS_MATCH should return an error. That is, in the IS_MATCH.__call__ definition, if match: should be if match and (value == match.group():. That change would raise an error that would force a user like me to correct a regex that was matching in an unexpected way. I would never want IS_MATCH to silently change data between a form and insertion into a database. IS_MATCH is already implicitly anchored at the beginning of the field, since it uses re.match. I think it'd make sense to implicitly anchor at the end as well. We could change this: self.regex = re.compile(expression) to this: self.regex = re.compile('(%s)$' % expression) Ken On Feb 2, 9:13 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: This is the correct behavio of regular expressions. Anyway, good that you are pointing this out since others may find it counter intuitive. Massimo On Feb 2, 6:33 pm, Ken kenma...@mac.com wrote: I have been having trouble with truncation of data from one field of a form. The culprit turned out to be the IS_MATCH() validator, which was truncating a valid value to return a shorter valid value. I'm not sure whether to call this a bug or just unexpected behavior, but if I had trouble with it, someone else may. The data in question were spreadsheet-style coordinate values with letters for rows and numbers for columns, in the range A1 to J10. Initially, I used a validator like IS_MATCH('^[A-J][1-9]|[A-J]10$'). This checks first for the two-character combinations A1 to J9, then checks for A10 to J10. If I test this in a web2py shell, it accepts and returns the two-character combinations, but it accepts and truncates any values ending in 10. In [1] : vdtr = IS_MATCH('^[A-J][1-9]|[A-J]10$') In [2] : vdtr('A1') ('A1', None) In [3] : vdtr('J1') ('J1', None) In [4] : vdtr('A10') ('A1', None) In [5] : vdtr('J10') ('J1', None) It seems to me that A1 and J1 are not proper matches because the '1' does not appear at the end of the validated string. In any case, I am surprised that IS_MATCH() would modify a value under any circumstances. If I turn the regex around, so that it tests for the three-character combinations first, like IS_MATCH('^[A-J]10|[A-J][1-9]$'), then things work better. In [6] : vdtr = IS_MATCH('^[A-J]10|[A-J][1-9]$') In [7] : vdtr('A1') ('A1', None) In [8] : vdtr('J1') ('J1', None) In [9] : vdtr('A10') ('A10', None) In [10] : vdtr('J10') ('J10', None)
Re: [web2py] Re: Create databases folder
I will add debugging to find out next time I am working on it. -- Thadeus On Fri, Feb 4, 2011 at 7:11 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: As Jonathan says, it is main that creates the missing folders, the first time the app is accessed. dal just assumes it is there. On Feb 4, 4:56 pm, Jonathan Lundell jlund...@pobox.com wrote: On Feb 4, 2011, at 1:19 PM, Thadeus Burgess wrote: Nope not working for me. A raw checkout of a branch, there is no NEWINSTALL file, nor a welcome.w2p file since we don't need it. The app only contains controllers, cron, languages, models, modules, static, tests, views, __init__.py. From this state, when starting web2py just by python web2py.py. Navigate to the app in firefox or other web browser, and it crashes because it cannot connect to the sqlite database 5 times, this is because the databases folder does not exist from a raw checkout of our app, and web2py does not seem to be creating any of the folders. If I navigate into my app directory, and run ``mkdir databases`` then navigate to the app, everything is fine, and web2py ends up making the uploads, private, cache, sessions, and errors folders. Odd. The admin.create_missing_app_folders() call in main.wsgibase should be creating the folder. Could you throw a couple of strategic debug prints into that function and see what's going on?
Re: [web2py] drop support for python 2.4?
I´m using CentOS on all my servers but I have nothing against dropping 2.4 support as I have allways installed python 2.5 or 2.6 beside the default 2.4. Kenneth @web2py-developers we have discussing the possibility of dropping support for Python 2.4. So far we have put a great effor t in having web2py run on 2.4 because this is the default python version on CentOS for shared hosts. Yet by dropping support we could improve the code base, make it more readable and expose new syntax to users. Who strongly opposes? Make your case.
[web2py] web2py working on my iPad! :vD
I have renewed interest in using web2py for simple Google gadgets and CRUD updates to a web database, and in exploring it, wondered if I could load and use it on my iPad. Well, sure enough, I got it going! Very impressive!! Procedure is: a) jailbreak your iPad install Cydia (a bit involved, but there's lots of howto's on the web) b) set your type as developer in Cydia (your prompted initially, - or you may not be able to find Python, to install it c) install unix commands - OpenSSH, wget, unzip, (vim) - via Cydia d) install iphone/python (2.5) e) install pTerm via iPad appstore f) using pTerm, login to root@localhost (default pswd is alpine - change it using passwd!!) g) at sys prompt, use wget http:/web2py/examples/static/ web2py_src.zip h) then unzip web2py_src.zip i) then cd web2py j) then ./web2py ... enter a password (no gui but not prob) k) use pTerm browser (via tapping the [...] button at upper right) to browse to localhost:8000 l) your there, with sqlite and all! Even the editor works with the iPad (most don't)!! So just in case anyone else out there is a little crazy like me, this is how it is done: Notes: 1) Jailbreaking your iPad: At the moment, it's still a Mac only, 'tethered' jailbreak, meaning; to enable the jailbreak mode you have to boot the device connected to your Mac, using redsn0w utility, and selecting the just boot tethered' mode - otherwise the it will boot with jailbreaking disabled 2) pTerm does not go into background properly, so it will kill web2py if you try to use an iPad browser instead of the built in one - hopefully this is updated soon. Here's some screenshots on picasa - https://picasaweb.google.com/kgingeri/Wep2pyOnIpad?feat=directlink
Re: [web2py] drop support for python 2.4?
Me too. Martin 2011/2/5 Kenneth Lundström kenneth.t.lundst...@gmail.com I´m using CentOS on all my servers but I have nothing against dropping 2.4 support as I have allways installed python 2.5 or 2.6 beside the default 2.4. Kenneth @web2py-developers we have discussing the possibility of dropping support for Python 2.4. So far we have put a great effor t in having web2py run on 2.4 because this is the default python version on CentOS for shared hosts. Yet by dropping support we could improve the code base, make it more readable and expose new syntax to users. Who strongly opposes? Make your case.
[web2py] Re: Can any help me with new dal in trunk?
Goodnight to everybody I think my problem with legacy databases with mysql is finished. Change the driver SQLDB by DAL and now, my old application left to give me the problem that I described above with web2py trunk version. Thank you very much everybody and my apologize because I didn't see that. Now, I have a problem with one database that it didn't is legacy database in the same old application This is the issue Traceback (most recent call last): File /home/drayco/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /home/drayco/web2py/applications/iscada/models/db.py, line 85, in module Field('creadoPor', db.auth_user, default=current_user_id, label='Creado por', writable=False, readable=False), File /home/drayco/web2py/gluon/dal.py, line 3510, in __getattr__ return self[key] File /home/drayco/web2py/gluon/dal.py, line 3504, in __getitem__ return dict.__getitem__(self, str(key).lower()) KeyError: 'auth_user' Anyone have any advice on how to overcome it? Thanks in advance On Feb 2, 12:44 am, Fran francisb...@gmail.com wrote: This is now fixed in Trunk - thanks Massimo :) F
[web2py] Re: How do I explicitly close a database connection?
I don't get it... doesn't this make you logged out because you wouldn't have auth_user anymore? then what do you do? But on the other hand could we use this to hop from one db to another (thinking through script) ? Sorry for asking ;) Mart On Feb 4, 12:57 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: db._adapter.connection.close() On Feb 4, 10:24 am, vortex billyara...@gmail.com wrote: How do I explicitly close a database connection?