[web2py] Re: convert field to multiple view values?
This is a three step process: 1) disable JS validation as float for this field form.element('input[name=height]')['_class']='feet' 2) create a custom validator that filters data in and formats data out class FEET: def __init__(self,error_message='invalid'): self.error_message=error_message def __call__(self,value): # converts 3ft 4.5in input into 1.0287 meters for DB import re match=re.compile((?Pfeet\d+)ft\s+(?Pinches\d+(\.\d +)?)in).match(value) if not match: return (value, self.error_message) return 0.30480*(int(match.group('feet')) +float(match.group('inches'))/12) #meters of course def formatter(self,value): # converts 1.0287 meters from DB into 3ft 4.5in output feet = value/0.30480 feet, inches = int(feet), (feet-int(feet))*12 return '%ift %fin' % (feet, inches) db.define_table('foo', ... Field('height', 'double', requires=FEET()), ... ) 3) (optional but nice touch) create a JS validator for CSS class 'feet' jQuery('input.double').keyup(function() {this.value=do_something(this.value);}); you have to write the function do_something to parse ft and in and output the proper formatting. Massimo On Jun 4, 11:09 am, Keith ke...@setuplinux.com wrote: I'm new to web2py and the I did this previously was with javascript but I was hoping to avoid that this go around. In my database table I have a single field something like this below: db.define_table('foo', Field('height', 'double'), In the controller/view I need to be able to translate that so when viewing a record they see: Feet, Inches, and Fractions of a Inch. When adding a record it would need to be a text field for feet and drop down lists for inches and fractions of a inch. I know how to do that in javascript, but I don't like relying on javascript if possible. I'm hoping there is a way to do this in the controller or model. Thanks for any suggestions.
[web2py] Re: web2py seems to lose session
Hello mdipierro, i only store basic python datatypes (dictionaries, floats, strings). The most complex variables that i store are dictionaries inside other dictionaries, with a max depth of 2 (i.e., a first dictionary with secondary dictionaries inside it). It is a bit strange for, while using the same client browser on the same app instance (i.e., without reloading), after a while web2py ignores the first session file and creates a second one. In other words, in what situations is web2py designed to do this behavior? Also, are there any kind of methods for clearing the session files? Because with this kind of behavior, one gets the session folder filled up very fast.. Is there any possibilty of session timeout and file deletion? Ah, this has already happened before, and the only common thing that i've detected so far is that i use tab navigation with jquery's ajax function to load content to a div. Any hints? Thanks, João Ventura PS: I'll try to debug my application down to the web2py source code to see if something triggers my thought. Any ideia where to start searching? By the way, web2py is a great framework, i've started with Django, couldn't do almost no production there, switch to web2py, and production increased a lot... Just this annoying session behavior, but hope it's a small bug.. On 6 Jun, 06:36, mdipierro mdipie...@cs.depaul.edu wrote: The only thing that comes to mind is if you try store an object in the session. The object may be an instance of class that you define and therefore web2py succeeds in storing the session but fails to retrieve it because the class is not yet defined (or imported) at the time when the session is retrieved (before your user code it executed). You can only store primitive types in session, not objects. On Jun 5, 9:04 pm, João Ventura joaojonesvent...@gmail.com wrote: Hello everyone, i've searched a lot but couldn't find any answer to the following: I'm developing a web application, and i rely heavily on sessions, storing all the user data on a session while the user uses a jquery tab interface. The problem is that sometimes web2py loses the session object, and it is almost in the same manner. I've checked my code many times and i don't mess with the session object. But as web2py does manage sessions automatically, i see that the first time i use the app, web2py creates a session file in the session folder. And when the contents of the first session disappears, when i check the sessions folder, the previous session file is there with all its contents, but now there's a new (empty) session file. I can't give a simple example how to replicate the error, but i think web2py shouldn't lose the first session, because: - I haven't explicitely called anything like session.forget() that could influence. - I haven't opened any other browser instance, tab or any other browser at all. Anybody knows anything about this? Thanks, João Ventura
[web2py] Re: Newbie question on self-submitting form
Can anyone help me with this? Still not get it.=_=
[web2py] Re: Newbie question on self-submitting form
Try changing your redirect to this: redirect(URL(r=request, f='gotopage',args=request.vars.page_no)) On Jun 6, 6:50 am, NoNoNo coldspring830...@gmail.com wrote: Can anyone help me with this? Still not get it. =_=
Re: [web2py] Is there a default file upload when filling forms?
Yes. But i end up having to do that about 15 times in my document. And we all know programs creat ways to do everything once. - Original message - Sounds like you got it. if not record.image: if record.sex == male: return male.jpg else: return female.jpg else: return record.image -- Thadeus On Sat, Jun 5, 2010 at 12:22 PM, Jason Brower encomp...@gmail.com wrote: I need the avatar (IS_IMAGE) in my authentication table to have a default if nothing is entered. Is this easily possible? I was thinking of having it controller side and just check if it was blank... if so, default it. The image would be based on the auth_user tables .sex value. Any ideas how to accomplish this? Best Regards, Jason Brower
[web2py] Re: web2py seems to lose session
On Jun 6, 4:45 am, João Ventura joaojonesvent...@gmail.com wrote: Hello mdipierro, i only store basic python datatypes (dictionaries, floats, strings). The most complex variables that i store are dictionaries inside other dictionaries, with a max depth of 2 (i.e., a first dictionary with secondary dictionaries inside it). It is a bit strange for, while using the same client browser on the same app instance (i.e., without reloading), after a while web2py ignores the first session file and creates a second one. In other words, in what situations is web2py designed to do this behavior? No. web2py reuses the same sessions for the same client over and over, unless it fails to retrieve a session. Try print request.cookies. It may help figure it out. Also, are there any kind of methods for clearing the session files? You can have the app itself clear them or you can use a cron script like admin/cron/expire_sessions.py Because with this kind of behavior, one gets the session folder filled up very fast.. Is there any possibilty of session timeout and file deletion? move admin/cron/expire_sessions.py into your app cron Ah, this has already happened before, and the only common thing that i've detected so far is that i use tab navigation with jquery's ajax function to load content to a div. Any hints? I do not understand. Sorry. Thanks, João Ventura PS: I'll try to debug my application down to the web2py source code to see if something triggers my thought. Any ideia where to start searching? By the way, web2py is a great framework, i've started with Django, couldn't do almost no production there, switch to web2py, and production increased a lot... Just this annoying session behavior, but hope it's a small bug.. On 6 Jun, 06:36, mdipierro mdipie...@cs.depaul.edu wrote: The only thing that comes to mind is if you try store an object in the session. The object may be an instance of class that you define and therefore web2py succeeds in storing the session but fails to retrieve it because the class is not yet defined (or imported) at the time when the session is retrieved (before your user code it executed). You can only store primitive types in session, not objects. On Jun 5, 9:04 pm, João Ventura joaojonesvent...@gmail.com wrote: Hello everyone, i've searched a lot but couldn't find any answer to the following: I'm developing a web application, and i rely heavily on sessions, storing all the user data on a session while the user uses a jquery tab interface. The problem is that sometimes web2py loses the session object, and it is almost in the same manner. I've checked my code many times and i don't mess with the session object. But as web2py does manage sessions automatically, i see that the first time i use the app, web2py creates a session file in the session folder. And when the contents of the first session disappears, when i check the sessions folder, the previous session file is there with all its contents, but now there's a new (empty) session file. I can't give a simple example how to replicate the error, but i think web2py shouldn't lose the first session, because: - I haven't explicitely called anything like session.forget() that could influence. - I haven't opened any other browser instance, tab or any other browser at all. Anybody knows anything about this? Thanks, João Ventura
[web2py] Re: Is there a default file upload when filling forms?
Why? I think you just need a function and call it from auth.settings.register_onvalidation auth.settings.profile_onvalidation On Jun 6, 3:57 am, Jason Brower encomp...@gmail.com wrote: Yes. But i end up having to do that about 15 times in my document. And we all know programs creat ways to do everything once. - Original message - Sounds like you got it. if not record.image: if record.sex == male: return male.jpg else: return female.jpg else: return record.image -- Thadeus On Sat, Jun 5, 2010 at 12:22 PM, Jason Brower encomp...@gmail.com wrote: I need the avatar (IS_IMAGE) in my authentication table to have a default if nothing is entered. Is this easily possible? I was thinking of having it controller side and just check if it was blank... if so, default it. The image would be based on the auth_user tables .sex value. Any ideas how to accomplish this? Best Regards, Jason Brower
[web2py] Re: web2py seems to lose session
Hello again Massimo, and thanks for the feedback. I've been troubleshooting this all day long and i've tracked this down to a view that i have that serves 2 images and two tables with information from those two images. That view is something like (the syntax is not this, just for illustration purposes): div div id=1 img src=URL(.,f=generate_image,param=1) / {{python code for the table using information on the session...}} /div div id=2 img src=URL(.,f=generate_image,param=2) / {{python code for the second table using information on the session...}} /div /div All the tables are ok, but only the first image appears. If i go call the URL of the second image directly on the browser url textarea, or using firebug, the second image appears ok. The only difference between both images is a parameter that calls inside the default.py the function generate_image, but one parameter generates one kind of image, the other parameter other kind of image. The images use information from the session. So what i found so far is: - both images called separately work fine - one after the other gives problems with session things - both images are called one after the other, but it seems that at the second time, the session object isn't defined at the time of function call, and if i do a kind of if (session.something is not None) and give something like a alert image, web2py creates a new session file and leaves the first session file in the session folder.. It seems, that the second time the method generate_image is called, the session is still not ready. If i don't return nothing, web2py works fine. If i do a 'if' inside generate_image to return an alert, web2py creates a new session and leaves the other in the folder. Is there any way of enforcing the session object to be ready when a function in default.py is called? Even if that slows down the response from the server.. I'll keep on exploring, thanks, João Ventura On 6 Jun, 14:57, mdipierro mdipie...@cs.depaul.edu wrote: On Jun 6, 4:45 am, João Ventura joaojonesvent...@gmail.com wrote: Hello mdipierro, i only store basic python datatypes (dictionaries, floats, strings). The most complex variables that i store are dictionaries inside other dictionaries, with a max depth of 2 (i.e., a first dictionary with secondary dictionaries inside it). It is a bit strange for, while using the same client browser on the same app instance (i.e., without reloading), after a while web2py ignores the first session file and creates a second one. In other words, in what situations is web2py designed to do this behavior? No. web2py reuses the same sessions for the same client over and over, unless it fails to retrieve a session. Try print request.cookies. It may help figure it out. Also, are there any kind of methods for clearing the session files? You can have the app itself clear them or you can use a cron script like admin/cron/expire_sessions.py Because with this kind of behavior, one gets the session folder filled up very fast.. Is there any possibilty of session timeout and file deletion? move admin/cron/expire_sessions.py into your app cron Ah, this has already happened before, and the only common thing that i've detected so far is that i use tab navigation with jquery's ajax function to load content to a div. Any hints? I do not understand. Sorry. Thanks, João Ventura PS: I'll try to debug my application down to the web2py source code to see if something triggers my thought. Any ideia where to start searching? By the way, web2py is a great framework, i've started with Django, couldn't do almost no production there, switch to web2py, and production increased a lot... Just this annoying session behavior, but hope it's a small bug.. On 6 Jun, 06:36, mdipierro mdipie...@cs.depaul.edu wrote: The only thing that comes to mind is if you try store an object in the session. The object may be an instance of class that you define and therefore web2py succeeds in storing the session but fails to retrieve it because the class is not yet defined (or imported) at the time when the session is retrieved (before your user code it executed). You can only store primitive types in session, not objects. On Jun 5, 9:04 pm, João Ventura joaojonesvent...@gmail.com wrote: Hello everyone, i've searched a lot but couldn't find any answer to the following: I'm developing a web application, and i rely heavily on sessions, storing all the user data on a session while the user uses a jquery tab interface. The problem is that sometimes web2py loses the session object, and it is almost in the same manner. I've checked my code many times and i don't mess with the session object. But as web2py does manage sessions automatically, i see that the first time i use the app, web2py creates a session file in the session folder.
Re: [web2py] Is there a default file upload when filling forms?
thats why you have a VirtualField called get_image_url() that does that and everywhere you need it you go record.get_image_url() More on virtualfields here: http://thadeusb.com/weblog/archive/2009/12/31/web2py_virtualfields_as_an_orm_an_sqlalchemy_approach/27 -- Thadeus On Sun, Jun 6, 2010 at 3:57 AM, Jason Brower encomp...@gmail.com wrote: Yes. But i end up having to do that about 15 times in my document. And we all know programs creat ways to do everything once. - Original message - Sounds like you got it. if not record.image: if record.sex == male: return male.jpg else: return female.jpg else: return record.image -- Thadeus On Sat, Jun 5, 2010 at 12:22 PM, Jason Brower encomp...@gmail.com wrote: I need the avatar (IS_IMAGE) in my authentication table to have a default if nothing is entered. Is this easily possible? I was thinking of having it controller side and just check if it was blank... if so, default it. The image would be based on the auth_user tables .sex value. Any ideas how to accomplish this? Best Regards, Jason Brower
[web2py] Feature request for crontab
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello all, I was wondering if the following 2 features could be added to newcron.py 1) Support sourcing application paths in crontab folder: Example: @reboot root *applications/eden/cron/sms_handler_api.py Use case: Since we are developing out application ( Sahana-eden used to be called SahanaPy) to be redistributed and installed with different application names, i.e eden above could be replaced with say, wfp. It would be nice if some syntax like the following could be used: @reboot root *currentapp/cron/sms_handler_api.py 2) Support for adding an extra attribute to limit a cron entry to work with a particular type of cron. Example: @reboot extcron root *currentapp/cron/sms_handler_api.py Use case: Say I have a threaded application inside the sms_handler_api.py - it would fail to work with softcron or hardcron. I would simply like the cron service to ignore the entry if it is not invoked via extcron. I would be grateful if the features are added into the trunk. Thanks, Praneeth -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJMC/LUAAoJENaaLQPAdAyuMOIH/RX1A/IEeIZ8dezec3/o96Et FwAgkKvihlKVc9pROF4/stWeZZdz99NSGji8qkIYg9AykK/cb2MTbVYcYW3CR9zo TuOkQ9rK8+josRY7CYh4r9990Mb6hVcXN1Q7SZ7DCN/Uk4hScEoULqxT+Z35KVby pJVnV6ned0P3mZ5cYHoRk/9ZKag2GO4smD03nB6QQhHmyr+gB1WvhjyRdM73SlDR yHciHqypkotmUD1+MD+uBLLcIN4emBhKVg8kzdzZXHfanMAW73auFzuqvBWHERTy ZaQswc2D70lWvhuL03G3ZjkdQqRT3H5VQiEOW+U17XYUu712j4LaHcnRdnz7q+E= =j+ns -END PGP SIGNATURE-
[web2py] python web console
Hi all, if I'm correct web2py had a web (java script) python console. I can't find it now, is it still included? Thanks -- Tomas Pelka
[web2py] Re: web2py seems to lose session
Hello again, well, after an entire day (about 12 hours) around this, i just made a final test with a controler and view something like: img alt=1 src={{=URL(r=request,f='get_image',vars={'param':'1'})}} / img alt=2 src={{=URL(r=request,f='get_image',vars={'param':'2'})}} / img alt=3 src={{=URL(r=request,f='get_image',vars={'param':'3'})}} / and sometimes just the first image appears, sometimes the 1st and the 2nd, sometimes the 1st and the 3rd, and very rare all... If i insist on pressing F5 to reload the images very fast, web2py loses the session, and creates another file in the session folder. get_image is a very used controller, and after digging in some foruns and in the web2py documentation, i've read something like web2py has the session object locked, and maybe it is what has been happening here: the first call to get_image locks the session, and then the second can't access the session (maybe the browser parallels the calls to the controler), and instead of waiting for the unlock, web2py fails miserably. To go around this, i've added to function get_image a session.forget(), so now it is something like this: def get_image(): ---session.forget() ---() In the web2py book it is written this about session.forget(): It tells web2py not to save the session. This should be used in those controllers whose actions are called often and do not need to track user activity.. If this kind of behavior is the purpose for forgetting the session, maybe this should be better documented in that section of the book (4.8 - session). To me, that sentence about sentence.forget sounds something like When web2py finds this, it will discard and throw away your session data.. Maybe this things of locking/unlocking of session objects should be better documented because it reflects web2py details which are unknown for the users. Or maybe i'm wrong in my conclusions, but the fact is that now all three images (see code above) appear and the problem seems to be solved. But i'm not very secure about this... Well, web2py still is a great framework, and i'll definitely keep using it! :) Congratulations for web2py, Massimo. Thanks, João Ventura On 6 Jun, 17:47, João Ventura joaojonesvent...@gmail.com wrote: Hello again Massimo, and thanks for the feedback. I've been troubleshooting this all day long and i've tracked this down to a view that i have that serves 2 images and two tables with information from those two images. That view is something like (the syntax is not this, just for illustration purposes): div div id=1 img src=URL(.,f=generate_image,param=1) / {{python code for the table using information on the session...}} /div div id=2 img src=URL(.,f=generate_image,param=2) / {{python code for the second table using information on the session...}} /div /div All the tables are ok, but only the first image appears. If i go call the URL of the second image directly on the browser url textarea, or using firebug, the second image appears ok. The only difference between both images is a parameter that calls inside the default.py the function generate_image, but one parameter generates one kind of image, the other parameter other kind of image. The images use information from the session. So what i found so far is: - both images called separately work fine - one after the other gives problems with session things - both images are called one after the other, but it seems that at the second time, the session object isn't defined at the time of function call, and if i do a kind of if (session.something is not None) and give something like a alert image, web2py creates a new session file and leaves the first session file in the session folder.. It seems, that the second time the method generate_image is called, the session is still not ready. If i don't return nothing, web2py works fine. If i do a 'if' inside generate_image to return an alert, web2py creates a new session and leaves the other in the folder. Is there any way of enforcing the session object to be ready when a function in default.py is called? Even if that slows down the response from the server.. I'll keep on exploring, thanks, João Ventura
[web2py] Re: Feature request for crontab
Good ideas. I think they can both be done. On Jun 6, 2:11 pm, Praneeth life...@gmail.com wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello all, I was wondering if the following 2 features could be added to newcron.py 1) Support sourcing application paths in crontab folder: Example: @reboot root *applications/eden/cron/sms_handler_api.py Use case: Since we are developing out application ( Sahana-eden used to be called SahanaPy) to be redistributed and installed with different application names, i.e eden above could be replaced with say, wfp. It would be nice if some syntax like the following could be used: @reboot root *currentapp/cron/sms_handler_api.py 2) Support for adding an extra attribute to limit a cron entry to work with a particular type of cron. Example: @reboot extcron root *currentapp/cron/sms_handler_api.py Use case: Say I have a threaded application inside the sms_handler_api.py - it would fail to work with softcron or hardcron. I would simply like the cron service to ignore the entry if it is not invoked via extcron. I would be grateful if the features are added into the trunk. Thanks, Praneeth -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJMC/LUAAoJENaaLQPAdAyuMOIH/RX1A/IEeIZ8dezec3/o96Et FwAgkKvihlKVc9pROF4/stWeZZdz99NSGji8qkIYg9AykK/cb2MTbVYcYW3CR9zo TuOkQ9rK8+josRY7CYh4r9990Mb6hVcXN1Q7SZ7DCN/Uk4hScEoULqxT+Z35KVby pJVnV6ned0P3mZ5cYHoRk/9ZKag2GO4smD03nB6QQhHmyr+gB1WvhjyRdM73SlDR yHciHqypkotmUD1+MD+uBLLcIN4emBhKVg8kzdzZXHfanMAW73auFzuqvBWHERTy ZaQswc2D70lWvhuL03G3ZjkdQqRT3H5VQiEOW+U17XYUu712j4LaHcnRdnz7q+E= =j+ns -END PGP SIGNATURE-
[web2py] Re: python web console
There is a button [shell] from the admin/edit page for each app. On Jun 6, 3:15 pm, Tomas Pelka tompe...@gmail.com wrote: Hi all, if I'm correct web2py had a web (java script) python console. I can't find it now, is it still included? Thanks -- Tomas Pelka
[web2py] Re: web2py seems to lose session
I am not completely sure what is going on in your case but: session.forget() only affects the current action and forces web2py to release the lock on the session file and not save it. This affects only the current action in the sense that if the session was a created by a different action that did not call forget, the session is there and any action passing the session cookie will be able to retrieve it. There are two locks. One on the session file. One on the sqlite database (imposed by sqlite itself). On Jun 6, 3:29 pm, João Ventura joaojonesvent...@gmail.com wrote: Hello again, well, after an entire day (about 12 hours) around this, i just made a final test with a controler and view something like: img alt=1 src={{=URL(r=request,f='get_image',vars={'param':'1'})}} / img alt=2 src={{=URL(r=request,f='get_image',vars={'param':'2'})}} / img alt=3 src={{=URL(r=request,f='get_image',vars={'param':'3'})}} / and sometimes just the first image appears, sometimes the 1st and the 2nd, sometimes the 1st and the 3rd, and very rare all... If i insist on pressing F5 to reload the images very fast, web2py loses the session, and creates another file in the session folder. get_image is a very used controller, and after digging in some foruns and in the web2py documentation, i've read something like web2py has the session object locked, and maybe it is what has been happening here: the first call to get_image locks the session, and then the second can't access the session (maybe the browser parallels the calls to the controler), and instead of waiting for the unlock, web2py fails miserably. To go around this, i've added to function get_image a session.forget(), so now it is something like this: def get_image(): ---session.forget() ---() In the web2py book it is written this about session.forget(): It tells web2py not to save the session. This should be used in those controllers whose actions are called often and do not need to track user activity.. If this kind of behavior is the purpose for forgetting the session, maybe this should be better documented in that section of the book (4.8 - session). To me, that sentence about sentence.forget sounds something like When web2py finds this, it will discard and throw away your session data.. Maybe this things of locking/unlocking of session objects should be better documented because it reflects web2py details which are unknown for the users. Or maybe i'm wrong in my conclusions, but the fact is that now all three images (see code above) appear and the problem seems to be solved. But i'm not very secure about this... Well, web2py still is a great framework, and i'll definitely keep using it! :) Congratulations for web2py, Massimo. Thanks, João Ventura On 6 Jun, 17:47, João Ventura joaojonesvent...@gmail.com wrote: Hello again Massimo, and thanks for the feedback. I've been troubleshooting this all day long and i've tracked this down to a view that i have that serves 2 images and two tables with information from those two images. That view is something like (the syntax is not this, just for illustration purposes): div div id=1 img src=URL(.,f=generate_image,param=1) / {{python code for the table using information on the session...}} /div div id=2 img src=URL(.,f=generate_image,param=2) / {{python code for the second table using information on the session...}} /div /div All the tables are ok, but only the first image appears. If i go call the URL of the second image directly on the browser url textarea, or using firebug, the second image appears ok. The only difference between both images is a parameter that calls inside the default.py the function generate_image, but one parameter generates one kind of image, the other parameter other kind of image. The images use information from the session. So what i found so far is: - both images called separately work fine - one after the other gives problems with session things - both images are called one after the other, but it seems that at the second time, the session object isn't defined at the time of function call, and if i do a kind of if (session.something is not None) and give something like a alert image, web2py creates a new session file and leaves the first session file in the session folder.. It seems, that the second time the method generate_image is called, the session is still not ready. If i don't return nothing, web2py works fine. If i do a 'if' inside generate_image to return an alert, web2py creates a new session and leaves the other in the folder. Is there any way of enforcing the session object to be ready when a function in default.py is called? Even if that slows down the response from the server.. I'll keep on exploring, thanks, João Ventura
[web2py] Re: python web console
You can also try the following from the command line: # in linux python web2py.py -S yourappname -M # in windows web2py.exe -S yourappname -M On Jun 6, 4:15 pm, Tomas Pelka tompe...@gmail.com wrote: Hi all, if I'm correct web2py had a web (java script) python console. I can't find it now, is it still included? Thanks -- Tomas Pelka
[web2py] Re: python web console
This is actually better because the web based shell seems to close the db connection quite soon and we do not yet know why. Massimo On Jun 6, 5:16 pm, johntynan jgty...@gmail.com wrote: You can also try the following from the command line: # in linux python web2py.py -S yourappname -M # in windows web2py.exe -S yourappname -M On Jun 6, 4:15 pm, Tomas Pelka tompe...@gmail.com wrote: Hi all, if I'm correct web2py had a web (java script) python console. I can't find it now, is it still included? Thanks -- Tomas Pelka
[web2py] Putting too much logic in a view
I have a table with the following structure. firstname string stboolean I can display the info with a view, but I'd like to check/uncheck certain names using the status check box, then delete the checked names. I feel I'm going about this the WRONG way because most of the logic should be in a controller, and views should mostly only display the data. Here's the view. Thanks in advance! table {{ for r in recs : }} tr {{=TD(r.id)}} {{=TD(r.firstname)}} tdform input type = 'checkbox' name = 'st' {{ if r.st == True: }} checked {{pass}} /form /td /tr {{pass}} table
[web2py] Re: Putting too much logic in a view
Something like this? def delete_things(): table = TABLE() recs = db(db.things.id 0).select() for rec in recs: chk = INPUT(_type='checkbox', _name='st_%s' % rec.id) table.append(TR(rec.id,rec.name,chk)) form = FORM(table,INPUT(_type='submit')) if form.accepts(request.vars,session): for k,v in request.vars.items(): if k.startswith('st_'): id = k.split('_')[-1] db(db.things.id == int(id)).delete() return dict(form=form) On Jun 6, 6:39 pm, NetAdmin mr.netad...@gmail.com wrote: I have a table with the following structure. firstname string st boolean I can display the info with a view, but I'd like to check/uncheck certain names using the status check box, then delete the checked names. I feel I'm going about this the WRONG way because most of the logic should be in a controller, and views should mostly only display the data. Here's the view. Thanks in advance! table {{ for r in recs : }} tr {{=TD(r.id)}} {{=TD(r.firstname)}} tdform input type = 'checkbox' name = 'st' {{ if r.st == True: }} checked {{pass}} /form /td /tr {{pass}} table
[web2py] Keep the instance of a class during the session
I have a module (in my_app / modules) that defines a class MyClass. This class operates with model data. In the __init__ there is a heavy workload, and data are available for other minor calculations. What I want is to create an instance of MyClass [my_object = MyClass (...)] a function of my controller and can use this instance from other functions, to avoid re-do the calculations again. I analyzed the alternatives are: 1) Save my_object in session. This is discarded because session only supports saving simple objects. 2) Save my_object with pickle and load it to the other functions. 3) Save the state of the object in the database. I do not like. 4) ¿? How do you see this approach? What other alternative can be proposed? Regards Jose
[web2py] Re: Putting too much logic in a view
I'll give it a try. Thanks! On Jun 6, 7:10 pm, mr.freeze nat...@freezable.com wrote: Something like this? def delete_things(): table = TABLE() recs = db(db.things.id 0).select() for rec in recs: chk = INPUT(_type='checkbox', _name='st_%s' % rec.id) table.append(TR(rec.id,rec.name,chk)) form = FORM(table,INPUT(_type='submit')) if form.accepts(request.vars,session): for k,v in request.vars.items(): if k.startswith('st_'): id = k.split('_')[-1] db(db.things.id == int(id)).delete() return dict(form=form) On Jun 6, 6:39 pm, NetAdmin mr.netad...@gmail.com wrote: I have a table with the following structure. firstname string st boolean I can display the info with a view, but I'd like to check/uncheck certain names using the status check box, then delete the checked names. I feel I'm going about this the WRONG way because most of the logic should be in a controller, and views should mostly only display the data. Here's the view. Thanks in advance! table {{ for r in recs : }} tr {{=TD(r.id)}} {{=TD(r.firstname)}} tdform input type = 'checkbox' name = 'st' {{ if r.st == True: }} checked {{pass}} /form /td /tr {{pass}} table
[web2py] Re: Putting too much logic in a view
Perfect! Thanks so much! One thing I've been thinking about, is putting together a reference database that will help newbies learn from working examples. As I browse the forum, I see people asking things such as How do I populate a drop-down list from a table. Providing a reference database would help give people actual working examples of code that can be viewed and customized to fit specific needs. What does everyone think? Again thanks for the GREAT example Mr. Freeze On Jun 6, 7:10 pm, mr.freeze nat...@freezable.com wrote: Something like this? def delete_things(): table = TABLE() recs = db(db.things.id 0).select() for rec in recs: chk = INPUT(_type='checkbox', _name='st_%s' % rec.id) table.append(TR(rec.id,rec.name,chk)) form = FORM(table,INPUT(_type='submit')) if form.accepts(request.vars,session): for k,v in request.vars.items(): if k.startswith('st_'): id = k.split('_')[-1] db(db.things.id == int(id)).delete() return dict(form=form) On Jun 6, 6:39 pm, NetAdmin mr.netad...@gmail.com wrote: I have a table with the following structure. firstname string st boolean I can display the info with a view, but I'd like to check/uncheck certain names using the status check box, then delete the checked names. I feel I'm going about this the WRONG way because most of the logic should be in a controller, and views should mostly only display the data. Here's the view. Thanks in advance! table {{ for r in recs : }} tr {{=TD(r.id)}} {{=TD(r.firstname)}} tdform input type = 'checkbox' name = 'st' {{ if r.st == True: }} checked {{pass}} /form /td /tr {{pass}} table
[web2py] fastcgi install not working
I just setup a new install of web2py on a shared host. Using the fastcgi instructions results in the webpage displaying the contents of dispatch.fcgi instead of executing it. What am I doing wrong? Here is dispatch.fcgi: #!/usr/bin/env /home/user/w2env/bin/python import sys from flup.server.fcgi_fork import WSGIServer import gluon.main application=gluon.main.wsgibase ## or # application=gluon.main.wsgibase_with_logging WSGIServer(application).run() Here is .htaccess: Options +FollowSymLinks +ExecCGI AddHandler fcgid-script .cgi RewriteEngine On RewriteBase / RewriteRule ^dispatch\.fcgi/ - [L] RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
Re: [web2py] Keep the instance of a class during the session
cache the object. -- Thadeus On Sun, Jun 6, 2010 at 7:23 PM, Jose jjac...@gmail.com wrote: I have a module (in my_app / modules) that defines a class MyClass. This class operates with model data. In the __init__ there is a heavy workload, and data are available for other minor calculations. What I want is to create an instance of MyClass [my_object = MyClass (...)] a function of my controller and can use this instance from other functions, to avoid re-do the calculations again. I analyzed the alternatives are: 1) Save my_object in session. This is discarded because session only supports saving simple objects. 2) Save my_object with pickle and load it to the other functions. 3) Save the state of the object in the database. I do not like. 4) ¿? How do you see this approach? What other alternative can be proposed? Regards Jose
[web2py] Quick fetch modification
I've just made a quick modification to the fetch function from gluon.tools and felt it might be worth posting. http://wklej.to/rLuT - I've pasted the code online since I didn't really have time for sending a proper patch (whatever would that mean for web2py - BTW, some guide about it wouldn't hurt). The main difference is that when not on GAE it uses httplib instead of urllib2, so it can use any HTTP method (including PUT and DELETE). It also lets you send data that is not urlencoded (some web APIs are based on JSON or XML, so I thought such a feature might come in handy. The first new feature is controlled by the method keyword argument. If it's value is not specified it behaves like it did before (POST if it sends data and GET otherwise). The second feature is controlled by the encode_data keyword argument (which defaults to True). PS. I'm affraid I didn't implement redirection handling. I'll get to it asap, but now it's 4 am in my timezone and I need some sleep right now. PPS. Since HTTPConnection.request accepts file-like objects as the requests body I think I should count that as implementing three features. ;)
[web2py] Re: Keep the instance of a class during the session
I depends on whether the data is different for each user of shared between users. In the latter case Thadeus is right: cache it. You can store any object in cache.ram value=cache.ram('key',lambda:function_that_computes_value(),expiration_time) If the data is per user you can store it in session but you need to pickle/unpickle it yourself. On Jun 6, 7:23 pm, Jose jjac...@gmail.com wrote: I have a module (in my_app / modules) that defines a class MyClass. This class operates with model data. In the __init__ there is a heavy workload, and data are available for other minor calculations. What I want is to create an instance of MyClass [my_object = MyClass (...)] a function of my controller and can use this instance from other functions, to avoid re-do the calculations again. I analyzed the alternatives are: 1) Save my_object in session. This is discarded because session only supports saving simple objects. 2) Save my_object with pickle and load it to the other functions. 3) Save the state of the object in the database. I do not like. 4) ¿? How do you see this approach? What other alternative can be proposed? Regards Jose
[web2py] Re: Quick fetch modification
I will look at it later today or tomorrow. Thanks you! On Jun 6, 9:12 pm, szabba isza...@gmail.com wrote: I've just made a quick modification to the fetch function from gluon.tools and felt it might be worth posting. http://wklej.to/rLuT- I've pasted the code online since I didn't really have time for sending a proper patch (whatever would that mean for web2py - BTW, some guide about it wouldn't hurt). The main difference is that when not on GAE it uses httplib instead of urllib2, so it can use any HTTP method (including PUT and DELETE). It also lets you send data that is not urlencoded (some web APIs are based on JSON or XML, so I thought such a feature might come in handy. The first new feature is controlled by the method keyword argument. If it's value is not specified it behaves like it did before (POST if it sends data and GET otherwise). The second feature is controlled by the encode_data keyword argument (which defaults to True). PS. I'm affraid I didn't implement redirection handling. I'll get to it asap, but now it's 4 am in my timezone and I need some sleep right now. PPS. Since HTTPConnection.request accepts file-like objects as the requests body I think I should count that as implementing three features. ;)
[web2py] Re: news?
more info here: http://www.techfuel.net/zblog/blog/view/24 On Jun 6, 3:08 am, Joschua cit_corperat...@gmx.net wrote: i'm sorry. i wanted to answer in this threadhttp://groups.google.com/group/web2py/browse_thread/thread/1857d9db96... ^^ Is there a public repository? Maybie I could work on it.. On Jun 5, 7:07 pm, mdipierro mdipie...@cs.depaul.edu wrote: Is anybody working on it? On Jun 5, 11:46 am, Joschua cit_corperat...@gmx.net wrote: Hi, is there new information about the stackoverflow-clone?
Re: [web2py] Re: parsehtml
This project: http://github.com/gabrielfalcao/dominic#readme was created by a Brazilian. Maybe it can helps with web2py HTMLParser. -- Álvaro Justen - Turicas http://blog.justen.eng.br/ 21 9898-0141
[web2py] Re: parsehtml
Amazing. Very similar. One thing that web2py TAG is missing it the ability to guess encoding. It fails and.or does mistakes if the source is not UTF8 encoded. On Jun 6, 10:57 pm, Álvaro Justen alv...@justen.eng.br wrote: This project:http://github.com/gabrielfalcao/dominic#readme was created by a Brazilian. Maybe it can helps with web2py HTMLParser. -- Álvaro Justen - Turicas http://blog.justen.eng.br/ 21 9898-0141
[web2py] Re: news?
Is there a source we can look at? On Jun 6, 10:04 pm, Richard richar...@gmail.com wrote: more info here:http://www.techfuel.net/zblog/blog/view/24 On Jun 6, 3:08 am, Joschua cit_corperat...@gmx.net wrote: i'm sorry. i wanted to answer in this threadhttp://groups.google.com/group/web2py/browse_thread/thread/1857d9db96... ^^ Is there a public repository? Maybie I could work on it.. On Jun 5, 7:07 pm, mdipierro mdipie...@cs.depaul.edu wrote: Is anybody working on it? On Jun 5, 11:46 am, Joschua cit_corperat...@gmx.net wrote: Hi, is there new information about the stackoverflow-clone?
[web2py] about SQLTABLE and truncate
Hello, I read the online book and I have a doubt, how I change the value of a truncate parameter, to never truncate text in table cell or change to another value, because in the online book not explain how doit. Thank for your help
[web2py] Re: about SQLTABLE and truncate
SQLTABLE(,truncate=32) On Jun 6, 11:42 pm, kike eacarm...@estudiantes.uci.cu wrote: Hello, I read the online book and I have a doubt, how I change the value of a truncate parameter, to never truncate text in table cell or change to another value, because in the online book not explain how doit. Thank for your help
[web2py] Re: Support for Indian Languages
Hi Massimo, Hi Massimo, Here are the translation files I intend to get. 1- Marathi mr-mr or (mar-mar) code is mr-IN 2- Gujrathi gu-gu (gu-IN) 3- Tamil ta-ta (ta-IN) 4- Bengali bn-bn (bn-IN) 5- Punjabi pa-pa (pa-IN) 6- Malayalam ml-ml (ml-IN) 7- Telugu te-te (te-IN) 8- Sanskrit sa-sa (sa-IN) 9- Oriya or-or (or-IN) 10 - Sindhi sd-sd (sd-IN) 11- Kashmiri ks-ks (ks-IN) 12- Kannada kn-kn (kn-IN) 13- Urdu ur-ur (ur-PK) 14- Konkani code( kok-IN ) 15- Hindi hi-hi (already works great) 16- Assamese as-as (as-IN) or (asm-IN) not too sure These are the files. Also one thing I noted was that when I used the plugin Translate It translated the files when web2py was online. But when I went offline, the files could not be translated. Other thing I couldn't make translations work in IE7 (online or offline). I use Firefox 3.6 and Windows XP with SP2 . Any idea how we can make this work offline? I am using web2py latest version. I had generated language files using its admin interface for my application. Regards, Rahul . On Jun 4, 6:36 pm, mdipierro mdipie...@cs.depaul.edu wrote: if you email me your language files I will include them in web2py. On Jun 4, 5:29 am, Rahul rahul.dhak...@gmail.com wrote: Hi Massimo, All, Wondering how the internationalization forIndianLanguages works. I am using latest web2py (1.78.3) on Firefox with Translate Plugin installed for translation on Windows XP (SP2). International languageslike Japanese, Chinese, Korean and others work seamlessly and thats brilliant. Also, I've successfully translated to Hindi (hi-hi) but Marathi (mr- mr) , Bengali (bn-bn) and otherlanguageslike Punjabi (pa-pa) etc don't seem to work with my application. I've even tried adding these languagesto Browser (Firefox and IE7) vialanguagesoption but no use. What am I doing wrong? Do these files need to be created exclusively? Please advice. BTW, I am repeatedly viewing your video onhttp://vimeo.com/7520812 to understand where I am going wrong. Thanks, Rahul.
[web2py] Re: Support for Indian Languages
Hi Anand, Yes that's a good idea, we can collaborate. But I am not familiar with translations. Also, I can provide help as and when time permits. Its a real busy schedule for me here. Let me know what you think. Also, I am happy we've got some people here in India working on web2py and Indian languages. Keep up the great work. :-) Thanks, Rahul
[web2py] Re: Support for Indian Languages
plugin translate uses google for translation. It cannot be made to work offline. On Jun 7, 12:02 am, Rahul rahul.dhak...@gmail.com wrote: Hi Massimo, Hi Massimo, Here are the translation files I intend to get. 1- Marathi mr-mr or (mar-mar) code is mr-IN 2- Gujrathi gu-gu (gu-IN) 3- Tamil ta-ta (ta-IN) 4- Bengali bn-bn (bn-IN) 5- Punjabi pa-pa (pa-IN) 6- Malayalam ml-ml (ml-IN) 7- Telugu te-te (te-IN) 8- Sanskrit sa-sa (sa-IN) 9- Oriya or-or (or-IN) 10 - Sindhi sd-sd (sd-IN) 11- Kashmiri ks-ks (ks-IN) 12- Kannada kn-kn (kn-IN) 13- Urdu ur-ur (ur-PK) 14- Konkani code( kok-IN ) 15- Hindi hi-hi (already works great) 16- Assamese as-as (as-IN) or (asm-IN) not too sure These are the files. Also one thing I noted was that when I used the plugin Translate It translated the files when web2py was online. But when I went offline, the files could not be translated. Other thing I couldn't make translations work in IE7 (online or offline). I use Firefox 3.6 and Windows XP with SP2 . Any idea how we can make this work offline? I am using web2py latest version. I had generated language files using its admin interface for my application. Regards, Rahul . On Jun 4, 6:36 pm, mdipierro mdipie...@cs.depaul.edu wrote: if you email me your language files I will include them in web2py. On Jun 4, 5:29 am, Rahul rahul.dhak...@gmail.com wrote: Hi Massimo, All, Wondering how the internationalization forIndianLanguages works. I am using latest web2py (1.78.3) on Firefox with Translate Plugin installed for translation on Windows XP (SP2). International languageslike Japanese, Chinese, Korean and others work seamlessly and thats brilliant. Also, I've successfully translated to Hindi (hi-hi) but Marathi (mr- mr) , Bengali (bn-bn) and otherlanguageslike Punjabi (pa-pa) etc don't seem to work with my application. I've even tried adding these languagesto Browser (Firefox and IE7) vialanguagesoption but no use. What am I doing wrong? Do these files need to be created exclusively? Please advice. BTW, I am repeatedly viewing your video onhttp://vimeo.com/7520812 to understand where I am going wrong. Thanks, Rahul.
[web2py] Re: about SQLTABLE and truncate
thank, is very easy, if i need not truncate the following sentence is correct??? SQLTABLE(,truncate=None) On Jun 7, 6:55 am, mdipierro mdipie...@cs.depaul.edu wrote: SQLTABLE(,truncate=32) On Jun 6, 11:42 pm, kike eacarm...@estudiantes.uci.cu wrote: Hello, I read the online book and I have a doubt, how I change the value of a truncate parameter, to never truncate text in table cell or change to another value, because in the online book not explain how doit. Thank for your help
[web2py] Re: Support for Indian Languages
Hi Massimo, I see, but a general question when we use inbuilt translation of web2py say like T(abc) or something in the web2py app, then would it work offline? Thanks, Rahul On Jun 7, 10:05 am, mdipierro mdipie...@cs.depaul.edu wrote: plugin translate uses google for translation. It cannot be made to work offline. On Jun 7, 12:02 am, Rahul rahul.dhak...@gmail.com wrote: Hi Massimo, Hi Massimo, Here are the translation files I intend to get. 1- Marathi mr-mr or (mar-mar) code is mr-IN 2- Gujrathi gu-gu (gu-IN) 3- Tamil ta-ta (ta-IN) 4- Bengali bn-bn (bn-IN) 5- Punjabi pa-pa (pa-IN) 6- Malayalam ml-ml (ml-IN) 7- Telugu te-te (te-IN) 8- Sanskrit sa-sa (sa-IN) 9- Oriya or-or (or-IN) 10 - Sindhi sd-sd (sd-IN) 11- Kashmiri ks-ks (ks-IN) 12- Kannada kn-kn (kn-IN) 13- Urdu ur-ur (ur-PK) 14- Konkani code( kok-IN ) 15- Hindi hi-hi (already works great) 16- Assamese as-as (as-IN) or (asm-IN) not too sure These are the files. Also one thing I noted was that when I used the plugin Translate It translated the files when web2py was online. But when I went offline, the files could not be translated. Other thing I couldn't make translations work in IE7 (online or offline). I use Firefox 3.6 and Windows XP with SP2 . Any idea how we can make this work offline? I am using web2py latest version. I had generated language files using its admin interface for my application. Regards, Rahul . On Jun 4, 6:36 pm, mdipierro mdipie...@cs.depaul.edu wrote: if you email me your language files I will include them in web2py. On Jun 4, 5:29 am, Rahul rahul.dhak...@gmail.com wrote: Hi Massimo, All, Wondering how the internationalization forIndianLanguages works. I am using latest web2py (1.78.3) on Firefox with Translate Plugin installed for translation on Windows XP (SP2). International languageslike Japanese, Chinese, Korean and others work seamlessly and thats brilliant. Also, I've successfully translated to Hindi (hi-hi) but Marathi (mr- mr) , Bengali (bn-bn) and otherlanguageslike Punjabi (pa-pa) etc don't seem to work with my application. I've even tried adding these languagesto Browser (Firefox and IE7) vialanguagesoption but no use. What am I doing wrong? Do these files need to be created exclusively? Please advice. BTW, I am repeatedly viewing your video onhttp://vimeo.com/7520812 to understand where I am going wrong. Thanks, Rahul.
[web2py] Re: about SQLTABLE and truncate
sorry not. But you can choose a very large value like 10**10 On Jun 7, 12:26 am, kike eacarm...@estudiantes.uci.cu wrote: thank, is very easy, if i need not truncate the following sentence is correct??? SQLTABLE(,truncate=None) On Jun 7, 6:55 am, mdipierro mdipie...@cs.depaul.edu wrote: SQLTABLE(,truncate=32) On Jun 6, 11:42 pm, kike eacarm...@estudiantes.uci.cu wrote: Hello, I read the online book and I have a doubt, how I change the value of a truncate parameter, to never truncate text in table cell or change to another value, because in the online book not explain how doit. Thank for your help
[web2py] Re: Support for Indian Languages
yes. In this case the translation is done by web2py beased in provided translation strings. On Jun 7, 12:47 am, Rahul rahul.dhak...@gmail.com wrote: Hi Massimo, I see, but a general question when we use inbuilt translation of web2py say like T(abc) or something in the web2py app, then would it work offline? Thanks, Rahul On Jun 7, 10:05 am, mdipierro mdipie...@cs.depaul.edu wrote: plugin translate uses google for translation. It cannot be made to work offline. On Jun 7, 12:02 am, Rahul rahul.dhak...@gmail.com wrote: Hi Massimo, Hi Massimo, Here are the translation files I intend to get. 1- Marathi mr-mr or (mar-mar) code is mr-IN 2- Gujrathi gu-gu (gu-IN) 3- Tamil ta-ta (ta-IN) 4- Bengali bn-bn (bn-IN) 5- Punjabi pa-pa (pa-IN) 6- Malayalam ml-ml (ml-IN) 7- Telugu te-te (te-IN) 8- Sanskrit sa-sa (sa-IN) 9- Oriya or-or (or-IN) 10 - Sindhi sd-sd (sd-IN) 11- Kashmiri ks-ks (ks-IN) 12- Kannada kn-kn (kn-IN) 13- Urdu ur-ur (ur-PK) 14- Konkani code( kok-IN ) 15- Hindi hi-hi (already works great) 16- Assamese as-as (as-IN) or (asm-IN) not too sure These are the files. Also one thing I noted was that when I used the plugin Translate It translated the files when web2py was online. But when I went offline, the files could not be translated. Other thing I couldn't make translations work in IE7 (online or offline). I use Firefox 3.6 and Windows XP with SP2 . Any idea how we can make this work offline? I am using web2py latest version. I had generated language files using its admin interface for my application. Regards, Rahul . On Jun 4, 6:36 pm, mdipierro mdipie...@cs.depaul.edu wrote: if you email me your language files I will include them in web2py. On Jun 4, 5:29 am, Rahul rahul.dhak...@gmail.com wrote: Hi Massimo, All, Wondering how the internationalization forIndianLanguages works. I am using latest web2py (1.78.3) on Firefox with Translate Plugin installed for translation on Windows XP (SP2). International languageslike Japanese, Chinese, Korean and others work seamlessly and thats brilliant. Also, I've successfully translated to Hindi (hi-hi) but Marathi (mr- mr) , Bengali (bn-bn) and otherlanguageslike Punjabi (pa-pa) etc don't seem to work with my application. I've even tried adding these languagesto Browser (Firefox and IE7) vialanguagesoption but no use. What am I doing wrong? Do these files need to be created exclusively? Please advice. BTW, I am repeatedly viewing your video onhttp://vimeo.com/7520812 to understand where I am going wrong. Thanks, Rahul.