Re: [web2py] How to list:reference users ?
Field('user_id', list:reference auth_user) On Sun, Mar 11, 2012 at 12:36 AM, bussiere adrien bussi...@gmail.comwrote: maybe Field('Auth','list:reference Auth'), or ('Auth','list:reference User'), Regards Bussiere -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] represent
In db.py I have: db.define_table('Node', Field('createdOn',type='datetime',writable=False,readable=False), Field('modifiedOn',type='datetime',writable= False,readable=False), migrate=False) db.define_table('Organization', Field('nodeID',db.Node,default='',notnull=True,ondelete='RESTRICT',writable=False,readable=False), Field('name',length=128,default='',notnull=True), ... migrate=False) db.define_table('NodeRelatedCard', Field('sourceID',db.Node,default='',notnull=True,ondelete='CASCADE',writable=False,readable=False), Field('targetID',db.Node,default='',notnull=True,ondelete='CASCADE'), ... migrate=False) In a function I have: row=db(db.NodeRelatedCard.id==request.args(1)).select().first() In the update form of this function I would like targetID to be represented by Organization.name. I tried: db.NodeRelatedCard.targetID.represent= lambda targetID, row: db.Organization(targetID).name but that doesn't work. What is the correct syntax to get this to work. Kind regards, Annet.
[web2py] Re: How to list:reference users ?
thanks Le dimanche 11 mars 2012 04:36:37 UTC+1, bussiere adrien a écrit : maybe Field('Auth','list:reference Auth'), or ('Auth','list:reference User'), Regards Bussiere
[web2py] (Field: unknown field type: float for Price)
here is my error : Traceback (most recent call last): File gluon/restricted.py, line 205, in restricted File C:/Users/Bussiere/Dropbox/Projets/Yuki/web2py/applications/init/models/db.py http://127.0.0.1:8000/admin/default/edit/init/models/db.py, line 327, in module File gluon/dal.py, line 6320, in define_table File gluon/dal.py, line 638, in create_table SyntaxError: Field: unknown field type: float for Price type 'exceptions.SyntaxError'(Field: unknown field type: float for Price) db.define_table('Cour', Field http://127.0.0.1:8000/examples/global/vars/Field('id'), Field http://127.0.0.1:8000/examples/global/vars/Field('Price', 'float'), format = '%(Price)d') db.define_table('Currency', Field http://127.0.0.1:8000/examples/global/vars/Field('Name', unique=True), Field http://127.0.0.1:8000/examples/global/vars/Field('Cour', db.Cour), format = '%(Name)s') db.define_table('Price', Field http://127.0.0.1:8000/examples/global/vars/Field('Name'), Field http://127.0.0.1:8000/examples/global/vars/Field('Currency', db.Currency), Field http://127.0.0.1:8000/examples/global/vars/Field('Amount', 'float'), format = '%(Price,Currency)s') I ruly don't understand i did as in the tutorial
Re: [web2py] (Field: unknown field type: float for Price)
There is no float, it is double in web2py Field http://127.0.0.1:8000/examples/global/vars/Field('Price', 'double'), -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] (Field: unknown field type: float for Price)
i owe you one. But on the web i see float ? http://web2py.wordpress.com/ Le dimanche 11 mars 2012 10:26:29 UTC+1, rochacbruno a écrit : There is no float, it is double in web2py Field http://127.0.0.1:8000/examples/global/vars/Field('Price', 'double'), -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] using form in same page?
Hello sorry my bad english and i hope that you understand my problem. I want show in one page all pictures which are saved in database. In page i want that i can upload new picture and update it whit forms (override old one) My code are in controller: def jobs(): images=db().select(db.ref.id,db.ref.file) for img in images: formname = upload_f_%s%img.id form = FORM(INPUT(_type=file,_name=formname), INPUT(_type='submit')) if form.accepts(request.vars, _name=formname): response.flash = form.vars return dict(form=form, img=img, formname=formname, images=images) in views: {{for img in images:}} imageimg width=85px src={{=URL('download', args=img.file)}} /br/image brbrbrbrbr {{=img}} {{formname=img.id}} {{=formname}} {{=form}} {{pass}}{{pass}} please help!
Re: [web2py] using form in same page?
I don't know why you have two {{pass}} in your view. I think you can do: def jobs(): images=db().select(db.ref.id,db.ref.file) form = SQLFORM(db.ref) if form.process().accepted: response.flash = Image uploaded return dict(form=form, images=images) in views: {{for img in images:}} imageimg width=85px src={{=URL('download', args=img.file)}} /br/image brbrbrbrbr {{=img}} {{=img.id}} {{=form}} {{pass}} 2012/3/11 juvi1 juha.wilh...@gmail.com Hello sorry my bad english and i hope that you understand my problem. I want show in one page all pictures which are saved in database. In page i want that i can upload new picture and update it whit forms (override old one) My code are in controller: def jobs(): images=db().select(db.ref.id,db.ref.file) for img in images: formname = upload_f_%s%img.id form = FORM(INPUT(_type=file,_name=formname), INPUT(_type='submit')) if form.accepts(request.vars, _name=formname): response.flash = form.vars return dict(form=form, img=img, formname=formname, images=images) in views: {{for img in images:}} imageimg width=85px src={{=URL('download', args=img.file)}} /br/image brbrbrbrbr {{=img}} {{formname=img.id}} {{=formname}} {{=form}} {{pass}}{{pass}} please help! -- http://www.tecnodoc.com.ar
[web2py] custom css
Hi I like to use my custom css and add it to my application base.css mess my application. I have remove base.css and move classes .flash and .error to my custom css file. when I do that it is not working in FireFox 10 in windows but it works in all other browser and OS (mac Ubuntu , win). Can you please help me with that ? /F
[web2py] Re: Website doesn't show up.
What exactly does that do? Where does it get sent to? It is explained in the book (available online): 1.3 Model-View- Controller ... The data in the dictionary is rendered by a view. If the visitor requests an HTML page (the default), the dictionary is rendered into an HTML page ... For more details see 10.1 Rendering a dictionary
Re: [web2py] custom css
What is not working?, you change views/layout.html? 2012/3/11 frasse frass...@gmail.com Hi I like to use my custom css and add it to my application base.css mess my application. I have remove base.css and move classes .flash and .error to my custom css file. when I do that it is not working in FireFox 10 in windows but it works in all other browser and OS (mac Ubuntu , win). Can you please help me with that ? /F -- http://www.tecnodoc.com.ar
[web2py] Re: represent
db.Organization(targetID).name I'd use db.Organization[targetID].name Not sure the first syntax is supported, (tables should have a __call__ attribute for that purpose)
[web2py] Re: Translations in custom classes
When messages object is instantiated, T is passed as argument probabbly to process default auth values for translation. Then .password_reset_button is set without T(...), so for automatic translation, there should be some operator overloading for the Message instance to translate the text without explicit T call, otherwise, the attribute will just be set without further actions. On 11 mar, 01:26, Bruce Wade bruce.w...@gmail.com wrote: Hi, I was looking at the Auth class, why are settings like the following not showing in the language translations files by default? # ## these are messages that can be customized messages = self.messages = Messages(current.T) messages.password_reset_button = 'Request reset password' I have no idea what Messages(current.T) is supposed to do however the above string is not found in the languages files. -- -- Regards, Bruce Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com
[web2py] Re: represent
On Sunday, March 11, 2012 4:07:46 AM UTC-4, Annet wrote: In db.py I have: db.define_table('Node', Field('createdOn',type='datetime',writable=False,readable=False), Field('modifiedOn',type='datetime',writable= False,readable=False), migrate=False) db.define_table('Organization', Field('nodeID',db.Node,default='',notnull=True,ondelete='RESTRICT',writable=False,readable=False), Field('name',length=128,default='',notnull=True), ... migrate=False) db.define_table('NodeRelatedCard', Field('sourceID',db.Node,default='',notnull=True,ondelete='CASCADE',writable=False,readable=False), Field('targetID',db.Node,default='',notnull=True,ondelete='CASCADE'), ... migrate=False) In a function I have: row=db(db.NodeRelatedCard.id==request.args(1)).select().first() In the update form of this function I would like targetID to be represented by Organization.name. I tried: db.NodeRelatedCard.targetID.represent= lambda targetID, row: db.Organization(targetID).name db.Organization(targetID) is equivalent to db(db.Organization.id == targetID).select().first(), but you want to equate targetID with Organization.nodeID, not with Organization.id, so instead do: db.NodeRelatedCard.targetID.represent = lambda targetID, row: db(db.Organization.nodeID == targetID).select().first().name Anthony but that doesn't work. What is the correct syntax to get this to work. Kind regards, Annet.
[web2py] Re: represent
db.Organization(targetID).name I'd use db.Organization[targetID].name Not sure the first syntax is supported, (tables should have a __call__ attribute for that purpose) Yes, the first syntax is supported -- it's just not the right query in this case. Anthony
[web2py] Re: represent
db.Organization(targetID).name I'd use db.Organization[targetID].name Not sure the first syntax is supported, (tables should have a __call__ attribute for that purpose) Yes, the first syntax is supported -- it's just not the right query in this case. Note, the difference is that the first syntax (i.e., with the parentheses) won't trigger an exception even if the id submitted is not an int, and it allows multiple conditions to be submitted rather than just an id. For example: db.Organization(db.Organization.nodeID == targetID).name See http://web2py.com/books/default/chapter/29/6#Fetching-a-Row. Anthony
Re: [web2py] Re: Website doesn't show up.
Putting in return dict() made it work. Thanks. What exactly does that do? Where does it get sent to? When myfunc() in mycontroller.py returns a dict (even an empty one), that tells web2py to render the view associated with myfunc, which by default will be /views/mycontroller/myfunc.html (if the requested URL has an extension other than html, then it will look for a view file with the associated extension instead). If the expected view file doesn't exist, web2py will attempt to use /views/generic.html, but only if generic views are enabled (they are disabled by default, except for local requests). If myfunc() returns anything other than a dict, whatever it returns will be sent directly as the HTTP response body without first rendering any view. See http://web2py.com/books/default/chapter/29/4#Workflow. Anthony
Re: [web2py] (Field: unknown field type: float for Price)
i owe you one. But on the web i see float ? http://web2py.wordpress.com/ That blog entry appears to be incorrect.
[web2py] Re: custom css
color for .error is not change and .flash move to left with no border. /F On 11 mar, 12:53, Martín Mulone mulone.mar...@gmail.com wrote: What is not working?, you change views/layout.html? 2012/3/11 frasse frass...@gmail.com Hi I like to use my custom css and add it to my application base.css mess my application. I have remove base.css and move classes .flash and .error to my custom css file. when I do that it is not working in FireFox 10 in windows but it works in all other browser and OS (mac Ubuntu , win). Can you please help me with that ? /F -- http://www.tecnodoc.com.ar
[web2py] Re: custom css
One more think. yes I change the layout.html On 11 mar, 15:38, frasse frass...@gmail.com wrote: color for .error is not change and .flash move to left with no border. /F On 11 mar, 12:53, Martín Mulone mulone.mar...@gmail.com wrote: What is not working?, you change views/layout.html? 2012/3/11 frasse frass...@gmail.com Hi I like to use my custom css and add it to my application base.css mess my application. I have remove base.css and move classes .flash and .error to my custom css file. when I do that it is not working in FireFox 10 in windows but it works in all other browser and OS (mac Ubuntu , win). Can you please help me with that ? /F -- http://www.tecnodoc.com.ar
Re: [web2py] (Field: unknown field type: float for Price)
Also decimal is good for prices.
Re: [web2py] Re: Translations in custom classes
Okay, Well maybe it is just me but I think when you click the update translations button in admin, it should automatically grab ALL strings especially default strings in admin so we can translate them. For example with pyramid you use python setup.py extract_messages this will go through every single file in the project to pull out the translate able strings. Would it be difficult to change the way translation works to do this? On Sun, Mar 11, 2012 at 5:21 AM, Alan Etkin spame...@gmail.com wrote: When messages object is instantiated, T is passed as argument probabbly to process default auth values for translation. Then .password_reset_button is set without T(...), so for automatic translation, there should be some operator overloading for the Message instance to translate the text without explicit T call, otherwise, the attribute will just be set without further actions. On 11 mar, 01:26, Bruce Wade bruce.w...@gmail.com wrote: Hi, I was looking at the Auth class, why are settings like the following not showing in the language translations files by default? # ## these are messages that can be customized messages = self.messages = Messages(current.T) messages.password_reset_button = 'Request reset password' I have no idea what Messages(current.T) is supposed to do however the above string is not found in the languages files. -- -- Regards, Bruce Wadehttp:// ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
Re: [web2py] Re: Translations in custom classes
How would we update this method so it also gets all the strings from the gluon package? When you click update all languages it only looks in the specific language folders. This should also look in the gluon package and ideally there should be away to add locations for it to look. def findT(path, language='en-us'): must be run by the admin app filename = os.path.join(path, 'languages', '%s.py' % language) sentences = read_dict(filename) mp = os.path.join(path, 'models') cp = os.path.join(path, 'controllers') vp = os.path.join(path, 'views') for file in listdir(mp, '.+\.py', 0) + listdir(cp, '.+\.py', 0)\ + listdir(vp, '.+\.html', 0): fp = portalocker.LockedFile(file, 'r') data = fp.read() fp.close() items = regex_translate.findall(data) for item in items: try: message = eval(item) if not message.startswith('#') and not '\n' in message: tokens = message.rsplit('##', 1) else: # this allows markmin syntax in translations tokens = [message] if len(tokens) == 2: message = tokens[0].strip() + '##' + tokens[1].strip() if message and not message in sentences: sentences[message] = message except: pass write_dict(filename, sentences) On Sun, Mar 11, 2012 at 8:39 AM, Bruce Wade bruce.w...@gmail.com wrote: Okay, Well maybe it is just me but I think when you click the update translations button in admin, it should automatically grab ALL strings especially default strings in admin so we can translate them. For example with pyramid you use python setup.py extract_messages this will go through every single file in the project to pull out the translate able strings. Would it be difficult to change the way translation works to do this? On Sun, Mar 11, 2012 at 5:21 AM, Alan Etkin spame...@gmail.com wrote: When messages object is instantiated, T is passed as argument probabbly to process default auth values for translation. Then .password_reset_button is set without T(...), so for automatic translation, there should be some operator overloading for the Message instance to translate the text without explicit T call, otherwise, the attribute will just be set without further actions. On 11 mar, 01:26, Bruce Wade bruce.w...@gmail.com wrote: Hi, I was looking at the Auth class, why are settings like the following not showing in the language translations files by default? # ## these are messages that can be customized messages = self.messages = Messages(current.T) messages.password_reset_button = 'Request reset password' I have no idea what Messages(current.T) is supposed to do however the above string is not found in the languages files. -- -- Regards, Bruce Wadehttp:// ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
Re: [web2py] Re: Translations in custom classes
Looks in specific folders in the current application On Sun, Mar 11, 2012 at 8:49 AM, Bruce Wade bruce.w...@gmail.com wrote: How would we update this method so it also gets all the strings from the gluon package? When you click update all languages it only looks in the specific language folders. This should also look in the gluon package and ideally there should be away to add locations for it to look. def findT(path, language='en-us'): must be run by the admin app filename = os.path.join(path, 'languages', '%s.py' % language) sentences = read_dict(filename) mp = os.path.join(path, 'models') cp = os.path.join(path, 'controllers') vp = os.path.join(path, 'views') for file in listdir(mp, '.+\.py', 0) + listdir(cp, '.+\.py', 0)\ + listdir(vp, '.+\.html', 0): fp = portalocker.LockedFile(file, 'r') data = fp.read() fp.close() items = regex_translate.findall(data) for item in items: try: message = eval(item) if not message.startswith('#') and not '\n' in message: tokens = message.rsplit('##', 1) else: # this allows markmin syntax in translations tokens = [message] if len(tokens) == 2: message = tokens[0].strip() + '##' + tokens[1].strip() if message and not message in sentences: sentences[message] = message except: pass write_dict(filename, sentences) On Sun, Mar 11, 2012 at 8:39 AM, Bruce Wade bruce.w...@gmail.com wrote: Okay, Well maybe it is just me but I think when you click the update translations button in admin, it should automatically grab ALL strings especially default strings in admin so we can translate them. For example with pyramid you use python setup.py extract_messages this will go through every single file in the project to pull out the translate able strings. Would it be difficult to change the way translation works to do this? On Sun, Mar 11, 2012 at 5:21 AM, Alan Etkin spame...@gmail.com wrote: When messages object is instantiated, T is passed as argument probabbly to process default auth values for translation. Then .password_reset_button is set without T(...), so for automatic translation, there should be some operator overloading for the Message instance to translate the text without explicit T call, otherwise, the attribute will just be set without further actions. On 11 mar, 01:26, Bruce Wade bruce.w...@gmail.com wrote: Hi, I was looking at the Auth class, why are settings like the following not showing in the language translations files by default? # ## these are messages that can be customized messages = self.messages = Messages(current.T) messages.password_reset_button = 'Request reset password' I have no idea what Messages(current.T) is supposed to do however the above string is not found in the languages files. -- -- Regards, Bruce Wadehttp:// ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] web2py and LGPLv3 License
Hi, Looking through the code base, there is a file in pyfpdf/designer.py licensed under: GNU General Public License. Wont this force web2py to be GPL consider it contains code under that license? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Custom register form with personnalised Auth
here is my auth table : (the beginning my table is correct) db.define_table( auth.settings.table_user_name, Field('Nom'), Field('Prenom'), Field('Telephone'), # NOte on user is intern and the user don't hve to see it. Field('Note on user'), How to make a custom sqlform from it ? like : def user(): # i just want some things what is needed (passwd name and all but NOT note on user on the form form = SQLFORM([auth.settings.Nom,auth.settings.Prenom]) return dict(form=form) Regards Bussiere
[web2py] Re: web2py and LGPLv3 License
Good catch. I assume that is an error, as the project as a whole says it's licensed under LGPL: http://code.google.com/p/pyfpdf/. Perhaps the license was changed at some point but the change wasn't made to this file. Anthony On Sunday, March 11, 2012 12:07:47 PM UTC-4, Detectedstealth wrote: Hi, Looking through the code base, there is a file in pyfpdf/designer.py licensed under: GNU General Public License. Wont this force web2py to be GPL consider it contains code under that license? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] PDF rendering without spaces
Hi, A while back I reported a problem with PDF's being generated without spaces. IE: 'This would render' as 'Thiswouldrender' This is actually a bug with chrome not with the PDF library: http://code.google.com/p/chromium/issues/detail?id=86306 Just wanted to point that out if anyone else was confused by this. -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: Translations in custom classes
it should automatically grab ALL strings especially default strings in admin so we can translate them I don't understand completely how does the web2py translator works internally, but, why to translate every string in a module? Sometimes there are strings that the core developer is not interested to translate as string literals not exposed to the user. It also would add processing time for the server to translate strings not meant for translation. On 11 mar, 12:39, Bruce Wade bruce.w...@gmail.com wrote: Okay, Well maybe it is just me but I think when you click the update translations button in admin, it should automatically grab ALL strings especially default strings in admin so we can translate them. For example with pyramid you use python setup.py extract_messages this will go through every single file in the project to pull out the translate able strings. Would it be difficult to change the way translation works to do this? On Sun, Mar 11, 2012 at 5:21 AM, Alan Etkin spame...@gmail.com wrote: When messages object is instantiated, T is passed as argument probabbly to process default auth values for translation. Then .password_reset_button is set without T(...), so for automatic translation, there should be some operator overloading for the Message instance to translate the text without explicit T call, otherwise, the attribute will just be set without further actions. On 11 mar, 01:26, Bruce Wade bruce.w...@gmail.com wrote: Hi, I was looking at the Auth class, why are settings like the following not showing in the language translations files by default? # ## these are messages that can be customized messages = self.messages = Messages(current.T) messages.password_reset_button = 'Request reset password' I have no idea what Messages(current.T) is supposed to do however the above string is not found in the languages files. -- -- Regards, Bruce Wadehttp:// ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.f... -- -- Regards, Bruce Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com
[web2py] Re: Pycon Streaming
Lost the first part. I hope it will be posted somewhere later. On 11 mar, 16:33, Bruno Rocha rochacbr...@gmail.com wrote: in one hour at:http://streamti.me/track-5 -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: Translations file
With a first look at the code, I don't realize how to use it in the new admin. I am thinking of a multi-translators plugin to store and manage per- user translations without patching the admin app. Does web2py for GAE support translations? (I belive GAE python runtime doesn't allow file IO) On 6 mar, 21:33, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Actually I made that long ago ago: http://dl.dropbox.com/u/18065445/Tmp/web2py.app.translatoradmin.w2p But it predates auth and the new admin design. It should be possible to merge with new admin add auth easily. massimo On Tuesday, 6 March 2012 16:43:29 UTC-6, Alan Etkin wrote: It would be great that web2py had a multi-user translation (for non- administrators). I have no idea about how could be implemented. I suppose that it can be accomplished imitating the admin code that handles the translation interface and adding support for Auth. On 6 mar, 18:26, Bruce Wade bruce.w...@gmail.com wrote: Yeah I am not worried about editing it myself, but when I get non-tech people to edit the files that is when things go bad :D. I think I am just going to write a standalone editor like the web based one that I can give to others when editing a file. On Tue, Mar 6, 2012 at 1:18 PM, Bruno Rocha rochacbr...@gmail.com wrote: On Tue, Mar 6, 2012 at 4:48 PM, Bruce Wade bruce.w...@gmail.com wrote: Any suggestions on the best way to update languages.py to prevent this from happening? You can use an editor with Pylinter and PEP8 modules (Sublime-Text-2, Geany, etc), so it will show live syntax errors and prevent problems with syntax. -- Bruno Rocha [http://rochacbruno.com.br] -- -- Regards, Bruce Wadehttp:// ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.f...
Re: [web2py] using form in same page?
thanks, but now form create always new image in database, and i want update image. how it can be done?? sunnuntaina 11. maaliskuuta 2012 13.37.36 UTC+2 Martin.Mulone kirjoitti: I don't know why you have two {{pass}} in your view. I think you can do: def jobs(): images=db().select(db.ref.id,db.ref.file) form = SQLFORM(db.ref) if form.process().accepted: response.flash = Image uploaded return dict(form=form, images=images) in views: {{for img in images:}} imageimg width=85px src={{=URL('download', args=img.file)}} /br/image brbrbrbrbr {{=img}} {{=img.id}} {{=form}} {{pass}} 2012/3/11 juvi1 juha.wilh...@gmail.com Hello sorry my bad english and i hope that you understand my problem. I want show in one page all pictures which are saved in database. In page i want that i can upload new picture and update it whit forms (override old one) My code are in controller: def jobs(): images=db().select(db.ref.id,db.ref.file) for img in images: formname = upload_f_%s%img.id form = FORM(INPUT(_type=file,_name=formname), INPUT(_type='submit')) if form.accepts(request.vars, _name=formname): response.flash = form.vars return dict(form=form, img=img, formname=formname, images=images) in views: {{for img in images:}} imageimg width=85px src={{=URL('download', args=img.file)}} /br/image brbrbrbrbr {{=img}} {{formname=img.id}} {{=formname}} {{=form}} {{pass}}{{pass}} please help! -- http://www.tecnodoc.com.ar
Re: [web2py] Re: how to set a default user group
auth.settings.register_onaccept = post_register it works, thank you :) On Sat, Mar 10, 2012 at 2:44 PM, Alan Etkin spame...@gmail.com wrote: This is one way of solving it (by binding a function to an auth.settings attribute): # model code def post_register(form): # the new user id is stored in auth.user_id pass auth.settings.register_onaccept = give_create_permission On registration, you can perform auth management by accessing the new user id On 10 mar, 09:37, Vasile Ermicioi elff...@gmail.com wrote: hi, currently a new user group is created for each new user after registration, I disabled new groups to be created auth.settings.create_user_groups = False but actually I need to set all new users to a default user group I know I will get a response, :) thank you in advance
Re: [web2py] Re: Translations in custom classes
I was referring to all strings visible to the end user. Primarily the customizable setting stringsstrings On Mar 11, 2012 2:22 PM, Alan Etkin spame...@gmail.com wrote: it should automatically grab ALL strings especially default strings in admin so we can translate them I don't understand completely how does the web2py translator works internally, but, why to translate every string in a module? Sometimes there are strings that the core developer is not interested to translate as string literals not exposed to the user. It also would add processing time for the server to translate strings not meant for translation. On 11 mar, 12:39, Bruce Wade bruce.w...@gmail.com wrote: Okay, Well maybe it is just me but I think when you click the update translations button in admin, it should automatically grab ALL strings especially default strings in admin so we can translate them. For example with pyramid you use python setup.py extract_messages this will go through every single file in the project to pull out the translate able strings. Would it be difficult to change the way translation works to do this? On Sun, Mar 11, 2012 at 5:21 AM, Alan Etkin spame...@gmail.com wrote: When messages object is instantiated, T is passed as argument probabbly to process default auth values for translation. Then .password_reset_button is set without T(...), so for automatic translation, there should be some operator overloading for the Message instance to translate the text without explicit T call, otherwise, the attribute will just be set without further actions. On 11 mar, 01:26, Bruce Wade bruce.w...@gmail.com wrote: Hi, I was looking at the Auth class, why are settings like the following not showing in the language translations files by default? # ## these are messages that can be customized messages = self.messages = Messages(current.T) messages.password_reset_button = 'Request reset password' I have no idea what Messages(current.T) is supposed to do however the above string is not found in the languages files. -- -- Regards, Bruce Wadehttp:// ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.f. .. -- -- Regards, Bruce Wadehttp:// ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com
[web2py] Re: how to set a default user group
Yes, my bad. I copy-pasted the example from the book and modified it partially. On 11 mar, 19:43, Vasile Ermicioi elff...@gmail.com wrote: auth.settings.register_onaccept = post_register it works, thank you :) On Sat, Mar 10, 2012 at 2:44 PM, Alan Etkin spame...@gmail.com wrote: This is one way of solving it (by binding a function to an auth.settings attribute): # model code def post_register(form): # the new user id is stored in auth.user_id pass auth.settings.register_onaccept = give_create_permission On registration, you can perform auth management by accessing the new user id On 10 mar, 09:37, Vasile Ermicioi elff...@gmail.com wrote: hi, currently a new user group is created for each new user after registration, I disabled new groups to be created auth.settings.create_user_groups = False but actually I need to set all new users to a default user group I know I will get a response, :) thank you in advance
[web2py] Re: Support for PyPy
They say its incompatible https://bitbucket.org/pypy/compatibility/wiki/web2py Could someone run some tests? On Tuesday, February 28, 2012 5:41:41 PM UTC, Massimo Di Pierro wrote: I have fixed all pypy bugs that have been reported but I did not run it myself. Please report any problems if any. On Feb 11, 3:51 am, Phyo Arkar phyo.arkarl...@gmail.com wrote: has anyone tested with Pypy 1.8 ? Seems good this time. Previous tests fails web2py , On Fri, Feb 10, 2012 at 10:05 PM, Sathvik Ponangi psath...@gmail.comwrote: Is there some way to run Web2Py on PyPy http://pypy.org?
[web2py] Re: Latest version unable to connect to DB
fixing in trunk (while at PyCon print) On Saturday, 10 March 2012 17:16:57 UTC-6, Alan Etkin wrote: Line 1999 in trunk: self.driver = drivers.get('pg8000') Should be: self.driver = self.drivers.get('pg8000') On Mar 10, 8:07 pm, Alan Etkin spame...@gmail.com wrote: If something changed (as now pg adapter supports pg8000 driver), old uri strings would have to be accepted also. I'd say it's is a bug. There seems to be a list/dict conflict in dal. On Mar 10, 2:16 pm, Bruce Wade bruce.w...@gmail.com wrote: db_users = DAL('postgres://warplyde_fto:password@localhost/warplyde_fto') Has something been changed in how we need to make database connections to postgres? Traceback (most recent call last): File /home/bruce/Development/wct_dev/web2py_dev/projects/fto/gluon/restricted.py, line 205, in restricted exec ccode in environment File /home/bruce/Development/wct_dev/web2py_dev/projects/fto/applications/signon/models/db.py http://127.0.0.1:8000/admin/edit/signon/models/db.py, line 14, in module db_users = DAL('postgres://warplyde_fto:password@localhost/warplyde_fto') File /home/bruce/Development/wct_dev/web2py_dev/projects/fto/gluon/dal.py, line 5968, in __init__ raise RuntimeError, Failure to connect, tried %d times:\n%s % (attempts, tb) RuntimeError: Failure to connect, tried 5 times: Traceback (most recent call last): File /home/bruce/Development/wct_dev/web2py_dev/projects/fto/gluon/dal.py, line 5955, in __init__ self._adapter = ADAPTERS[self._dbname](*args) File /home/bruce/Development/wct_dev/web2py_dev/projects/fto/gluon/dal.py, line 1999, in __init__ self.driver = drivers.get('pg8000') AttributeError: 'list' object has no attribute 'get' -- -- Regards, Bruce Wadehttp:// ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp:...
[web2py] Re: Errors creating/reading tickets
Please email me one of the tickets that causes the problem and one of the tickets generated by admin as consequence. On Saturday, 10 March 2012 20:48:04 UTC-6, Brian M wrote: This has actually been plaguing me for a while but finally annoyed me enough to ask. I have several web2py (1.99.4) apps running under Apache/2.2.17 (Win32) , mod_wsgi/3.3 and Python/2.6.4. More often than not when an error happens and a ticket is generated, the ticket seems to be corrupt. Attempting to view the ticket creates another error for which the ticket says something like: type 'exceptions.EOFError' Version web2py™ (1, 99, 4, datetime.datetime(2011, 12, 22, 11, 20, 45), 'stable') Python Python 2.6.4: C:\vantage_dashboard\xampp\apache\bin\httpd.exe Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. Traceback (most recent call last): File C:\vantage_dashboard\xampp\web2py\gluon\restricted.py, line 204, in restricted exec ccode in environment File C:/vantage_dashboard/xampp/web2py/applications/admin/controllers/default.py https://app02:444/admin/default/edit/admin/controllers/default.py, line 1341, in module File C:\vantage_dashboard\xampp\web2py\gluon\globals.py, line 172, in lambda self._caller = lambda f: f() File C:/vantage_dashboard/xampp/web2py/applications/admin/controllers/default.py https://app02:444/admin/default/edit/admin/controllers/default.py, line 1082, in errors error = pickle.load(fullpath_file) File C:\Python26\Lib\pickle.py, line 1370, in load return Unpickler(file).load() File C:\Python26\Lib\pickle.py, line 858, in load dispatch[key](self) File C:\Python26\Lib\pickle.py, line 880, in load_eof raise EOFError EOFError Which means that I have to attempt to read the original error ticket in a text editor which is just slightly less than idea. Any ideas what might be happening? This problem doesn't seem to happen in my dev environment (also Windows but just using rocket instead of apache/mod_wsgi). Thanks, Brian
[web2py] Re: Custom register form with personnalised Auth
you the fields you do not want to db.table.field.writeable=False and the use the regular SQLFORM(db.table) On Sunday, 11 March 2012 11:15:41 UTC-5, bussiere adrien wrote: here is my auth table : (the beginning my table is correct) db.define_table( auth.settings.table_user_name, Field('Nom'), Field('Prenom'), Field('Telephone'), # NOte on user is intern and the user don't hve to see it. Field('Note on user'), How to make a custom sqlform from it ? like : def user(): # i just want some things what is needed (passwd name and all but NOT note on user on the form form = SQLFORM([auth.settings.Nom,auth.settings.Prenom]) return dict(form=form) Regards Bussiere
[web2py] Re: web2py and LGPLv3 License
On Sunday, 11 March 2012 11:07:47 UTC-5, Detectedstealth wrote: Hi, Looking through the code base, there is a file in pyfpdf/designer.py licensed under: GNU General Public License. Wont this force web2py to be GPL consider it contains code under that license? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: web2py and LGPLv3 License
I am sitting in front of Mariano at PyCon. He is the authors. He said he will change it to LGPL. Anyway, having a GPL file into contrib does not change web2py to be GPL because the file is not linked and not required by web2py to run. This is a debatable issue. Since I like to avoid ambiguities I require all files in contrib be MIT, BSD or LGPL or Apache. massimo On Sunday, 11 March 2012 11:27:28 UTC-5, Anthony wrote: Good catch. I assume that is an error, as the project as a whole says it's licensed under LGPL: http://code.google.com/p/pyfpdf/. Perhaps the license was changed at some point but the change wasn't made to this file. Anthony On Sunday, March 11, 2012 12:07:47 PM UTC-4, Detectedstealth wrote: Hi, Looking through the code base, there is a file in pyfpdf/designer.py licensed under: GNU General Public License. Wont this force web2py to be GPL consider it contains code under that license? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com On Sunday, 11 March 2012 11:27:28 UTC-5, Anthony wrote: Good catch. I assume that is an error, as the project as a whole says it's licensed under LGPL: http://code.google.com/p/pyfpdf/. Perhaps the license was changed at some point but the change wasn't made to this file. Anthony On Sunday, March 11, 2012 12:07:47 PM UTC-4, Detectedstealth wrote: Hi, Looking through the code base, there is a file in pyfpdf/designer.py licensed under: GNU General Public License. Wont this force web2py to be GPL consider it contains code under that license? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: Translations file
You have to translate locally and then push. On Sunday, 11 March 2012 16:33:01 UTC-5, Alan Etkin wrote: With a first look at the code, I don't realize how to use it in the new admin. I am thinking of a multi-translators plugin to store and manage per- user translations without patching the admin app. Does web2py for GAE support translations? (I belive GAE python runtime doesn't allow file IO) On 6 mar, 21:33, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Actually I made that long ago ago: http://dl.dropbox.com/u/18065445/Tmp/web2py.app.translatoradmin.w2p But it predates auth and the new admin design. It should be possible to merge with new admin add auth easily. massimo On Tuesday, 6 March 2012 16:43:29 UTC-6, Alan Etkin wrote: It would be great that web2py had a multi-user translation (for non- administrators). I have no idea about how could be implemented. I suppose that it can be accomplished imitating the admin code that handles the translation interface and adding support for Auth. On 6 mar, 18:26, Bruce Wade bruce.w...@gmail.com wrote: Yeah I am not worried about editing it myself, but when I get non-tech people to edit the files that is when things go bad :D. I think I am just going to write a standalone editor like the web based one that I can give to others when editing a file. On Tue, Mar 6, 2012 at 1:18 PM, Bruno Rocha rochacbr...@gmail.com wrote: On Tue, Mar 6, 2012 at 4:48 PM, Bruce Wade bruce.w...@gmail.com wrote: Any suggestions on the best way to update languages.py to prevent this from happening? You can use an editor with Pylinter and PEP8 modules (Sublime-Text-2, Geany, etc), so it will show live syntax errors and prevent problems with syntax. -- Bruno Rocha [http://rochacbruno.com.br] -- -- Regards, Bruce Wadehttp:// ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.f. ..
Re: [web2py] Re: Support for PyPy
And I have to say! it is very very fast! and you can see the different even running welcome app. I am planning to put a web2py app to run in production for some time to test it. -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Web2Py Version 1.99.7 giving the trace back during run the Cron
I am using the following model for test the cron : db.define_table(('emp'), Field('name')) and in crontab file inside the welcome app i am using the : */1 * * * * root *applications/welcome/modules/background_updater.py and makes the file inside the modules folder background_updater.py and used the code : db.emp.insert(name = 'Alex') this code is inserting the Alex in the table emp within 1 minutes interval this code is working in the version of web2py 1.99.4 perfectly but when i try this same code in the version 1.99.7 i got the following error :- RuntimeError: Failure to connect, tried 5 times: Traceback (most recent call last): File /home/tls-sanjeet/Desktop/web2py/gluon/dal.py, line 5955, in __init__ self._adapter = ADAPTERS[self._dbname](*args) File /home/tls-sanjeet/Desktop/web2py/gluon/dal.py, line 1732, in __init__ self.pool_connection(connect) File /home/tls-sanjeet/Desktop/web2py/gluon/dal.py, line 465, in pool_connection self.connection = f() File /home/tls-sanjeet/Desktop/web2py/gluon/dal.py, line 1731, in connect return self.driver.Connection(dbpath, **driver_args) OperationalError: unable to open database file
[web2py] need help with unicode decoding/encoding upload file
I'm embarrassed to say that I'm *still* having trouble getting unicode working on uploaded files. I'm sure this is an incredibly stupid easy thing to do, but unicode has never come easy for me. # model db.define_table('infile', Field('name', 'upload',uploadseparate=True)) # controller for uploading using a component def from_file(): form = SQLFORM(db.infile) if form.process().accepted: # store uploaded file request.vars.name.file.seek(0) # rewind uploaded file infile_id = db.infile.insert( name=db.infile.name.store( request.vars.name.file, request.vars.name.filename ) ) response.flash = ... response.js = ... elif file_form.errors: ... return dict(form=form) I'm trying to figure out how to encode the uploaded file before inserting it into the db manually. I've tried lots of things to encode before inserting. The latest failed attempt is this: text = reqeust.vars.name.file.getvalue() from gluon import decoder text = decoder.decoder(text) and then inserted text rather than request.vars.name.file, but this doesn't work. decoder throws a ticket saying File N:\web2py\gluon\decoder.py, line 74, in decoder return buffer.decode(encoding).encode('utf8') File c:\Program Files (x86)\Python25\lib\encodings\utf_8.py, line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode bytes in position 4-7: invalid data I'm really just grasping at straws right now. Any helpful examples would be appreciated.