Re: [web2py] Re: web2py 1.90.6 is OUT
On 21 December 2010 09:47, mdipierro mdipie...@cs.depaul.edu wrote: The problem is this field: Field(publishers_details,string, length=1024) , The new dal thinks (incorrecly) this is too much. I have now fixed it in trunk and soon post a new stable version with the fix. Thanks. I am using Postgresql. Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
[web2py] Formatted data entries
I have in the past asked a similar question and could not find a solution. I am trying again. I have to read in thousands of records into a database and some entries contains very spesific formatting. I want to preserve that if possible and have them presented as such through web2py. Here is a partial example of one field before I import it into the database. 12-deoxyphorbol-13-(2-methylbutyrate)-20-acetate (b2/b), and two new phorbol esters, 12-deoxyphorbol-13-isobutyrate-16-angelate-20-acetate (b3/b) and 12-deoxyphorbol-13-(2-methylbutyrate)-16-angelate-20-acetate (b4/b), were isolated from the endemic South African plant iEuphorbia bothae/i. I would appreciate some guidelines on handling this. I suspect I may have to translate such text into markup or markdown. If so, pointers to tutorials will help me please. Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
[web2py] Re: Error in web2py book
On Dec 21, 4:26 am, Martin H helpmh...@gmail.com wrote: It should be the other way around: where 3,4,5 are replicated servers and 1,2,3 are slaves. Fixed. The section should also be changed to: Using Replicated Database Servers OR Using Replicated Databases Fixed. Many thanks for your keen eyes!
Re: [web2py] Re: Python Shell on Chrome
very nice! thank you! On 21 December 2010 03:44, mdipierro mdipie...@cs.depaul.edu wrote: Anyway... I merged the google shell with web2py. We now have a new shell: http://127.0.0.1:8000/admin/shell/index/appname should work better then before and should work on GAE too. Please give it a try.
Re: [web2py] Re: Python Shell on Chrome
+1 2010/12/21 Tom Atkins minkto...@gmail.com: very nice! thank you! On 21 December 2010 03:44, mdipierro mdipie...@cs.depaul.edu wrote: Anyway... I merged the google shell with web2py. We now have a new shell: http://127.0.0.1:8000/admin/shell/index/appname should work better then before and should work on GAE too. Please give it a try.
[web2py] another funtion in view
I want to use a function in index.html other than index(). Where I should define ?
Re: [web2py] another funtion in view
If you want to use the same view/default/index.html in other controller? example: in controller/default.py def another(): response.view='default/index.html' 2010/12/21 Sahil Arora sahilarora...@gmail.com: I want to use a function in index.html other than index(). Where I should define ? -- My blog: http://martin.tecnodoc.com.ar My portfolio *spanish*: http://www.tecnodoc.com.ar Checkout my last proyect instant-press: http://www.instant2press.com
Re: [web2py] another funtion in view
no , i know this. But i want to use a function say view( ) as well as index( ) in index.html. I want to use the output of view( ) in index.html On 12/21/10, Martín Mulone mulone.mar...@gmail.com wrote: If you want to use the same view/default/index.html in other controller? example: in controller/default.py def another(): response.view='default/index.html' 2010/12/21 Sahil Arora sahilarora...@gmail.com: I want to use a function in index.html other than index(). Where I should define ? -- My blog: http://martin.tecnodoc.com.ar My portfolio *spanish*: http://www.tecnodoc.com.ar Checkout my last proyect instant-press: http://www.instant2press.com -- Sahil Arora B.Tech 2nd year Computer Science and Engineering IIT Delhi Contact No: +91 9871491046
Re: [web2py] another funtion in view
I dont understand what do you want to achieve if view is a function declared in models and call it (ex: func_view), and return data in 'controllers/default.py' def view(): response.view='default/index.html' mydata = func_view() return dict(mydata=mydata) def index(): response.view='default/index.html' mydata = func_view() return dict(mydata=mydata) in 'view/default/index.html' {{include layout.html}} {{=mydata}} 2010/12/21 Sahil Arora sahilarora...@gmail.com: no , i know this. But i want to use a function say view( ) as well as index( ) in index.html. I want to use the output of view( ) in index.html On 12/21/10, Martín Mulone mulone.mar...@gmail.com wrote: If you want to use the same view/default/index.html in other controller? example: in controller/default.py def another(): response.view='default/index.html' 2010/12/21 Sahil Arora sahilarora...@gmail.com: I want to use a function in index.html other than index(). Where I should define ? -- My blog: http://martin.tecnodoc.com.ar My portfolio *spanish*: http://www.tecnodoc.com.ar Checkout my last proyect instant-press: http://www.instant2press.com -- Sahil Arora B.Tech 2nd year Computer Science and Engineering IIT Delhi Contact No: +91 9871491046 -- My blog: http://martin.tecnodoc.com.ar My portfolio *spanish*: http://www.tecnodoc.com.ar Checkout my last proyect instant-press: http://www.instant2press.com
[web2py] Recent Posts in plugin_wiki
Hi, I am using the plugin_wiki (which is fantastic by the way) and the Rambling plugin_layout. I am trying to make it a bit more blog like by listing recent posts. I have created a file recentPosts.html which is: ul {{for recent in recents:}} li a href=/bs/plugin_wiki/page/{{recent.slug}} {{=recent.slug}} /a /li {{pass}} /ul and in the default.py controller defined: def recentPosts(): return dict(recents=db().select(db.plugin_wiki_page.slug, db.plugin_wiki_page.created_on )) this works fine when I load the page /myApp/default/recentPosts However: I want to show the recent posts in the sidebar. So I have put {{include 'recentPosts.html'}} in layout.html and written the index.html as: {{left_sidebar_enabled=right_sidebar_enabled=False}} {{extend 'layout.html'}} {{=plugin_wiki.embed_page('home') or ''}} When I run this I get an error: Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /home/www-data/web2py/applications/myApp/views/default/ index.html, line 53, in module NameError: name 'recents' is not defined OK, so I add to index() in default.py return dict(message=T('Hello World'), recents=db().select(db.plugin_wiki_page.slug, db.plugin_wiki_page.created_on )) And this works fine until I try to select another wiki page. Where I get the error: Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /home/www-data/web2py/applications/myApp/views/plugin_wiki/ page.html, line 79, in module NameError: name 'recents' is not defined So the problem seems to be that the recents definition does not seem to be cascading down from the layout.html. I have tried to define it under plugin_wiki.py, but no luck. I hope I have defined the problem as clearly as possible. Any help, much appreciated.
[web2py] Upload files with accepting only (png, gif, jpg)
hi, how can i realise this? thanks peter
[web2py] Re: Upload files with accepting only (png, gif, jpg)
Try db,define_table('image;, Field('image, 'upload', notnull=True, requires=[IS_IAMGE()]), ) On Dec 21, 9:02 pm, pk peter.kirch...@youngdesigners.de wrote: hi, how can i realise this? thanks peter
[web2py] default values in options widget
Hi, is it possible to set a default value to a widgets.options.widget? model: db = DAL('sqlite://storage.sqlite') db.define_table('mytable', Field('options_1', 'text', widget = SQLFORM.widgets.options.widget ), Field('options_2', 'text', widget = SQLFORM.widgets.options.widget )) db.mytable.options_1.requires = [IS_IN_SET(['option_1', 'option_2', 'option_3', 'option_4', 'unknown'], zero = None)] db.mytable.options_2.requires = [IS_IN_SET(['option_1', 'option_2', 'option_3', 'option_4', 'unknown'], zero = None)] controller: from gluon.tools import Crud def index(): crud = Crud(globals(), db) if request.args(0): values = db(db.mytable.id == request.args(0)).select(db.mytable.ALL)[0] form = crud.update(db.mytable, request.args(0), onvalidation = validate_values) # # How to set the default value (option value=unknown selected=selectedunknown/option) # mean stuff like # if values.option_1 == None: # db.mytable.option_1 = 'unknown' # or # # if values.option_2 == None: # form.custom.dspval.option_2 = 'unknown' # # This does not work properly! Any suggestions? # Is it posible to create an optionswidget, which must not be selected and can be empty? # else: values = None form = crud.create(db.mytable) return dict(form = form, values = values) def validate_values(form): for value in form.vars: if form.vars[value] == 'unknown': form.vars[value] = None In this special case the user have to select 'unknown' if he didn't know the value during record creation, but later (during update), the user must not select a value, None values are automatically set to unknown. thanks max
[web2py] Re: Exception during file autodelete
Thanks for fix line ! On Dec 14, 12:50 am, Kurt Grutzmacher gr...@jingojango.net wrote: Using latest web2py trunk. Upload Field configured for autodelete=True and executing del db.t_file_uploads[form.vars.id] after processing the file: File /Users/grutz/src/web2py/gluon/dal.py, line 3696, in __delitem__ elif not str(key).isdigit() or not self._db(self.id == key).delete(): File /Users/grutz/src/web2py/gluon/dal.py, line 4381, in delete self.delete_uploaded_files() File /Users/grutz/src/web2py/gluon/dal.py, line 4412, in delete_uploaded_files uploadfolder = os.path.join(self.db._folder, '..', 'uploads') File /Users/grutz/src/web2py/gluon/dal.py, line 3329, in __getattr__ return dict.__getitem__(self,key) KeyError: '_folder' FIX: Line 4412 in dal.py should be: uploadfolder = os.path.join(self.db._adapter.folder, '..', 'uploads')
[web2py] Re: default values in options widget
Hi, sorry i was to hasty posting my problem. The easiest way to solve this problem is to change: db.mytable.options_1.requires = [IS_IN_SET(['option_1', 'option_2', 'option_3', 'option_4', 'unknown'], zero = None)] into: db.mytable.options_1.requires = [IS_IN_SET({'option_1' : 'Option 1', 'option_2' : 'Option 2', 'option_3 : 'Option 3'', 'option_4' : 'Option 4', None: 'unknown'}, zero = None)] documentation: IS_IN_SET({'id1':'first label', 'id2':'second label'})('id1') http://web2py.com/examples/static/epydoc/web2py.gluon.validators.IS_IN_SET-class.html thanks max
[web2py] Left Join with aliased table and the new DAL
Hi everyone, I currently use Web2py for an internal corporation application. I recently upgraded from 1.89 to 1.90-6. Since this upgrade all my left joins with aliased table don't work any more. I'm using Web2py with Postgres. For example I have this in a controller exposed function: Domain = dbPsnol.domain Client = dbPsnol.client Manager = dbPsnol.contact.with_alias('manager') infos = dbPsnol(Domain.id==request.args[0]).select( Domain.ALL, Client.ALL,Manager.ALL, left=[ Client.on(Client.id==Domain.client_id), Manager.on(Manager.id==Client.manager_id)]) This example generate the following error: ProgrammingError: invalid reference to FROM-clause entry for table domain LINE 1: ... domain, contact LEFT JOIN client ON (client.id = domain.cli... ^ HINT: There is an entry for table domain, but it cannot be referenced from this part of the query. And as soon as I redefine Manager like this: Manager = dbPsnol.contact I don't get the error any more. But the result is not what I want. Is this a bug in the new DAL or is there an other way to do what I want ?
Re: [web2py] How to do this in web2py..?
http://www.web2pyslices.com/main/slices/take_slice/85 On Mon, Dec 20, 2010 at 10:13 AM, Fabiano fabianoeng...@gmail.com wrote: Hi, I am new to web2py and sure not if I am doing things the best way. I am designing an app and would like your opinion on my choices and also how could I implement some stuff in web2py. My problem: I have classes of stuff that I want to store on the database. Stuff here is very generic and could be anything. (Not related to OO, it is part of the problem I am modeling). The final end users of my app will be able to select a class to create an instance, by giving a name to it and selecting options for it. For each class I insert on my database I may have different options available with different values. For example, I may have a class person with option sex with values male, female. A user may select this class person to create a person, giving a name to it and selecting one value for its sex option. I may have a class Pie One on my database, with an option flavor with values flavor 1, flavor 2, flavor 3 and another option Fruit with values apple, banana. I may have another class Pie Two also with an option flavor but now with different available values for it: flavor 2, flavor 4 an no option Fruit now. When user chooses that it wants a Pie One, he must also choose a value for its flavor, but only from available flavor for Pie One, and also must choose a value for its fruit option. If user wants a Pie Two, the only option is flavor, there is no fruit nor sex option for this class. So far, we could have tables like this: Stuff id: name: 1 'person' 2 'pie one' 3 'pie two' Option id: name: 1 'sex' 2 'flavor' 3 'fruit' OptionValue id: option_id: name: 1 1'male' 2 1'female' 3 2'flavor 1' 4 2'flavor 2' 5 2'flavor 3' 6 2'flavor 4' 7 3'apple' 8 3'banana' StuffOption stuff_id: option_value: 1 1 1 2 2 3 2 4 2 5 2 7 2 8 3 4 3 6 From this, I can derive the option names available for each class by its option values (values grouped by option names actually). When user will instantiate a class of pie one, I want to show him a field flavor with a dropdown box with available flavors for this class, and another field fruit with fruits available for this class in a dropdown box. I may have many options for each class (or none) and the values available for the same option may be different in different classes, so this has to be generic. How could I show these dropdowns in web2py? There is more. Each of theses classes will be classified in categories, but each one may be in none or more than one category. Also, when I display all classes of a category I must be able to customize the order where the classes appear, and the order will be independent for each category. I thought in implement this with something like: Category id: name: 1'people' 2'pies' StuffCategory category_id: stuff_id: position: 2 2 2 2 3 1 I would them retrieve items inverse ordered by position column, and also set this column as autoincrement. This way, when I insert a new class it will always show first on the list by default. If, lets say, I want to insert an item on position 7, before insert it I would do: UPDATE StuffCategory SET position = position + 1 WHERE position = 7 and then insert it with its position = 7. It would be similar to move an class to a specific position, update all position values between it and the desired position, before setting the desired position. Would you guys say is this a good way to achieve this functionality or is there a better way? Also, I don't want to write SQL directly, how could I do this nicely in web2py? An additional interface I'd like to provide to admin to change the order would be to list all classes in the right order, and in from of each class, there would be two buttons: up and down arrows. clicking on them would swap its position with the next record. I think this would be great in an ajax interface, but I don't have a clue how to do it in web2py yet. And now, my last problem. Each of these classes will have a number of images associated with them. One of the images of each class will be its main image. Each value may have one of its image associate with it also. For this, I may have an Image table: Image id: stuff_id: image: And add a main_image_id column to stuff table. I thought of main_image column be a reference to image table so it would be easy to change the main image between the images available for that class. For the option values, I could add a column image_id also, where
Re: [web2py] another funtion in view
On Dec 21, 2010, at 3:31 AM, Sahil Arora wrote: no , i know this. But i want to use a function say view( ) as well as index( ) in index.html. I want to use the output of view( ) in index.html Martin has the right idea, I think. Factor out the common logic and call it from view() and index(). On 12/21/10, Martín Mulone mulone.mar...@gmail.com wrote: If you want to use the same view/default/index.html in other controller? example: in controller/default.py def another(): response.view='default/index.html' 2010/12/21 Sahil Arora sahilarora...@gmail.com: I want to use a function in index.html other than index(). Where I should define ?
[web2py] Re: Formatted data entries
I think you just need: db.mytable.myfield.represent=lambda x: XML(x,sanitize=True) On Dec 21, 3:03 am, Johann Spies johann.sp...@gmail.com wrote: I have in the past asked a similar question and could not find a solution. I am trying again. I have to read in thousands of records into a database and some entries contains very spesific formatting. I want to preserve that if possible and have them presented as such through web2py. Here is a partial example of one field before I import it into the database. 12-deoxyphorbol-13-(2-methylbutyrate)-20-acetate (b2/b), and two new phorbol esters, 12-deoxyphorbol-13-isobutyrate-16-angelate-20-acetate (b3/b) and 12-deoxyphorbol-13-(2-methylbutyrate)-16-angelate-20-acetate (b4/b), were isolated from the endemic South African plant iEuphorbia bothae/i. I would appreciate some guidelines on handling this. I suspect I may have to translate such text into markup or markdown. If so, pointers to tutorials will help me please. Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
[web2py] Re: Error in web2py book
thanks. On Dec 21, 3:17 am, cjrh caleb.hatti...@gmail.com wrote: On Dec 21, 4:26 am, Martin H helpmh...@gmail.com wrote: It should be the other way around: where 3,4,5 are replicated servers and 1,2,3 are slaves. Fixed. The section should also be changed to: Using Replicated Database Servers OR Using Replicated Databases Fixed. Many thanks for your keen eyes!
[web2py] Re: Recent Posts in plugin_wiki
If you put {{include 'recentPosts.html'}} in layout.html than the view 'recentPosts.html' is included in the layout but the corresponding action is not called. Try replace {{include 'recentPosts.html'}} with {{=LOAD('default','recentPosts',ajax=True)}} On Dec 21, 6:53 am, nic nicats...@gmail.com wrote: Hi, I am using the plugin_wiki (which is fantastic by the way) and the Rambling plugin_layout. I am trying to make it a bit more blog like by listing recent posts. I have created a file recentPosts.html which is: ul {{for recent in recents:}} li a href=/bs/plugin_wiki/page/{{recent.slug}} {{=recent.slug}} /a /li {{pass}} /ul and in the default.py controller defined: def recentPosts(): return dict(recents=db().select(db.plugin_wiki_page.slug, db.plugin_wiki_page.created_on )) this works fine when I load the page /myApp/default/recentPosts However: I want to show the recent posts in the sidebar. So I have put {{include 'recentPosts.html'}} in layout.html and written the index.html as: {{left_sidebar_enabled=right_sidebar_enabled=False}} {{extend 'layout.html'}} {{=plugin_wiki.embed_page('home') or ''}} When I run this I get an error: Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /home/www-data/web2py/applications/myApp/views/default/ index.html, line 53, in module NameError: name 'recents' is not defined OK, so I add to index() in default.py return dict(message=T('Hello World'), recents=db().select(db.plugin_wiki_page.slug, db.plugin_wiki_page.created_on )) And this works fine until I try to select another wiki page. Where I get the error: Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 188, in restricted exec ccode in environment File /home/www-data/web2py/applications/myApp/views/plugin_wiki/ page.html, line 79, in module NameError: name 'recents' is not defined So the problem seems to be that the recents definition does not seem to be cascading down from the layout.html. I have tried to define it under plugin_wiki.py, but no luck. I hope I have defined the problem as clearly as possible. Any help, much appreciated.
[web2py] Re: default values in options widget
You do not sent it in the widget.You have to set the default attribute for the field. On Dec 21, 5:01 am, max maxopp...@googlemail.com wrote: Hi, is it possible to set a default value to a widgets.options.widget? model: db = DAL('sqlite://storage.sqlite') db.define_table('mytable', Field('options_1', 'text', widget = SQLFORM.widgets.options.widget ), Field('options_2', 'text', widget = SQLFORM.widgets.options.widget )) db.mytable.options_1.requires = [IS_IN_SET(['option_1', 'option_2', 'option_3', 'option_4', 'unknown'], zero = None)] db.mytable.options_2.requires = [IS_IN_SET(['option_1', 'option_2', 'option_3', 'option_4', 'unknown'], zero = None)] controller: from gluon.tools import Crud def index(): crud = Crud(globals(), db) if request.args(0): values = db(db.mytable.id == request.args(0)).select(db.mytable.ALL)[0] form = crud.update(db.mytable, request.args(0), onvalidation = validate_values) # # How to set the default value (option value=unknown selected=selectedunknown/option) # mean stuff like # if values.option_1 == None: # db.mytable.option_1 = 'unknown' # or # # if values.option_2 == None: # form.custom.dspval.option_2 = 'unknown' # # This does not work properly! Any suggestions? # Is it posible to create an optionswidget, which must not be selected and can be empty? # else: values = None form = crud.create(db.mytable) return dict(form = form, values = values) def validate_values(form): for value in form.vars: if form.vars[value] == 'unknown': form.vars[value] = None In this special case the user have to select 'unknown' if he didn't know the value during record creation, but later (during update), the user must not select a value, None values are automatically set to unknown. thanks max
[web2py] web2py.com is down
tried accessing it right now but no response
[web2py] Re: web2py.com is down
Same here. On Dec 21, 11:14 am, weheh richard_gor...@verizon.net wrote: tried accessing it right now but no response
Re: [web2py] Re: web2py.com is down
Yep, same here. Nor .com or .org something happen on the server. may be we need an HA mirror.the examples app running on GAE could be a second choice when main server goes down. (http://web2pysite.appspot.com/examples/default/index) if there is a way to keep it updated and a default route when server time outs. 2010/12/21 DenesL denes1...@yahoo.ca Same here. On Dec 21, 11:14 am, weheh richard_gor...@verizon.net wrote: tried accessing it right now but no response -- Bruno Rocha http://about.me/rochacbruno/bio
Re: [web2py] Re: web2py.com is down
http://wasitup.com/ -- Thadeus On Tue, Dec 21, 2010 at 10:22 AM, Bruno Rocha rochacbr...@gmail.com wrote: Yep, same here. Nor .com or .org something happen on the server. may be we need an HA mirror.the examples app running on GAE could be a second choice when main server goes down. (http://web2pysite.appspot.com/examples/default/index) if there is a way to keep it updated and a default route when server time outs. 2010/12/21 DenesL denes1...@yahoo.ca Same here. On Dec 21, 11:14 am, weheh richard_gor...@verizon.net wrote: tried accessing it right now but no response -- Bruno Rocha http://about.me/rochacbruno/bio
[web2py] Re: web2py.com is down
It is not down but somehow it is incredibly show. The problem is not with the server but looks more like a bandwidth problem. Let's way today and see if it is temporary. Massimo On Dec 21, 10:22 am, Bruno Rocha rochacbr...@gmail.com wrote: Yep, same here. Nor .com or .org something happen on the server. may be we need an HA mirror.the examples app running on GAE could be a second choice when main server goes down. (http://web2pysite.appspot.com/examples/default/index) if there is a way to keep it updated and a default route when server time outs. 2010/12/21 DenesL denes1...@yahoo.ca Same here. On Dec 21, 11:14 am, weheh richard_gor...@verizon.net wrote: tried accessing it right now but no response -- Bruno Rochahttp://about.me/rochacbruno/bio
[web2py] Re: Left Join with aliased table and the new DAL
Thanks for reporting this. It is definitively a bug and I will try fix it today. On Dec 21, 9:25 am, HaM yarib...@gmail.com wrote: Hi everyone, I currently use Web2py for an internal corporation application. I recently upgraded from 1.89 to 1.90-6. Since this upgrade all my left joins with aliased table don't work any more. I'm using Web2py with Postgres. For example I have this in a controller exposed function: Domain = dbPsnol.domain Client = dbPsnol.client Manager = dbPsnol.contact.with_alias('manager') infos = dbPsnol(Domain.id==request.args[0]).select( Domain.ALL, Client.ALL,Manager.ALL, left=[ Client.on(Client.id==Domain.client_id), Manager.on(Manager.id==Client.manager_id)]) This example generate the following error: ProgrammingError: invalid reference to FROM-clause entry for table domain LINE 1: ... domain, contact LEFT JOIN client ON (client.id = domain.cli... ^ HINT: There is an entry for table domain, but it cannot be referenced from this part of the query. And as soon as I redefine Manager like this: Manager = dbPsnol.contact I don't get the error any more. But the result is not what I want. Is this a bug in the new DAL or is there an other way to do what I want ?
[web2py] Re: web2py.com is down
Works for me. Tried from locations in USA (Texas), Slovenia and Serbia... Yes, the site responds a bit slower than usual. Traceroute looks ok. Let me know if you need any connectivity/speed tests done... I tried downloading web2py release and just about maxed out the 10 mbit line here. I can try from a faster location, but sheer download bandwidth seems ok.
Re: [web2py] Re: web2py.com is down
Work for me. No slowness here. 2010/12/21 LightDot light...@gmail.com: Works for me. Tried from locations in USA (Texas), Slovenia and Serbia... Yes, the site responds a bit slower than usual. Traceroute looks ok. Let me know if you need any connectivity/speed tests done... I tried downloading web2py release and just about maxed out the 10 mbit line here. I can try from a faster location, but sheer download bandwidth seems ok. -- My blog: http://martin.tecnodoc.com.ar My portfolio *spanish*: http://www.tecnodoc.com.ar Checkout my last proyect instant-press: http://www.instant2press.com
[web2py] Re: parse_get_post_vars change
So, does anyone have any thoughts on why request.vars was changed in this way? Is this a good way in which I can patch this parsing function? Or should I rewrite all of those places in our app? Thanks! On Dec 17, 12:34 pm, NuclearDragon nucleardragon...@gmail.com wrote: So, I am in the process of upgrading Web2py from version 1.67 to 1.89.5. Ouch. One of the things I encountered is that request.vars will now include a list of duplicate values, rather than a single value (not a list) as it previously did. For example, our url includes a _next variable. So does the form when posting, including the Cancel action. So now I end up with a list of 2 duplicate values when I test set redirurl = request.vars.get('_next'). Rather than change that umpteen times in our app, I am proposing a change to the function 'parse_get_post_vars' in main.py. def parse_get_post_vars(request, environ): # always parse variables in URL for GET, POST, PUT, DELETE, etc. in get_vars dget = cgi.parse_qsl(request.env.query_string, keep_blank_values=1) for (key, value) in dget: if key in request.get_vars: if isinstance(request.get_vars[key], list): request.get_vars[key] += [value] else: request.get_vars[key] = [request.get_vars[key]] + [value] else: request.get_vars[key] = value request.vars[key] = request.get_vars[key] # parse POST variables on POST, PUT, BOTH only in post_vars request.body = copystream_progress(request) ### stores request body if (request.body and request.env.request_method in ('POST', 'PUT', 'BOTH')): dpost = cgi.FieldStorage(fp=request.body,environ=environ,keep_blank_values=1) # The same detection used by FieldStorage to detect multipart POSTs is_multipart = dpost.type[:10] == 'multipart/' request.body.seek(0) isle25 = sys.version_info[1] = 5 def listify(a): return (not isinstance(a,list) and [a]) or a try: keys = sorted(dpost) except TypeError: keys = [] for key in keys: dpk = dpost[key] # if en element is not a file replace it with its value else leave it alone if isinstance(dpk, list): if not dpk[0].filename: value = [x.value for x in dpk] else: value = [x for x in dpk] elif not dpk.filename: value = dpk.value else: value = dpk pvalue = listify(value) if key in request.vars: gvalue = listify(request.vars[key]) if isle25: value = pvalue + gvalue elif is_multipart: pvalue = pvalue[len(gvalue):] else: pvalue = pvalue[:-len(gvalue)] request.vars[key] = value if len(pvalue): request.post_vars[key] = (len(pvalue)1 and pvalue) or pvalue[0] ### Begin added code for k,v in request.vars.iteritems(): if isinstance(v, list) and len(v)==2: request.vars[k] = v[0] if v[0] == v[1] else v ### End added code Thoughts? Comments? Any reason I shouldn't make this change?
[web2py] Re: Requires login decorator error
Any insights as to why self.settings.on_failed_authentication is None at this point? Should I be setting that value somewhere? It's difficult for me to tell what the value should be, since with my change it still returns to the login page with a flash message of Invalid Login. On Dec 16, 9:02 pm, NuclearDragon nucleardragon...@gmail.com wrote: I was getting an error when attempting to go to a page that requires you be logged in, if I was not logged in. Traceback: Traceback (most recent call last): File /xxx/app/gluon/restricted.py, line 188, in restricted exec ccode in environment File /xxx/app/applications/init/controllers/x.py, line 2712, in module File /xxx/app/gluon/globals.py, line 96, in lambda self._caller = lambda f: f() File /xxx/app/gluon/tools.py, line 2271, in f '?_next='+urllib.quote(next) File /xxx/app/gluon/tools.py, line 65, in call_or_redirect redirect(f) File /xxx/app/gluon/http.py, line 101, in redirect location = location.replace('\r', '%0D').replace('\n', '%0A') AttributeError: 'NoneType' object has no attribute 'replace' So I changed: return call_or_redirect(self.settings.on_failed_authentication, self.settings.login_url + \ '? _next='+urllib.quote(next) ) to: if self.settings.on_failed_authentication: return call_or_redirect(self.settings.on_failed_authentication, self.settings.login_url + \ '? _next='+urllib.quote(next) ) else: return call_or_redirect(self.settings.login_url + \ '? _next='+urllib.quote(next) ) Does anyone have any thoughts as to why that was happening? A print statement of self.settings.on_failed_authentication at that point displays None, which affects the workings of the call_or_redirect function.
[web2py] Re: web2py.com is down
AOK. Back again. On Dec 21, 11:48 am, Martín Mulone mulone.mar...@gmail.com wrote: Work for me. No slowness here. 2010/12/21 LightDot light...@gmail.com: Works for me. Tried from locations in USA (Texas), Slovenia and Serbia... Yes, the site responds a bit slower than usual. Traceroute looks ok. Let me know if you need any connectivity/speed tests done... I tried downloading web2py release and just about maxed out the 10 mbit line here. I can try from a faster location, but sheer download bandwidth seems ok. -- My blog: http://martin.tecnodoc.com.ar My portfolio *spanish*: http://www.tecnodoc.com.ar Checkout my last proyect instant-press:http://www.instant2press.com
Re: [web2py] Re: web2py 1.90.6 is OUT
I just pulled trunk and got this error: rochacbr...@macubuntu:~$ python projects/web2py/web2py.py -a 1234 Traceback (most recent call last): File /home/rochacbruno/projects/web2py/gluon/sql.py, line 5, in module from dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, drivers, BaseAdapter, SQLField, SQLTable, SQLXorable, SQLQuery, SQLSet, SQLRows, SQLStorage, SQLDB, GQLDB, SQLALL, SQLCustomType File /home/rochacbruno/projects/web2py/gluon/dal.py, line 1 !/bin/env python ^ SyntaxError: invalid syntax -- Bruno Rocha http://about.me/rochacbruno/bio
[web2py] Re: default values in options widget
ok actually I thought I have sovled my problem with writing None values to the database with this: IS_IN_SET({None :'unknown', 'option_1:'Option 1'}, zero = None) in stead of: IS_IN_SET(['unknown', 'option_1'], zero = None) but you are right, this only works when I use curd.create the first time. If I try to edit my record with crud.update later, the mapping does not work and the options widget selects a arbitrary value from the dictionary (in case of crud.create, too). But I'd like to have the 'unknown' label in case of None value in database. You think setting the default value to the field? db.mytable.myfield.default = defaultvalue does actually only work with string widget, options widget shows no response. thanks so far
[web2py] Re: Upload files with accepting only (png, gif, jpg)
http://web2py.com/book/default/chapter/07?search=IS_UPLOAD_FILENAME On Dec 21, 7:02 am, pk peter.kirch...@youngdesigners.de wrote: hi, how can i realise this? thanks peter
[web2py] Re: parse_get_post_vars change
I apologize I missed this line. I am sorry this is not possible. If a variable appears twice, the correct thing to to is to have a list in request.vars. If we were to elminate duplicates we could no longer detect the case when duplicates are intentional. Probably in your case the duplicate is due to the fact that the same value is in both request.get_vars and in request.post_vars and you want to choose one or the other. This was indeed a change of behavior in web2py and the previous behavior was considered a bug because it caused loss of information. Anyway, thanks for bringing it up. Massimo On Dec 17, 11:34 am, NuclearDragon nucleardragon...@gmail.com wrote: So, I am in the process of upgrading Web2py from version 1.67 to 1.89.5. Ouch. One of the things I encountered is that request.vars will now include a list of duplicate values, rather than a single value (not a list) as it previously did. For example, our url includes a _next variable. So does the form when posting, including the Cancel action. So now I end up with a list of 2 duplicate values when I test set redirurl = request.vars.get('_next'). Rather than change that umpteen times in our app, I am proposing a change to the function 'parse_get_post_vars' in main.py. def parse_get_post_vars(request, environ): # always parse variables in URL for GET, POST, PUT, DELETE, etc. in get_vars dget = cgi.parse_qsl(request.env.query_string, keep_blank_values=1) for (key, value) in dget: if key in request.get_vars: if isinstance(request.get_vars[key], list): request.get_vars[key] += [value] else: request.get_vars[key] = [request.get_vars[key]] + [value] else: request.get_vars[key] = value request.vars[key] = request.get_vars[key] # parse POST variables on POST, PUT, BOTH only in post_vars request.body = copystream_progress(request) ### stores request body if (request.body and request.env.request_method in ('POST', 'PUT', 'BOTH')): dpost = cgi.FieldStorage(fp=request.body,environ=environ,keep_blank_values=1) # The same detection used by FieldStorage to detect multipart POSTs is_multipart = dpost.type[:10] == 'multipart/' request.body.seek(0) isle25 = sys.version_info[1] = 5 def listify(a): return (not isinstance(a,list) and [a]) or a try: keys = sorted(dpost) except TypeError: keys = [] for key in keys: dpk = dpost[key] # if en element is not a file replace it with its value else leave it alone if isinstance(dpk, list): if not dpk[0].filename: value = [x.value for x in dpk] else: value = [x for x in dpk] elif not dpk.filename: value = dpk.value else: value = dpk pvalue = listify(value) if key in request.vars: gvalue = listify(request.vars[key]) if isle25: value = pvalue + gvalue elif is_multipart: pvalue = pvalue[len(gvalue):] else: pvalue = pvalue[:-len(gvalue)] request.vars[key] = value if len(pvalue): request.post_vars[key] = (len(pvalue)1 and pvalue) or pvalue[0] ### Begin added code for k,v in request.vars.iteritems(): if isinstance(v, list) and len(v)==2: request.vars[k] = v[0] if v[0] == v[1] else v ### End added code Thoughts? Comments? Any reason I shouldn't make this change?
[web2py] Re: Requires login decorator error
By default it should be auth.settings.on_failed_authentication = lambda x: redirect(x) auth.settings.on_failed_authentication can be a function or a url. You must set it to None somewhere. On Dec 16, 8:02 pm, NuclearDragon nucleardragon...@gmail.com wrote: I was getting an error when attempting to go to a page that requires you be logged in, if I was not logged in. Traceback: Traceback (most recent call last): File /xxx/app/gluon/restricted.py, line 188, in restricted exec ccode in environment File /xxx/app/applications/init/controllers/x.py, line 2712, in module File /xxx/app/gluon/globals.py, line 96, in lambda self._caller = lambda f: f() File /xxx/app/gluon/tools.py, line 2271, in f '?_next='+urllib.quote(next) File /xxx/app/gluon/tools.py, line 65, in call_or_redirect redirect(f) File /xxx/app/gluon/http.py, line 101, in redirect location = location.replace('\r', '%0D').replace('\n', '%0A') AttributeError: 'NoneType' object has no attribute 'replace' So I changed: return call_or_redirect(self.settings.on_failed_authentication, self.settings.login_url + \ '? _next='+urllib.quote(next) ) to: if self.settings.on_failed_authentication: return call_or_redirect(self.settings.on_failed_authentication, self.settings.login_url + \ '? _next='+urllib.quote(next) ) else: return call_or_redirect(self.settings.login_url + \ '? _next='+urllib.quote(next) ) Does anyone have any thoughts as to why that was happening? A print statement of self.settings.on_failed_authentication at that point displays None, which affects the workings of the call_or_redirect function.
[web2py] Re: web2py 1.90.6 is OUT
@#$% On Dec 21, 11:21 am, Bruno Rocha rochacbr...@gmail.com wrote: I just pulled trunk and got this error: rochacbr...@macubuntu:~$ python projects/web2py/web2py.py -a 1234 Traceback (most recent call last): File /home/rochacbruno/projects/web2py/gluon/sql.py, line 5, in module from dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, drivers, BaseAdapter, SQLField, SQLTable, SQLXorable, SQLQuery, SQLSet, SQLRows, SQLStorage, SQLDB, GQLDB, SQLALL, SQLCustomType File /home/rochacbruno/projects/web2py/gluon/dal.py, line 1 !/bin/env python ^ SyntaxError: invalid syntax -- Bruno Rochahttp://about.me/rochacbruno/bio
Re: [web2py] Re: web2py 1.90.6 is OUT
it is just a missing # in dal.py. 2010/12/21 mdipierro mdipie...@cs.depaul.edu @#$% On Dec 21, 11:21 am, Bruno Rocha rochacbr...@gmail.com wrote: I just pulled trunk and got this error: rochacbr...@macubuntu:~$ python projects/web2py/web2py.py -a 1234 Traceback (most recent call last): File /home/rochacbruno/projects/web2py/gluon/sql.py, line 5, in module from dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, drivers, BaseAdapter, SQLField, SQLTable, SQLXorable, SQLQuery, SQLSet, SQLRows, SQLStorage, SQLDB, GQLDB, SQLALL, SQLCustomType File /home/rochacbruno/projects/web2py/gluon/dal.py, line 1 !/bin/env python ^ SyntaxError: invalid syntax -- Bruno Rochahttp://about.me/rochacbruno/bio -- Bruno Rocha http://about.me/rochacbruno/bio
Re: [web2py] Re: web2py 1.90.6 is OUT
It was a test. You were supposed to select the correct character from @#$%. You passed. :-) On Tuesday, December 21, 2010 12:59:12 PM UTC-5, Bruno Rocha wrote: it is just a missing # in dal.py. 2010/12/21 mdipierro mdip...@cs.depaul.edu @#$% On Dec 21, 11:21 am, Bruno Rocha rocha...@gmail.com wrote: I just pulled trunk and got this error: rochacbr...@macubuntu:~$ python projects/web2py/web2py.py -a 1234 Traceback (most recent call last): File /home/rochacbruno/projects/web2py/gluon/sql.py, line 5, in module from dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, drivers, BaseAdapter, SQLField, SQLTable, SQLXorable, SQLQuery, SQLSet, SQLRows, SQLStorage, SQLDB, GQLDB, SQLALL, SQLCustomType File /home/rochacbruno/projects/web2py/gluon/dal.py, line 1 !/bin/env python ^ SyntaxError: invalid syntax -- Bruno Rochahttp://about.me/rochacbruno/bio -- Bruno Rocha http://about.me/rochacbruno/bio
[web2py] Re: Left Join with aliased table and the new DAL
I think this is now fixed in trunk. Can you give it a try? Massimo On Dec 21, 9:25 am, HaM yarib...@gmail.com wrote: Hi everyone, I currently use Web2py for an internal corporation application. I recently upgraded from 1.89 to 1.90-6. Since this upgrade all my left joins with aliased table don't work any more. I'm using Web2py with Postgres. For example I have this in a controller exposed function: Domain = dbPsnol.domain Client = dbPsnol.client Manager = dbPsnol.contact.with_alias('manager') infos = dbPsnol(Domain.id==request.args[0]).select( Domain.ALL, Client.ALL,Manager.ALL, left=[ Client.on(Client.id==Domain.client_id), Manager.on(Manager.id==Client.manager_id)]) This example generate the following error: ProgrammingError: invalid reference to FROM-clause entry for table domain LINE 1: ... domain, contact LEFT JOIN client ON (client.id = domain.cli... ^ HINT: There is an entry for table domain, but it cannot be referenced from this part of the query. And as soon as I redefine Manager like this: Manager = dbPsnol.contact I don't get the error any more. But the result is not what I want. Is this a bug in the new DAL or is there an other way to do what I want ?
Re: [web2py] Re: web2py 1.90.6 is OUT
2010/12/21 Anthony abasta...@gmail.com It was a test. You were supposed to select the correct character from @#$%. You passed. :-) I almost picked the wrong character, it was pure luck! :o) LOL Guess this was a test strategy to see who is really testing trunk, a presence ping! :P -- Bruno Rocha http://about.me/rochacbruno/bio
[web2py] Using existing database
I'm trying to convince the company I work for to use Web2Py. However, we already have a database with the data we have to use for our web app (from a previous one). So the question is this: is it possible to incorporate an already existing database (tables and all the data) as a model in a new web app with Web2Py?
[web2py] Re: Upload files with accepting only (png, gif, jpg)
Use IS_IMAGE(extensions=('jpeg', 'png', 'gif')) to limit to these file formats ttp://web2py.com/book/default/chapter/07?search=IS_IMAGE On Dec 21, 10:17 pm, Luther Goh Lu Feng elf...@yahoo.com wrote: Try db,define_table('image;, Field('image, 'upload', notnull=True, requires=[IS_IAMGE()]), ) On Dec 21, 9:02 pm, pk peter.kirch...@youngdesigners.de wrote: hi, how can i realise this? thanks peter
[web2py] Re: Using existing database
If each table has a unique auto-increment id field (even if not called id) and if this is the only only field used to build references things are easy. If they use other primary keys, things will be more complex and the easiest solution would be to migrate the database and give every field a unique auto-increment id field. Massimo On Dec 21, 11:57 am, Rock rocco.ro...@gmail.com wrote: I'm trying to convince the company I work for to use Web2Py. However, we already have a database with the data we have to use for our web app (from a previous one). So the question is this: is it possible to incorporate an already existing database (tables and all the data) as a model in a new web app with Web2Py?
[web2py] Re: parse_get_post_vars change
Thanks for the reply Massimo. Now that I know it was intentional, I will see what I can do about implementing the changed behavior in our app. --Brad On Dec 21, 12:35 pm, mdipierro mdipie...@cs.depaul.edu wrote: I apologize I missed this line. I am sorry this is not possible. If a variable appears twice, the correct thing to to is to have a list in request.vars. If we were to elminate duplicates we could no longer detect the case when duplicates are intentional. Probably in your case the duplicate is due to the fact that the same value is in both request.get_vars and in request.post_vars and you want to choose one or the other. This was indeed a change of behavior in web2py and the previous behavior was considered a bug because it caused loss of information. Anyway, thanks for bringing it up. Massimo On Dec 17, 11:34 am, NuclearDragon nucleardragon...@gmail.com wrote: So, I am in the process of upgrading Web2py from version 1.67 to 1.89.5. Ouch. One of the things I encountered is that request.vars will now include a list of duplicate values, rather than a single value (not a list) as it previously did. For example, our url includes a _next variable. So does the form when posting, including the Cancel action. So now I end up with a list of 2 duplicate values when I test set redirurl = request.vars.get('_next'). Rather than change that umpteen times in our app, I am proposing a change to the function 'parse_get_post_vars' in main.py. def parse_get_post_vars(request, environ): # always parse variables in URL for GET, POST, PUT, DELETE, etc. in get_vars dget = cgi.parse_qsl(request.env.query_string, keep_blank_values=1) for (key, value) in dget: if key in request.get_vars: if isinstance(request.get_vars[key], list): request.get_vars[key] += [value] else: request.get_vars[key] = [request.get_vars[key]] + [value] else: request.get_vars[key] = value request.vars[key] = request.get_vars[key] # parse POST variables on POST, PUT, BOTH only in post_vars request.body = copystream_progress(request) ### stores request body if (request.body and request.env.request_method in ('POST', 'PUT', 'BOTH')): dpost = cgi.FieldStorage(fp=request.body,environ=environ,keep_blank_values=1) # The same detection used by FieldStorage to detect multipart POSTs is_multipart = dpost.type[:10] == 'multipart/' request.body.seek(0) isle25 = sys.version_info[1] = 5 def listify(a): return (not isinstance(a,list) and [a]) or a try: keys = sorted(dpost) except TypeError: keys = [] for key in keys: dpk = dpost[key] # if en element is not a file replace it with its value else leave it alone if isinstance(dpk, list): if not dpk[0].filename: value = [x.value for x in dpk] else: value = [x for x in dpk] elif not dpk.filename: value = dpk.value else: value = dpk pvalue = listify(value) if key in request.vars: gvalue = listify(request.vars[key]) if isle25: value = pvalue + gvalue elif is_multipart: pvalue = pvalue[len(gvalue):] else: pvalue = pvalue[:-len(gvalue)] request.vars[key] = value if len(pvalue): request.post_vars[key] = (len(pvalue)1 and pvalue) or pvalue[0] ### Begin added code for k,v in request.vars.iteritems(): if isinstance(v, list) and len(v)==2: request.vars[k] = v[0] if v[0] == v[1] else v ### End added code Thoughts? Comments? Any reason I shouldn't make this change?
[web2py] Re: How to do this in web2py..?
I think you ideally need an object database system. I don't have experience with that, but I understand Zope might be of interest. Take a look at this: http://en.wikipedia.org/wiki/List_of_object_database_management_systems -D On Dec 21, 4:47 am, Fabiano fabianoeng...@gmail.com wrote: Hi Villas, yes, I know this concept, I have a good background in computer science, but it doesn't fit here, as my data is not hierarchical. Anyway, thanks for the suggestion and the links, that Troels articles seems to be interesting, I will take a look on that sometime. My first e-mail was very extensive and I guess not very clear. I am sorry, I am still learning English. I will try to explain better what I am trying to do here. When you are modeling databases, you usually think of tables as some sort of classes of stuff and the records are the instances. For example, a table Car is a class of objects, the columns are its properties, like color, engine, year, model, etc. Each record on this table would represent a real car, with a specific a color, a specific year, model, etc. You think of the car properties that are relevant for your problem to select the columns you need when your are designing the tables. If instead of an inventory of objects you need a list of employees, or customer, or whatever hole that are people, you may think in properties like name, birth date, gender, etc. The thing is, usually the classes of things that you can store instances on your database are limited, you usually have one table for each class of stuff you can store and the properties of these stuff are pre-defined at design/data modeling time. In normal use, you just store new records filling the already pre-defined set of properties (columns). What I need to do is to store many different types of stuff on the same table, not limited to classes of stuff I can foresee in design phase. The properties of each record will be dynamic. This way, I may store a car class on my db and then say that the properties for this class are color, engine, model, year, etc. But on my case, I will only deal with properties which values can be finite sets (so, color is ok, year is out). You can also think of car properties as car options (when you buy a car, you have the option to choose its color) or as variations (two cars may be similar and vary only in color). These properties, or variations, or options are what my table Option was about on my first e-mail. Color is an option. OptionValue table stores possible values for each option. Like, for color, you may have values like blue, gray and white. On the same db I may have a class of chairs, with option material with values wood and metal. I may have an employee class with options gender and department and its possible values, I may have pies, cakes, cars, people or whatever, just assigning some properties to each of them and possible properties values.. Each of these class may have an arbitrary number of properties, including none. In this design, instead of having a list of properties applicable for each class (stuff) I will list option *values* for each, and not options for each. This way, I may have an option color on my db with lots of color values stored. But when I am creating a class of stuff Apple, instead of assign a color property to it, I will assign only the available color options for it, red and green. So, despite having many more colors in my database, for apples I will have only these two, red and green. red and green values refers to the same option, which is color, so I can derive the options for each class from the list of available option values. If I had values blue, green, yellow, small, big for a class, I would derive that the options for this class are color and size for example. I think the database design is sound for what I need. My main doubts now are more like how to use this database under web2py and have an easy interface to the user that will input these stuff on the database. As there are a lot of relations, I don't want the user to insert values on each table independently and then link them later. When he is editing a class of stuff, I want a form that shows all options and options values for that class and a new option button which would pop up a list of option values (arranged by option names) that are not already assigned to the class, and also a text input that permits the user insert a new option and option value that is not already on the database. I think that an interface that puts all this simply and transparently together is the most complex part. For example, I'd like to have forms with transparent postback validation as I have with SQLFORM, but I'd have data from 4 or 5 tables together on the same screen looking like it is just one thing to the user. Thanks for your time and inputs. Kind regards, Fabiano. On 20 dez, 21:26, villas villa...@gmail.com wrote: Hi
[web2py] Re: Requires login decorator error
I saw where the default was being set, but couldn't find anywhere that we were overriding that value. I will tour through it again and see if I can pick it out this time. Thanks, Brad On Dec 21, 12:37 pm, mdipierro mdipie...@cs.depaul.edu wrote: By default it should be auth.settings.on_failed_authentication = lambda x: redirect(x) auth.settings.on_failed_authentication can be a function or a url. You must set it to None somewhere. On Dec 16, 8:02 pm, NuclearDragon nucleardragon...@gmail.com wrote: I was getting an error when attempting to go to a page that requires you be logged in, if I was not logged in. Traceback: Traceback (most recent call last): File /xxx/app/gluon/restricted.py, line 188, in restricted exec ccode in environment File /xxx/app/applications/init/controllers/x.py, line 2712, in module File /xxx/app/gluon/globals.py, line 96, in lambda self._caller = lambda f: f() File /xxx/app/gluon/tools.py, line 2271, in f '?_next='+urllib.quote(next) File /xxx/app/gluon/tools.py, line 65, in call_or_redirect redirect(f) File /xxx/app/gluon/http.py, line 101, in redirect location = location.replace('\r', '%0D').replace('\n', '%0A') AttributeError: 'NoneType' object has no attribute 'replace' So I changed: return call_or_redirect(self.settings.on_failed_authentication, self.settings.login_url + \ '? _next='+urllib.quote(next) ) to: if self.settings.on_failed_authentication: return call_or_redirect(self.settings.on_failed_authentication, self.settings.login_url + \ '? _next='+urllib.quote(next) ) else: return call_or_redirect(self.settings.login_url + \ '? _next='+urllib.quote(next) ) Does anyone have any thoughts as to why that was happening? A print statement of self.settings.on_failed_authentication at that point displays None, which affects the workings of the call_or_redirect function.
[web2py] Re: Run Web2py as a Service? on Ubuntu Lucid?
Hi, Mine seemed to work fine right off the bat with Lucid using the installation scripts that are included in web2py/scripts. I am doing some automated installation testing so I will let you know if I run into any issues and how I fixed them. In the mean time I am wondering why Web2py is in usr/lib/web2py/ web2py.py on your setup. Unlike many applications, web2py.py in particular, probably does not belong in that location (although I know someone was talking about building a Debian package for web2py at some point in time...). A more standard web2py setup can be obtained be unpacking the Web2py source in /home/www-data. This is what should happen when the included Ubuntu installer script is used. If the included Ubuntu installer script is used then the included services script should work as well. Cheers, Chris On Dec 20, 4:50 pm, ghoulmann rikgold...@gmail.com wrote: Web2py isn't running as a service for me. I relied on the instructions here:http://web2py.com/book/default/chapter/11#Start-as-Linux-Daemon . The file, /etc/init.d/web2py is owned by root and executable. Python is at /bin/python, and web2py is at /usr/lib/web2py/web2py.py . No pid file is being created in the specified directory. Below, several posts ago, I posted a pastebin of the web2py file in init.d. I'm working in the service of Sahana Eden, and don't want to scrap this build, which is dependent on web2py. However, it can't be completed if web2py won't run as a service at startup. I've used the feedback I received, but the problem isn't solved. Please, if you have suggestions, I'd love to hear them. On Dec 19, 1:00 pm, ghoulmann rikgold...@gmail.com wrote: SO what to do then? It appears no web2py.pid file is being created. On Dec 18, 3:27 pm, ghoulmann rikgold...@gmail.com wrote: Thanks Kenneth. When I look in the specified dir I see that no web2py existed. I thought maybe you meant changing the value $PIDDIR, so I tried that. I changed it to /root/$name and I ended up with the same result. It created /root/web2py, but the directory is empty. On Dec 18, 2:18 pm, Kenneth Lundström kenneth.t.lundst...@gmail.com wrote: Try to move the web2py.pid file and try again. Kenneth Thanks for the tip! Removed --quiet from the two lines. The service still doesn't appear to start on startup (after reboot). When I manually start with /etc/init.d/web2py (root user) I get this: No process in pidfile '/var/run/web2py/web2py.pid' found running; none killed. And the service doesn't seem to work. What can be a wise next step? On Dec 18, 10:33 am, jeffjef...@gmail.com wrote: When I had this kind of problem, I removed the --quiet and -- background in the /etc/init.d/web2py file (line 65 and 67 of your 3rd file). I was then able to get some error messages when doing /etc/init.d/ web2py start In my case, it helped me to find a stupid error I did. Good luck. On Dec 18, 5:59 am, ghoulmannrikgold...@gmail.com wrote: Thanks so much for the reply. I did try both; retried them when I saw your response. Both commands start web2py.py listening on :8000. SO, it does work in these cases. Is there something I can try next? On Dec 17, 6:34 pm, mdipierromdipie...@cs.depaul.edu wrote: did you try start it simply with python web2py.py -a password or nohup python web2py.py -a password Does it work fine in these cases? On Dec 17, 4:59 pm, ghoulmannrikgold...@gmail.com wrote: I'm thankful this community is here. I'm working on a project for the Sahana-Eden team [1]. It calls for running web2py as a service. I was thankful to find documentation in the 3rd edition Official Web2py Book [2]. Sadly, when I follow the docs I can't get the service running. / etc/init.d/web2py start returns no errors; restart returns no errors, and status returns nothing. Netstat tells me the interface isn't listening on port 8000. I did use the scripts/web2py.ubuntu.sh script, and did as instructed in the documentation. I made changes to some of the paramaters near the top of the script; I've made it available as a pastebin [3]. I've double-checked the daemon directory, and believe it to be correct. I have created web2py user with no password (using useradd); as web2py is new to me, I'm not sure that's necessary, but it has been done. Web2py has precisely the same mode as a working service (webmin in this case) and is owned root:root. Mode is rwxr-xr-x. I would be very grateful for any guidance, suggestions, improvements, encouragement you can offer. Ultimately, it's the high school students that have committed to the project that will benefit - I'm in unfamiliar territory and learning along with them. Rik
[web2py] Possible typo in book
In web2py book, chapter 7 Forms and Validators, IS_IN_SET section, second paragraph, should this line: If you do not want a choose one option, set zero=False be: If you do not want a choose one option, set zero=None Jim Karsten
Re: [web2py] Re: Formatted data entries
On 21 December 2010 18:08, mdipierro mdipie...@cs.depaul.edu wrote: I think you just need: db.mytable.myfield.represent=lambda x: XML(x,sanitize=True) Thanks. I will try it. Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
[web2py] Re: Possible typo in book
On Dec 21, 9:10 pm, Jim Karsten iiijjj...@gmail.com wrote: In web2py book, chapter 7 Forms and Validators, IS_IN_SET section, second paragraph, should this line: If you do not want a choose one option, set zero=False be: If you do not want a choose one option, set zero=None Can you confirm that the first is broken, and the second one works? I am not going to check myself, I'll trust your results, I just want to be sure that you've tested it before I change the book.
Re: [web2py] Re: Possible typo in book
On Dec 21, 2010, at 12:26 PM, cjrh wrote: On Dec 21, 9:10 pm, Jim Karsten iiijjj...@gmail.com wrote: In web2py book, chapter 7 Forms and Validators, IS_IN_SET section, second paragraph, should this line: If you do not want a choose one option, set zero=False be: If you do not want a choose one option, set zero=None Can you confirm that the first is broken, and the second one works? I am not going to check myself, I'll trust your results, I just want to be sure that you've tested it before I change the book. Per the code, it should be None. Same for IS_IN_DB.
[web2py] When to use lambda?
I see lambda used quite a bit and don't totally understand the concept. Is there a simple rule to follow to know when it is necessary to use?
Re: [web2py] Re: it case you missed it...
+1 2010/12/21 mdipierro mdipie...@cs.depaul.edu: Because I do not want closed source commercial derivatives. I am against people stealing other people work.
[web2py] Re: When to use lambda?
lambda is functional programming bit. :-) Well, you can use lambda to 1) define anonymous functions 2) one liner functions 3) to modify a function to behave the way you want (instead of defining another function that just call this function with desired params) etc, to name just few, that came into mind. Well, I strongly advice you to read *dive into python*
[web2py] Re: Possible typo in book
On Dec 21, 10:34 pm, Jonathan Lundell jlund...@pobox.com wrote: Per the code, it should be None. Same for IS_IN_DB. Fixed, thanks for checking.
[web2py] Re: When to use lambda?
pbreit wrote: I see lambda used quite a bit and don't totally understand the concept. Is there a simple rule to follow to know when it is necessary to use? Sometimes you need to pass a function as an argument to another function. In that case you have a choice to 1. define a separate function, and pass that to the function you are calling: def my_fun(x, y, operation): return operation(x, y) The function my_fun takes two numbers x and y, and one function operation that is applied to x and y You can e.g. use it as follows to perform an addition: def my_addition(x, y): return x+y print my_fun(1, 2, my_addition) 3 2. you can omit defining the separate function my_addition and pass in an anonymous function (defined using lambda) instead: def my_fun(x, y, operation): return operation(x,y) print my_fun(1,2, lambda x,y : x+y) 3 So lambda is used to define a function on-the-spot, without even bothering to give it a name of its own (an anonymous function). The lambda x,y part tells the system that you define an anonymous function expecting two arguments named x and y. The x+y part tells the system that the anonymous function returns the sum of its x and y arguments. Hope this helps, Best regards, Stefaan.
[web2py] Re: When to use lambda?
And if you're interested, the name lambda itself comes from lambda calculus: http://en.wikipedia.org/wiki/Lambda_calculus http://en.wikipedia.org/wiki/Lambda_calculus#First-class_functions http://en.wikipedia.org/wiki/Anonymous_functions On Tuesday, December 21, 2010 4:02:36 PM UTC-5, stefaan wrote: pbreit wrote: I see lambda used quite a bit and don't totally understand the concept. Is there a simple rule to follow to know when it is necessary to use? Sometimes you need to pass a function as an argument to another function. In that case you have a choice to 1. define a separate function, and pass that to the function you are calling: def my_fun(x, y, operation): return operation(x, y) The function my_fun takes two numbers x and y, and one function operation that is applied to x and y You can e.g. use it as follows to perform an addition: def my_addition(x, y): return x+y print my_fun(1, 2, my_addition) 3 2. you can omit defining the separate function my_addition and pass in an anonymous function (defined using lambda) instead: def my_fun(x, y, operation): return operation(x,y) print my_fun(1,2, lambda x,y : x+y) 3 So lambda is used to define a function on-the-spot, without even bothering to give it a name of its own (an anonymous function). The lambda x,y part tells the system that you define an anonymous function expecting two arguments named x and y. The x+y part tells the system that the anonymous function returns the sum of its x and y arguments. Hope this helps, Best regards, Stefaan.
[web2py] Re: When to use lambda?
On Dec 21, 10:36 pm, pbreit pbreitenb...@gmail.com wrote: I see lambda used quite a bit and don't totally understand the concept. Is there a simple rule to follow to know when it is necessary to use? Code A: f = lambda x,y: x + y Code B: def f(x,y): return x + y If you can remember that Code A is *exactly* equivalent to Code B, you will have no problem with lambda. The differences between using def to create a function, or lambda to create a function are the following: 1) lambda is useful when creating inline functions for which no name is necessary. A very commonly-cited example is as a comparison function for the sort method: my_list.sort(cmp=lambda a,b: a.age b.age) This feels more immediate and explicit than this: def compare_age(a,b): return a.age b.age my_list.sort(cmp=compare_age 2) lambda is limited to a single expression. If you need the function to contain multiple statements and expressions, you have to use the def version. 3) Using def means having to come up with a name, which implies the possibility of adding some small documentation hint for what the function is supposed to do. Lambda provides no such hint; however, in the scenarios in which lambda is most frequently used, the meaning and purpose of the lambda function is immediately obvious, as in the sort example above. So perhaps a guideline might be to prefer def when the purpose of the lambda function might not be immediately obvious from the usage, and the name given to a def function would be useful. 4) Python's scoping rules can catch out novice programmers very easily with lambdas. The typical example is a list comprehension in which a list of functions is built: my_list_of_functions = [lambda x : x + i for i in range(10)] You think you're getting a list of 10 functions that will each add a different amount (i.e. whatever i was at the time of each lambda function declaration) to the function's input, x, but in reality, all functions will be identical, because the lambda captures the location of the variable i, NOT its contents. The exact same thing would happen with def, except that def can't be used inline in this way. With def, the code would be written so: my_list_of_functions=[] for i in range(10): def f(x): return x + i my_list_of_functions.append(f) The exact same problem occurs as with lambda, but now of course it is obvious that the location of i will be enclosed in the functions, and therefore the desired effect will not be achieved. * * * FWIW always use functions to make closures, then the scoping is always right: def g(i): def f(x): return x + i return f my_list_of_functions = [g(i) for i in range(10)] I wrote up a fair bit on def and lambda in the web2py book, focusing specifically on these kinds of scoping issues, and I wouldn't mind feedback about anything that is unclear: http://web2py.com/book/default/chapter/02#def...return
[web2py] Syntax to INNER JOIN table to itself
I have a legacy table with a three-character primary key and a three- character self-referencing field. I'm trying to implement the following sql using the DAL: SELECT District.Description, SchoolDistrict.Description FROM District.DistrictID INNER JOIN District AS SchoolDistrict ON District.SchoolDistrictID = SchoolDistrict.DistrictID I thought I could use with_alias to do this but it does not seem to be working. Thanks, Mike
[web2py] Re: Left Join with aliased table and the new DAL
I just tried with the last revision (1414:da25156addab) and the problem stills the same.
Re: [web2py] When to use lambda?
On Tue, Dec 21, 2010 at 9:36 PM, pbreit pbreitenb...@gmail.com wrote: I see lambda used quite a bit and don't totally understand the concept. Is there a simple rule to follow to know when it is necessary to use? You can get away with NEVER using lambda. But it's cool to know it. Lambda is basically a function that acts as an object. So, for example, you can say this: def myfunction(a): a('this')! myfunction(lambda x: print 'Eat %s!' % x) and that would print 'Eat this!'. There's nothing to it, really. Just knowing this, you'll know when you need to use it. It's one of 3 features I love about Python. http://docs.python.org/reference/expressions.html#lambda -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/
[web2py] Re: When to use lambda?
On Dec 21, 11:37 pm, cjrh caleb.hatti...@gmail.com wrote: def g(i): def f(x): return x + i return f my_list_of_functions = [g(i) for i in range(10)] I suspect the following won't be of immediate use to you, but it is worth hearing about right now, even if it'll only make sense sometime later in the future. This also works: my_list_of_functions = [lambda x, j=i : x + j for i in range(10)] However, you can see how the version using def, above, is much clearer than this new version using lambda. You need really sharp eyes to catch the scoping trick: the j belongs to the inner scope of the lambda, while the i belongs to the outer scope of the list comprehension. The contents are copied from i to j at the time of each lambda declaration, which is why it works. In a large body of code, these kinds of micro-tricks make it hard to read code. Because Python's scoping rules are strict and clean, we can even do the following: my_list_of_functions = [lambda x, i=i : x + j for i in range(10)] Now, again in a large body of code, this kind of thing can make it very tricky to read code quickly. You need especially sharp eyes to spot that there are two is here: one belongs to the inner scope of the lambda function, and one belongs to the outer scope in the list comprehension (and again, the contents of the outer i are copied over to the inner i at the moment each lambda function is created). This is why, except for the simple common cases, def is often better, simply for the sake of readability.
Re: [web2py] Re: When to use lambda?
On Dec 21, 2010, at 1:37 PM, cjrh wrote: On Dec 21, 10:36 pm, pbreit pbreitenb...@gmail.com wrote: I see lambda used quite a bit and don't totally understand the concept. Is there a simple rule to follow to know when it is necessary to use? Another answer to the original question is that there are places in the web2py API where a function is called for. For example, when you define a Field, you can supply a represent=something argument to override the default representation. The something needs to be a function, and a lambda expression is often a handy way to provide one.
[web2py] Re: Left Join with aliased table and the new DAL
hmm... I am trying your select and it now generates the same sql as the old dal. please try this: Domain = db.domain Client = db.client Manager = db.contact.with_alias('manager') sql = db(Domain.id==1)._select( Domain.ALL, Client.ALL,Manager.ALL, left=[Client.on(Client.id==Domain.client_id), Manager.on(Manager.id==Client.manager_id)]) print sql what do you get? I get SELECT domain.id, domain.name, domain.client_id, client.id, client.name, client.manager_id, manager.id, manager.name FROM domain LEFT JOIN client ON (client.id = domain.client_id) LEFT JOIN contact AS manager ON (manager.id = client.manager_id) WHERE (domain.id = 1); On Dec 21, 2:55 pm, HaM yarib...@gmail.com wrote: I just tried with the last revision (1414:da25156addab) and the problem stills the same.
Re: [web2py] Re: it case you missed it...
+1
[web2py] Re: Syntax to INNER JOIN table to itself
there is a bug in 1.90.6 about with_alias. I think it is fixed in trunk. give it a try. On Dec 21, 3:46 pm, mwolfe02 michael.joseph.wo...@gmail.com wrote: I have a legacy table with a three-character primary key and a three- character self-referencing field. I'm trying to implement the following sql using the DAL: SELECT District.Description, SchoolDistrict.Description FROM District.DistrictID INNER JOIN District AS SchoolDistrict ON District.SchoolDistrictID = SchoolDistrict.DistrictID I thought I could use with_alias to do this but it does not seem to be working. Thanks, Mike
[web2py] Re: When to use lambda?
On Dec 21, 11:53 pm, cjrh caleb.hatti...@gmail.com wrote: Because Python's scoping rules are strict and clean, we can even do the following: my_list_of_functions = [lambda x, i=i : x + j for i in range(10)] To my shame, this should have been: my_list_of_functions = [lambda x, i=i : x + i for i in range(10)] Apologies for any confusion. It is confusing enough already without my typos adding to the pain!
[web2py] Re: it case you missed it...
Looks like we have enough consensus. The people who so far opposed to a license change seem to be in favor of this change. As soon as I can fix the open issues I will change the license for 1.91.1 to LPGL3 and, after that do, I do not want to hear anything any more about the license. Perhaps I should add a new exception: you loose the license to use web2py if you complain about web2py or its license. ;-) Massimo
Re: [web2py] Re: Syntax to INNER JOIN table to itself
I'm actually running off of trunk already (latest changeset is 1410 (feb4ddb2d659), committed 14 hours ago). The book example only demonstrates using with_alias in LEFT JOINs. Is this a limitation? If it makes any difference, I am running dal.py as a standalone module for a non-web2py project. (Speaking of using it as a standalone module, I almost wet myself when I saw how easy it was to use it that way. Nice work on the re-write.) Thanks, Mike On Tue, Dec 21, 2010 at 5:00 PM, mdipierro mdipie...@cs.depaul.edu wrote: there is a bug in 1.90.6 about with_alias. I think it is fixed in trunk. give it a try. On Dec 21, 3:46 pm, mwolfe02 michael.joseph.wo...@gmail.com wrote: I have a legacy table with a three-character primary key and a three- character self-referencing field. I'm trying to implement the following sql using the DAL: SELECT District.Description, SchoolDistrict.Description FROM District.DistrictID INNER JOIN District AS SchoolDistrict ON District.SchoolDistrictID = SchoolDistrict.DistrictID I thought I could use with_alias to do this but it does not seem to be working. Thanks, Mike
Re: [web2py] Re: it case you missed it...
On Tue, Dec 21, 2010 at 11:08 PM, mdipierro mdipie...@cs.depaul.edu wrote: Perhaps I should add a new exception: you loose the license to use web2py if you complain about web2py or its license. ;-) for 1000 years or life, whichever comes last ;) -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/
[web2py] Re: Syntax to INNER JOIN table to itself
yes alias only works with left joins. But you can mimic one with the other to I tried this which I think is equivalent to your query: db=DAL() District = db.define_table('district',Field('description'),Field('district_id','reference district')) SchoolDistrict = District.with_alias('school_district') rows= db(District.district_id! =None).select(District.description,SchoolDistrict.description,left=SchoolDistrict.on(SchoolDistrict. \ id==District.district_id)) print rows Makes this sql: SELECT district.description, school_district.description FROM district LEFT JOIN district AS school_district ON (school_district.id = district.district_id) WHERE (district.district_id IS NOT NULL); On Dec 21, 4:09 pm, Michael Wolfe michael.joseph.wo...@gmail.com wrote: I'm actually running off of trunk already (latest changeset is 1410 (feb4ddb2d659), committed 14 hours ago). The book example only demonstrates using with_alias in LEFT JOINs. Is this a limitation? If it makes any difference, I am running dal.py as a standalone module for a non-web2py project. (Speaking of using it as a standalone module, I almost wet myself when I saw how easy it was to use it that way. Nice work on the re-write.) Thanks, Mike On Tue, Dec 21, 2010 at 5:00 PM, mdipierro mdipie...@cs.depaul.edu wrote: there is a bug in 1.90.6 about with_alias. I think it is fixed in trunk. give it a try. On Dec 21, 3:46 pm, mwolfe02 michael.joseph.wo...@gmail.com wrote: I have a legacy table with a three-character primary key and a three- character self-referencing field. I'm trying to implement the following sql using the DAL: SELECT District.Description, SchoolDistrict.Description FROM District.DistrictID INNER JOIN District AS SchoolDistrict ON District.SchoolDistrictID = SchoolDistrict.DistrictID I thought I could use with_alias to do this but it does not seem to be working. Thanks, Mike
[web2py] look ma, no flash!
http://spritely.net/
Re: [web2py] look ma, no flash!
Damn, that's nice. On Tue, Dec 21, 2010 at 11:31 PM, Michele Comitini michele.comit...@gmail.com wrote: http://spritely.net/ -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/
Re: [web2py] Re: Syntax to INNER JOIN table to itself
You're right, that should work. I wonder if there would be a significant performance hit running a LEFT JOIN in place of an INNER JOIN. I'll have to keep an eye on that to see if it makes much difference, but in my particular case (less than 100 records) I think I'll be fine. Thanks for the quick response, Mike On Tue, Dec 21, 2010 at 5:22 PM, mdipierro mdipie...@cs.depaul.edu wrote: yes alias only works with left joins. But you can mimic one with the other to I tried this which I think is equivalent to your query: db=DAL() District = db.define_table('district',Field('description'),Field('district_id','reference district')) SchoolDistrict = District.with_alias('school_district') rows= db(District.district_id! =None).select(District.description,SchoolDistrict.description,left=SchoolDistrict.on(SchoolDistrict. \ id==District.district_id)) print rows Makes this sql: SELECT district.description, school_district.description FROM district LEFT JOIN district AS school_district ON (school_district.id = district.district_id) WHERE (district.district_id IS NOT NULL); On Dec 21, 4:09 pm, Michael Wolfe michael.joseph.wo...@gmail.com wrote: I'm actually running off of trunk already (latest changeset is 1410 (feb4ddb2d659), committed 14 hours ago). The book example only demonstrates using with_alias in LEFT JOINs. Is this a limitation? If it makes any difference, I am running dal.py as a standalone module for a non-web2py project. (Speaking of using it as a standalone module, I almost wet myself when I saw how easy it was to use it that way. Nice work on the re-write.) Thanks, Mike On Tue, Dec 21, 2010 at 5:00 PM, mdipierro mdipie...@cs.depaul.edu wrote: there is a bug in 1.90.6 about with_alias. I think it is fixed in trunk. give it a try. On Dec 21, 3:46 pm, mwolfe02 michael.joseph.wo...@gmail.com wrote: I have a legacy table with a three-character primary key and a three- character self-referencing field. I'm trying to implement the following sql using the DAL: SELECT District.Description, SchoolDistrict.Description FROM District.DistrictID INNER JOIN District AS SchoolDistrict ON District.SchoolDistrictID = SchoolDistrict.DistrictID I thought I could use with_alias to do this but it does not seem to be working. Thanks, Mike
Re: [web2py] look ma, no flash!
Branko, did you try to click on those fat black birds and then click somewhere else on the window? 2010/12/21 Branko Vukelić stu...@brankovukelic.com: Damn, that's nice. On Tue, Dec 21, 2010 at 11:31 PM, Michele Comitini michele.comit...@gmail.com wrote: http://spritely.net/ -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/
Re: [web2py] look ma, no flash!
Yup. It's great. I've looked at the demos, though, and they all sort of work the same way. Not very versatile if demo is all there is to it. On Tue, Dec 21, 2010 at 11:46 PM, Michele Comitini michele.comit...@gmail.com wrote: Branko, did you try to click on those fat black birds and then click somewhere else on the window? 2010/12/21 Branko Vukelić stu...@brankovukelic.com: Damn, that's nice. On Tue, Dec 21, 2010 at 11:31 PM, Michele Comitini michele.comit...@gmail.com wrote: http://spritely.net/ -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/ -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/
[web2py] Re: customizing registration layout
what about the password2 field?
[web2py] Re: When to use lambda?
myfunction(lambda x: print 'Eat %s!' % x) and that would print 'Eat this!'. Ahm... :) You can't use print in lambda as it is a statement, not an expression (in python 2.x at least)
[web2py] Cache stored at request, does not sync with other threads until new request
At least I think the subject seems to define the behavior. I have a function that exposes as an XMLRPC service. It puts something in a DB, and then polls to see if there is a response to it from another system talking to that same DB. (yes I realize that polling a DB is a bad thing but necessary for various reasons in this case) The difficulty is, there's an xmlrpc side, and an ajax side. The ajax side is a longpoll (simulated server side push) with a loop like this: while endtime datetime.datetime.now(): # This keeps finding a cached value, even when it's cleared by # another request. #for k in cache.ram.storage.keys(): #logging.debug(k,v) #if k.find(next_action.ccid= + str(ccid)) != -1: #logging.debug(str(ccid) + found cached value) actionrow = localdb(localdb.next_action.ccid == ccid).select( cache=(cache.ram,600)).first() if actionrow and len(actionrow) and actionrow.action_str != None and \ actionrow.return_str == None: return dict(action_xml=actionrow.action_str, ccid=ccid) time.sleep(.5) The XMLRPC side is much the same. ccid is a unique key for the conversation for both of them to use. The action string is where the XMLRPC side pushes information, and return_str is data that is handed back after the ajax longpoll fulfills the action string's needs. My problem in all of this is the comments above. Even though when I do an update on the XMLRPC side, I clear cache for this select statement (via setting timeout to 0 for that select statement in cache) it still maintains the value pulled from cache in the ajax request above. So I don't pull out the actual value in the DB until cache expires in this function, even though I've cleared the cache via setting timeout to 0 in the other function: localdb(localdb.next_action.ccid == ccid).select(cache=(cache.ram, 0)) Any ideas? For now, I really don't know what I'm looking at for an issue or resolution, but even a yep, makes a copy when your request object is created would work if someone knows. Or you're an idiot, do it like this would be even better!
Re: [web2py] look ma, no flash!
yes I suspect there is a lot of cutpaste... many have the running background, but some are different: http://voidstudio.eu/newdesign/ http://spritely.net/filipealcada/ http://www.naplntemisky.cz/hra/ http://www.pinkpigeon.net/ (go on those pigeons below :-) ) 2010/12/21 Branko Vukelić stu...@brankovukelic.com: Yup. It's great. I've looked at the demos, though, and they all sort of work the same way. Not very versatile if demo is all there is to it. On Tue, Dec 21, 2010 at 11:46 PM, Michele Comitini michele.comit...@gmail.com wrote: Branko, did you try to click on those fat black birds and then click somewhere else on the window? 2010/12/21 Branko Vukelić stu...@brankovukelic.com: Damn, that's nice. On Tue, Dec 21, 2010 at 11:31 PM, Michele Comitini michele.comit...@gmail.com wrote: http://spritely.net/ -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/ -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/
[web2py] Re: customizing registration layout
You have to make it manually input name=password2 On Dec 21, 4:58 pm, Plumo richar...@gmail.com wrote: what about the password2 field?
Re: [web2py] Cache stored at request, does not sync with other threads until new request
It occurs to me, I'm using uwsgi. I'm assuming cache.ram is per process, meaning that if my Ajax side and xmlrpc side are not on the same process, this will completely not work properly. I'll try flipping over to cache.disk tomorrow morning to verify. On Dec 21, 2010 5:20 PM, Dragonfyre13 dragonfyr...@gmail.com wrote: At least I think the subject seems to define the behavior. I have a function that exposes as an XMLRPC service. It puts something in a DB, and then polls to see if there is a response to it from another system talking to that same DB. (yes I realize that polling a DB is a bad thing but necessary for various reasons in this case) The difficulty is, there's an xmlrpc side, and an ajax side. The ajax side is a longpoll (simulated server side push) with a loop like this: while endtime datetime.datetime.now(): # This keeps finding a cached value, even when it's cleared by # another request. #for k in cache.ram.storage.keys(): #logging.debug(k,v) #if k.find(next_action.ccid= + str(ccid)) != -1: # logging.debug(str(ccid) + found cached value) actionrow = localdb(localdb.next_action.ccid == ccid).select( cache=(cache.ram,600)).first() if actionrow and len(actionrow) and actionrow.action_str != None and \ actionrow.return_str == None: return dict(action_xml=actionrow.action_str, ccid=ccid) time.sleep(.5) The XMLRPC side is much the same. ccid is a unique key for the conversation for both of them to use. The action string is where the XMLRPC side pushes information, and return_str is data that is handed back after the ajax longpoll fulfills the action string's needs. My problem in all of this is the comments above. Even though when I do an update on the XMLRPC side, I clear cache for this select statement (via setting timeout to 0 for that select statement in cache) it still maintains the value pulled from cache in the ajax request above. So I don't pull out the actual value in the DB until cache expires in this function, even though I've cleared the cache via setting timeout to 0 in the other function: localdb(localdb.next_action.ccid == ccid).select(cache=(cache.ram, 0)) Any ideas? For now, I really don't know what I'm looking at for an issue or resolution, but even a yep, makes a copy when your request object is created would work if someone knows. Or you're an idiot, do it like this would be even better!
[web2py] Re: look ma, no flash!
Did you see this? http://craftyjs.com/ On Dec 21, 5:27 pm, Michele Comitini michele.comit...@gmail.com wrote: yes I suspect there is a lot of cutpaste... many have the running background, but some are different: http://voidstudio.eu/newdesign/http://spritely.net/filipealcada/http://www.naplntemisky.cz/hra/http://www.pinkpigeon.net/(go on those pigeons below :-) ) 2010/12/21 Branko Vukelić stu...@brankovukelic.com: Yup. It's great. I've looked at the demos, though, and they all sort of work the same way. Not very versatile if demo is all there is to it. On Tue, Dec 21, 2010 at 11:46 PM, Michele Comitini michele.comit...@gmail.com wrote: Branko, did you try to click on those fat black birds and then click somewhere else on the window? 2010/12/21 Branko Vukelić stu...@brankovukelic.com: Damn, that's nice. On Tue, Dec 21, 2010 at 11:31 PM, Michele Comitini michele.comit...@gmail.com wrote: http://spritely.net/ -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/ -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/
Re: [web2py] Re: look ma, no flash!
I can't play elevator as much as I would like :( it crashes the chrome window 2010/12/22 mdipierro mdipie...@cs.depaul.edu: Did you see this? http://craftyjs.com/ On Dec 21, 5:27 pm, Michele Comitini michele.comit...@gmail.com wrote: yes I suspect there is a lot of cutpaste... many have the running background, but some are different: http://voidstudio.eu/newdesign/http://spritely.net/filipealcada/http://www.naplntemisky.cz/hra/http://www.pinkpigeon.net/(go on those pigeons below :-) ) 2010/12/21 Branko Vukelić stu...@brankovukelic.com: Yup. It's great. I've looked at the demos, though, and they all sort of work the same way. Not very versatile if demo is all there is to it. On Tue, Dec 21, 2010 at 11:46 PM, Michele Comitini michele.comit...@gmail.com wrote: Branko, did you try to click on those fat black birds and then click somewhere else on the window? 2010/12/21 Branko Vukelić stu...@brankovukelic.com: Damn, that's nice. On Tue, Dec 21, 2010 at 11:31 PM, Michele Comitini michele.comit...@gmail.com wrote: http://spritely.net/ -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/ -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/
[web2py] It is done GPL2 - LGPL3
For now trunk only. This will propagate to stable since 1.91.1 Reason for the change? - Eliminate some ambiguities with the current license + exception - Allow web2py to incorporate Apache code if needed (Google releases under Apache) - Give you the ability to use web2py modules in non-web2py apps (the new dal for example) - Expand the user base What does it mean for you again? - If you simply use web2py to develop web2py apps nothing changes. The LGPLv3 just makes more clear than the GPL+exception that the web2py license does not extend to your app but only to the web2py libraries, even if you import web2py libraries in your app. You can release your apps open or closed source under any license you like, with or without official web2py code, whether source or binary. - If you want to use web2py modules into non-web2py apps - for example use dal.py or template.py with a different framework, you can now do so without worries, as long as you do not change the source of the web2py modules. You simply need to state that your app includes web2py modules. - If you need to modify web2py code you have to release the modifications under LGPLv3 (before you had to release modifications under GPL2). What you cannot do is what you could not do before: modify web2py, include it a commercial product or closed source product and not release your changes to web2py open source. Merry Christmas
[web2py] Re: It is done GPL2 - LGPL3
LGPL3 +1 Merry Christmas +1
Re: [web2py] It is done GPL2 - LGPL3
Reason for the change? - Eliminate some ambiguities with the current license + exception - Allow web2py to incorporate Apache code if needed (Google releases under Apache) - Give you the ability to use web2py modules in non-web2py apps (the new dal for example) - Expand the user base Nice! This means that we officially have a new web based shell in admin, and I am going to try it on GAE. Thanks LGPL3 + 1 Merry Christmas + 1 -- Bruno Rocha http://about.me/rochacbruno/bio
Re: [web2py] Re: When to use lambda?
On Wed, Dec 22, 2010 at 12:13 AM, Stefaan Himpe stefaan.hi...@gmail.com wrote: myfunction(lambda x: print 'Eat %s!' % x) and that would print 'Eat this!'. Ahm... :) You can't use print in lambda as it is a statement, not an expression (in python 2.x at least) Yah, I know. I've corrected myself. But I guess it's worth repeating. :) -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/
Re: [web2py] It is done GPL2 - LGPL3
On Wed, Dec 22, 2010 at 1:30 AM, Bruno Rocha rochacbr...@gmail.com wrote: LGPL3 + 1 Merry Christmas + 1 [i + 1 for i in [LGPL3, MerryChristmas]] ;) -- Branko Vukelic stu...@brankovukelic.com http://www.brankovukelic.com/
Re: [web2py] It is done GPL2 - LGPL3
Another reason to switch from *webframework to web2py!. +1 :-) Merry Christmas +1 2010/12/21 mdipierro mdipie...@cs.depaul.edu: For now trunk only. This will propagate to stable since 1.91.1
[web2py] database query
This should be an easy one, but I can't figure it out. I am using the tagging implementation from plugin_wiki: Two tables (tag and link) store the info about tags on records in a third table (e.g. movies). db.tag has Fields id and name=str db.link has fields id, tagID=int and movieID=int Now if a user clicks on a tag in the tag-cloud, what is a good query to find all movies with that tag? Can I do that with standard queries and .select() or do I need to use executesql? movies_with_activeTag=db((db.link.tagID==id_of_activeTag)(db.movies.id==db.link.movieID)).select() was something I came up with (I have about zero experience with the query syntax) but it gives strange recursion errors: ... File c:\\web2py\gluon\dal.py, line 3456, in __allocate raise RuntimeError, Using a recursive select but encountered a broken reference RuntimeError: Using a recursive select but encountered a broken reference If I need the SQL execution, how can I convert its output to a rows object? sqlite is the database Thanks in advance any help is welcome. Regards czamb
[web2py] Re: database query
If you have joins, I would do this: movies_with_activeTag=db(db.movies.id.belongs(db(db.link.tagID==id_of_activeTag)._select(db.link.movieID,groupby=db.link.movieID,orderby=db.link.movieID))).select() On Dec 21, 7:00 pm, czamb grossep...@googlemail.com wrote: This should be an easy one, but I can't figure it out. I am using the tagging implementation from plugin_wiki: Two tables (tag and link) store the info about tags on records in a third table (e.g. movies). db.tag has Fields id and name=str db.link has fields id, tagID=int and movieID=int Now if a user clicks on a tag in the tag-cloud, what is a good query to find all movies with that tag? Can I do that with standard queries and .select() or do I need to use executesql? movies_with_activeTag=db((db.link.tagID==id_of_activeTag)(db.movies.id==db.link.movieID)).select() was something I came up with (I have about zero experience with the query syntax) but it gives strange recursion errors: ... File c:\\web2py\gluon\dal.py, line 3456, in __allocate raise RuntimeError, Using a recursive select but encountered a broken reference RuntimeError: Using a recursive select but encountered a broken reference If I need the SQL execution, how can I convert its output to a rows object? sqlite is the database Thanks in advance any help is welcome. Regards czamb
[web2py] web2py 1.91.1 is OUT (LGPLv3)
web2py 1.91.1 is out, the first version with a new license. Main changes are the license, bug fixes (compared to 1.90.*) and a new shell that runs better than before and runs on GAE too, if you choose to deploy it. Massimo
[web2py] Re: web2py 1.91.1 is OUT (LGPLv3)
You are working too fast Massimo :p On Dec 22, 9:33 am, mdipierro mdipie...@cs.depaul.edu wrote: web2py 1.91.1 is out, the first version with a new license. Main changes are the license, bug fixes (compared to 1.90.*) and a new shell that runs better than before and runs on GAE too, if you choose to deploy it. Massimo
[web2py] Re: web2py 1.91.1 is OUT (LGPLv3)
Excellent. On the download page (http://www.web2py.com/examples/default/download), there's a typo: (under the terms of the LPGL should be (under the terms of the LGPL) (i.e., PG - GP, and include closing parenthesis). Also, still need to update the license in the book: http://www.web2py.com/book/default/chapter/01#License On the download page, it says applications built with web2py can link unmodified web2py libraries. Under the LGPL, is it also OK to link _modified_ web2py libraries, as long as the source of the modified libraries is provided and released under LGPL as well (but still allowing the linking application to remain closed source if desired)? Anthony On Tuesday, December 21, 2010 8:33:21 PM UTC-5, mdipierro wrote: web2py 1.91.1 is out, the first version with a new license. Main changes are the license, bug fixes (compared to 1.90.*) and a new shell that runs better than before and runs on GAE too, if you choose to deploy it. Massimo
[web2py] Re: web2py 1.91.1 is OUT (LGPLv3)
On Dec 21, 8:07 pm, Anthony abasta...@gmail.com wrote: Excellent. On the download page (http://www.web2py.com/examples/default/download), there's a typo: (under the terms of the LPGL should be (under the terms of the LGPL) (i.e., PG - GP, and include closing parenthesis). oops Also, still need to update the license in the book:http://www.web2py.com/book/default/chapter/01#License On the download page, it says applications built with web2py can link unmodified web2py libraries. Under the LGPL, is it also OK to link _modified_ web2py libraries, as long as the source of the modified libraries is provided and released under LGPL as well (but still allowing the linking application to remain closed source if desired)? yes Anthony On Tuesday, December 21, 2010 8:33:21 PM UTC-5, mdipierro wrote: web2py 1.91.1 is out, the first version with a new license. Main changes are the license, bug fixes (compared to 1.90.*) and a new shell that runs better than before and runs on GAE too, if you choose to deploy it. Massimo
Re: [web2py] It is done GPL2 - LGPL3
+1 2010/12/22 R. Strusberg strusb...@gmail.com Another reason to switch from *webframework to web2py!. +1 :-) Merry Christmas +1 2010/12/21 mdipierro mdipie...@cs.depaul.edu: For now trunk only. This will propagate to stable since 1.91.1 -- Díaz Luis TSU Analisis de Sistemas Universidad de Carabobo http://web2pyfacil.blogspot.com/ Facultad de Odontologíahttp://www.odontologia.uc.edu.ve/index.php?option=com_contentview=articleid=102Itemid=85