[web2py] Re: headers argument behavior in v1.97.1
Why do you have to define all headers? I would only want to display the headers to those columns that I define in the columns list but now it requires me to set headers to every other column too that I'm not showing. That is stupid On Friday, 8 July 2011 04:17:39 UTC+2, ニコノコ wrote: Nope, I'm not using trunk. And yes, now I know that I have do define *all* the headers while in the old versions, that isn't a requirement. I guess it's part of being explicit.. On Jul 7, 6:36 pm, Martín Mulone mulone.mar...@gmail.com wrote: Did you use trunk version?, I submitted recently some changes there.- 2011/7/7 Bruno Rocha rochacbr...@gmail.com Can you share some example app or model + controller code t reproduce the bug. Do you have a Traceback ticket error? what message, what file/line? The erro occurs when running the mentioned controller, or qhen doing some other action on this? Need more onfo to help tracking this issue. []'s On Thu, Jul 7, 2011 at 2:50 AM, niknok nikolai...@gmail.com wrote: ** While using crud, I sometimes define headers for *some* fields listed in the fields argument. This works until I upgraded to 1.97.1 and now I get an error if I do not define the headers for *all* fields listed in the fields argument. For example, the following code no longer works rows=crud.select(db.address ,query=((db.address.owner_is==address_owner) (db.address.owner_is_person==address_owner_is_person)) ,fields=['address.id' ,'address.line_1' ,'address.is_type' ,'address.country'] ,headers={'address.id':'#' ,'address.line_1':'Street address' ,'address.country':'Country'}) until I add a header for address.is_type, too. Is this a bug or a new feature? -- -- Bruno Rocha [ About me:http://zerp.ly/rochacbruno] [ Aprenda a programar:http://CursoDePython.com.br] [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br] [ Consultoria em desenvolvimento web:http://www.blouweb.com] -- http://martin.tecnodoc.com.ar --
[web2py] Re: How to personalise a SQLTABLE ?
This is a great option but what is the best practice then to have the represents-functionality still on board? It is a bit messy to do that totally on your own On Friday, 30 November 2007 16:26:12 UTC+1, mdipierro wrote: What you try to do is too much personalization for sqltable. You should not use SQLTABLE. make a view like mytable.html {{def mytable(records):}} table{{for r in records:}}tr{{for k,v in r.items():}}td{{=v}}/ td{{pass}}/tr{{pass}}/table {{return}} - import it in your view with {{include 'mytable.html'}} and use it {{mytable(db(...).select())}} the you can personalize your table as you want and reuse it. --
[web2py] Re: bug with default view
When has this behaviour changed? I can't seem to find it on log On Jun 17, 7:33 pm, Jose jjac...@gmail.com wrote: On 17 jun, 11:35, Anthony abasta...@gmail.com wrote: On Friday, June 17, 2011 10:16:16 AM UTC-4, Jose wrote: Hi, In later versions of the trunk the default view does not work. If I create a function without creating ls associated view, should load the default view, well, this is what fails. [invalid view] Are you having this problem with requests on the local machine, or only remote requests? Due to a security vulnerability, generic views are turned off by default unless the request is local. In db.py of the 'welcome' app, the following has been added: response.generic_patterns= ['*'] if request.is_local else [] response.generic_patternsis a list of glob patterns that can be used to match /controller/function.extension to determine which generic views should be available for which controllers and functions. The above line allows all generic views, but only when request.is_local is True. You can set the generic_patterns centrally in a model file (as above), or you can set it within specific controllers or functions. For example: In default.py: def myaction(): response.generic_patterns= ['html', 'load'] # more code return dict(...) The above will enable generic.html and generic.load views specifically for requests to /default/myaction.[html/load]. Anthony Thanks Anthony.
[web2py] Re: Possible bug in trunk dal.py
Yes I did. Dal seems to try to put 0 in database but MySQL rejects the value, since there is no row with index 0. I think the proper way to indicate None in MySQL would be NULL. On Jun 1, 7:14 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Did you try: db.define_table(tags, Field(name,string), Field(parent, reference tags,default=None), format=%(name)s) On Jun 1, 9:30 am, Oskari oskari.pe...@gmail.com wrote: Hi, I'm reporting a possible bug with trunk version of dal.py. I'm having the traceback: Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 184, in restricted exec ccode in environment File /home/www-data/web2py/applications/backend/controllers/ appadmin.py, line 411, in module File /home/www-data/web2py/gluon/globals.py, line 135, in lambda self._caller = lambda f: f() File /home/www-data/web2py/applications/backend/controllers/ appadmin.py, line 127, in insert if form.accepts(request.vars, session): File /home/www-data/web2py/gluon/sqlhtml.py, line 1205, in accepts self.vars.id = self.table.insert(**fields) File /home/www-data/web2py/gluon/dal.py, line 4634, in insert return self._db._adapter.insert(self,self._listify(fields)) File /home/www-data/web2py/gluon/dal.py, line 814, in insert raise e IntegrityError: (1452, u'Cannot add or update a child row: a foreign key constraint fails (`tuubiodb`.`tags`, CONSTRAINT `tags_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `tags` (`id`) ON DELETE CASCADE)') with table definition db.define_table(tags, Field(name,string), Field(parent, reference tags,required=False), format=%(name)s) Web2py tries to insert parent with value 0, while mySQL only accepts null as a reference to non-existing table.
[web2py] Possible bug in trunk dal.py
Hi, I'm reporting a possible bug with trunk version of dal.py. I'm having the traceback: Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 184, in restricted exec ccode in environment File /home/www-data/web2py/applications/backend/controllers/ appadmin.py, line 411, in module File /home/www-data/web2py/gluon/globals.py, line 135, in lambda self._caller = lambda f: f() File /home/www-data/web2py/applications/backend/controllers/ appadmin.py, line 127, in insert if form.accepts(request.vars, session): File /home/www-data/web2py/gluon/sqlhtml.py, line 1205, in accepts self.vars.id = self.table.insert(**fields) File /home/www-data/web2py/gluon/dal.py, line 4634, in insert return self._db._adapter.insert(self,self._listify(fields)) File /home/www-data/web2py/gluon/dal.py, line 814, in insert raise e IntegrityError: (1452, u'Cannot add or update a child row: a foreign key constraint fails (`tuubiodb`.`tags`, CONSTRAINT `tags_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `tags` (`id`) ON DELETE CASCADE)') with table definition db.define_table(tags, Field(name,string), Field(parent, reference tags,required=False), format=%(name)s) Web2py tries to insert parent with value 0, while mySQL only accepts null as a reference to non-existing table.
[web2py] Doctests and aut - Difference being logged in or not
Hi, I'm writing doctests to my application. Most of my functions are decorated with @auth.requires_login(). Running doctests through the web IDE runs the tests in a different environment depending on if I'm logged in in the app. What kind of pattern is here meant to be used to test logged-in features (the normal usage) possibly without self first logging in through the app? And also of course test that you cannot access the function without logging in? And also, considering an app with no data in database, how to test for example empty forms and lists easily? I am a bit confused with the way web2py is really supposed to be tested, the book lacks examples and discussion on that. Thanks already!
[web2py] Re: form.accepts() with reference to other table
I'm still struggling with the IS_IN_DB-validator. This problem occurs when trying to implement reference id for example via a controller line: request.vars.reftableid = 2 The form just informs it isn't in the database. Why is that? On Feb 13, 3:14 pm, Oskari oskari.pe...@gmail.com wrote: Uncommenting that did the trick. Perhaps there was something wrong with that =) Anyways, thanks! On Feb 13, 3:17 am, villas villa...@gmail.com wrote: Try commenting out the line 'custom_auth_table.accountID.requires...' If that doesn't give you any progress, post all your auth model. I'm sure someone should be able to spot something obvious -- these bugs can be right under our noses sometimes :) -D On Feb 12, 11:03 pm, Oskari oskari.pe...@gmail.com wrote: Thank you for your answer villas! I don't think that is the problem. I am able to make inserts through the appadmin-site, but somehow it fails with form.accepts(). I also tried what you suggested, but could not quite get it working. On Feb 12, 8:45 pm, villas villa...@gmail.com wrote: Not sure, but the 3rd attrib of 'IS_IN_DB' doesn't look right? Maybe if you tried something like this, e.g. custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,'% (name)s') On Feb 12, 1:28 pm, Oskari oskari.pe...@gmail.com wrote: Hi! I'm having trouble making an insert with form.accepts() Currently I have a custom auth_user that has one extra field: Field('accountID', db.accounts) with custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,id) While trying to modify variables it fails with not found in db def func(): form=SQLFORM(db.auth_user) request.vars.accountID = 1 if form.accepts(request.vars,session): response.flash = Succesfully created user return dict(form=form) Why does not form.accepts() recognize and accept my accountID?
[web2py] Re: form.accepts() with reference to other table
Here's my code: db.py: db.define_table( accounts, Field(name,string,length=128,default=''), Field(email,string,length=128,default=''), Field('username', length=128,default='',unique=True), Field('password', 'password', length=512, readable=False, label='Password') ) db.accounts.name.requires = IS_NOT_EMPTY() db.accounts.password.requires = CRYPT(key=auth.settings.hmac_key) db.define_table( mytextbase, Field(mytext,string,length=512,default=''), Field(accountid,db.accounts) ) db.mytextbase.accountid.requires = IS_IN_DB(db,accounts.id) #Custom user-table to set accountid db.define_table( auth.settings.table_user_name, Field('first_name', length=128, default=''), Field('last_name', length=128, default=''), Field('email', length=128, default='', unique=True), Field('username', length=128,default='',unique=True), Field('password', 'password', length=512, readable=False, label='Password'), Field('registration_key', length=512, writable=False, readable=False, default=''), Field('reset_password_key', length=512, writable=False, readable=False, default=''), Field('registration_id', length=512, writable=False, readable=False, default=''), Field('accountid', db.accounts) ) custom_auth_table = db[auth.settings.table_user_name] custom_auth_table.first_name.requires = IS_NOT_EMPTY(error_message=auth.messages.is_empty) custom_auth_table.last_name.requires = IS_NOT_EMPTY(error_message=auth.messages.is_empty) custom_auth_table.password.requires = [CRYPT()] custom_auth_table.email.requires = [ IS_EMAIL(error_message=auth.messages.invalid_email), IS_NOT_IN_DB(db, custom_auth_table.email)] and my control.py: def add(): form=SQLFORM(db.mytextbase) request.vars.accountid = session.auth.user.accountid if form.accepts(request.vars,session): response.flash = Added successfully! :) elif form.errors: response.flash = Something went wrong! :( else: response.flash = Fill the form! return dict(form=form) With these my form only complains that accountid is:nt found in the database On Feb 16, 10:19 pm, villas villa...@gmail.com wrote: It should be easy. Post your relevant model and controller code. BTW it probably doesn't make any difference... but maybe you might consider using the notation account_id instead of accountID. I read somewhere that some databases have case sensitive fields and that web2py makes some assumptions about this. Just better to work all in lowercase and avoid hitting that possible complication in the future. :) Regards, D On Feb 16, 6:47 pm, Oskari oskari.pe...@gmail.com wrote: I'm still struggling with the IS_IN_DB-validator. This problem occurs when trying to implement reference id for example via a controller line: request.vars.reftableid = 2 The form just informs it isn't in the database. Why is that? On Feb 13, 3:14 pm, Oskari oskari.pe...@gmail.com wrote: Uncommenting that did the trick. Perhaps there was something wrong with that =) Anyways, thanks! On Feb 13, 3:17 am, villas villa...@gmail.com wrote: Try commenting out the line 'custom_auth_table.accountID.requires...' If that doesn't give you any progress, post all your auth model. I'm sure someone should be able to spot something obvious -- these bugs can be right under our noses sometimes :) -D On Feb 12, 11:03 pm, Oskari oskari.pe...@gmail.com wrote: Thank you for your answer villas! I don't think that is the problem. I am able to make inserts through the appadmin-site, but somehow it fails with form.accepts(). I also tried what you suggested, but could not quite get it working. On Feb 12, 8:45 pm, villas villa...@gmail.com wrote: Not sure, but the 3rd attrib of 'IS_IN_DB' doesn't look right? Maybe if you tried something like this, e.g. custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,'% (name)s') On Feb 12, 1:28 pm, Oskari oskari.pe...@gmail.com wrote: Hi! I'm having trouble making an insert with form.accepts() Currently I have a custom auth_user that has one extra field: Field('accountID', db.accounts) with custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,id) While trying to modify variables it fails with not found in db def func(): form=SQLFORM(db.auth_user) request.vars.accountID = 1 if form.accepts(request.vars,session): response.flash = Succesfully created user return dict(form=form) Why does not form.accepts() recognize and accept my accountID?
[web2py] Re: form.accepts() with reference to other table
Uncommenting that did the trick. Perhaps there was something wrong with that =) Anyways, thanks! On Feb 13, 3:17 am, villas villa...@gmail.com wrote: Try commenting out the line 'custom_auth_table.accountID.requires...' If that doesn't give you any progress, post all your auth model. I'm sure someone should be able to spot something obvious -- these bugs can be right under our noses sometimes :) -D On Feb 12, 11:03 pm, Oskari oskari.pe...@gmail.com wrote: Thank you for your answer villas! I don't think that is the problem. I am able to make inserts through the appadmin-site, but somehow it fails with form.accepts(). I also tried what you suggested, but could not quite get it working. On Feb 12, 8:45 pm, villas villa...@gmail.com wrote: Not sure, but the 3rd attrib of 'IS_IN_DB' doesn't look right? Maybe if you tried something like this, e.g. custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,'% (name)s') On Feb 12, 1:28 pm, Oskari oskari.pe...@gmail.com wrote: Hi! I'm having trouble making an insert with form.accepts() Currently I have a custom auth_user that has one extra field: Field('accountID', db.accounts) with custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,id) While trying to modify variables it fails with not found in db def func(): form=SQLFORM(db.auth_user) request.vars.accountID = 1 if form.accepts(request.vars,session): response.flash = Succesfully created user return dict(form=form) Why does not form.accepts() recognize and accept my accountID?
[web2py] form.accepts() with reference to other table
Hi! I'm having trouble making an insert with form.accepts() Currently I have a custom auth_user that has one extra field: Field('accountID', db.accounts) with custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,id) While trying to modify variables it fails with not found in db def func(): form=SQLFORM(db.auth_user) request.vars.accountID = 1 if form.accepts(request.vars,session): response.flash = Succesfully created user return dict(form=form) Why does not form.accepts() recognize and accept my accountID?
[web2py] Re: form.accepts() with reference to other table
Thank you for your answer villas! I don't think that is the problem. I am able to make inserts through the appadmin-site, but somehow it fails with form.accepts(). I also tried what you suggested, but could not quite get it working. On Feb 12, 8:45 pm, villas villa...@gmail.com wrote: Not sure, but the 3rd attrib of 'IS_IN_DB' doesn't look right? Maybe if you tried something like this, e.g. custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,'% (name)s') On Feb 12, 1:28 pm, Oskari oskari.pe...@gmail.com wrote: Hi! I'm having trouble making an insert with form.accepts() Currently I have a custom auth_user that has one extra field: Field('accountID', db.accounts) with custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,id) While trying to modify variables it fails with not found in db def func(): form=SQLFORM(db.auth_user) request.vars.accountID = 1 if form.accepts(request.vars,session): response.flash = Succesfully created user return dict(form=form) Why does not form.accepts() recognize and accept my accountID?
[web2py] Web2py SOAP
Hi! I'm building a SOAP interface with web2py. How can I return an array with that? I'm guessing its something like: @service.soap(test,args={},returns={'response':array} but that isn't recognised as a type. Any ideas?