[web2py] Re: routes.py
yes default_app is just to allow access to my app at http://127.0.0.1:8000 (without specifying an app name) *You probably still need to specify myApp in your routes.* In my app-specific routes;py tried #!/usr/bin/python # -*- coding: utf-8 -*- routes_in = ( ('/myApp/testme', '/myApp/default/index'), ) routes_out = ( ('/myApp/default/index', '/myApp/testme'), ) But when I go on http://127.0.0.1:8000/myApp/testme I still have an error : invalid controller (testme/index) I'm testing on Windows7 pro x64 with default rocket webserver. Could it cause some issues? Thank you Le jeudi 2 mai 2013 16:57:00 UTC+2, Anthony a écrit : I think default_app just tells it where to go if there is no app, controller, or function. You probably still need to specify myApp in your routes. Anthony On Thursday, May 2, 2013 9:54:20 AM UTC-4, Loïc wrote: Thank you anthony for your quick response. I updated *web2py\routes.py* to remain only the following line : # -*- coding: utf-8 -*- default_application = myApp When I open http://127.0.0.1:8000 I am redirected to myApp. So This routes.py file seems to be OK Then, on *web2py\applications\myApp\routes.py* I wrote : routes_in = ( ('/testme', '/myApp/default/index'), ) routes_out = ( ('/myApp/default/index', '/testme'), ) But when I go to http://127.0.0.1:8000/myApp/testme I still have an error invalid controller (testme/index) I have also tested with *web2py\applications\myApp\routes.py* : #!/usr/bin/python # -*- coding: utf-8 -*- routes_in = ( ('/testme', '/default/index'), ) routes_out = ( ('/default/index', '/testme'), ) But I have the same error : invalid controller (testme/index) Le jeudi 2 mai 2013 15:27:50 UTC+2, Anthony a écrit : You cannot combine the parameter-based and pattern-based rewrite systems -- pick one or the other. On Thursday, May 2, 2013 8:29:37 AM UTC-4, Loïc wrote: Hello all, I want to play with URL revrite. So I took the example in the book ( http://web2py.com/books/default/chapter/29/04?search=routes_in#Pattern-based-system ) In the file *web2py\applications\myApp\routes.py* I have : #!/usr/bin/python # -*- coding: utf-8 -*- routes_in = ( ('/testme', '/myApp/default/index'), ) routes_out = ( ('/myApp/default/index', '/testme'), ) In web2py root dir, I also added a routes.py file containing : # -*- coding: utf-8 -*- routers = dict( BASE=dict( default_application='myApp', ), ) I restarted web2py to reload routes, but when I go on http://127.0.0.1:8000/testme or on http://127.0.0.1:8000/myApp/testmeI have an error : invalid function (default/testme) Can somebody explain me what is wrong is my routes.py files? Thank you -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] scraping utils in controller
Hello, is there an example how to use this: scraping utils https://groups.google.com/forum/?fromgroups=#!topic/web2py/skcc2ql3zOs in a controller? Especially the first lines (fetching the page and getting it into an element) is what I am looking for. The above example is made for the shell access. Thanks and kind regards, Timmie -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] web2py doesn't start!
I would like to use the web2py framework. When I tried to run *python web2py*, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widget.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widget.py, line 921, in console if not is_loopback_ip_address(ip[4][0])])) File /home/nader/web2py/gluon/utils.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] SQLFORM.grid seems to overwriting an unshown field.
I must have missed something. In 2.4.6 I have a MSSQL table with an integer field. When I show the table with SQLFORM.grid, one of the fields is being reset to 0. The definition of this field is Field(cm_patient_id,integer) The table is migrate =False. the SQLFORM.grid is form = SQLFORM.grid(db_vciadmin.web_form_1te,deletable=False,user_signature =False,editable=False,Field=[...] but cm_patient_id is not one of the fields in the Field. If I edit the table to put a value in cm_patient_id, I see that when the SQLFORM.grid controller executes, cm_patient_id is reset to zero. Driving me crazy. Seems a bit odd, and certainly unexpected. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] form.vars form type GET
Hi, i have a form like this. fields.append(Field(date_from, date, requires=IS_DATE(), label=LABEL(Datum od, _for= no_table_date_from))) fields.append(Field(date_to, date, requires=IS_DATE(), label=LABEL(Datum do, _for=no_table_date_to ))) fields.append(Field(location_id, reference asset_location, required=True, requires=IS_NULL_OR(IS_IN_DB(db, 'asset_location.id', '%(name)s', zero=T(Molimo odaberite lokaciju))), label=LABEL(Lokacija, _for= no_table_location_id))) fields.append(Field(repeated, boolean, label=LABEL(Ponovljene, _for= no_table_repeated))) form = SQLFORM.factory(*fields, _method=GET) and then i have: if request.get_vars.date_from or request.get_vars.date_to: query = (db.asset_value.asset_attribute_id == 27) if request.get_vars.date_from: query = (db.asset_value.date_value request.get_vars. date_from) form.vars.date_from = request.get_vars.date_from if request.get_vars.date_to: query = (db.asset_value.date_value request.get_vars. date_to) form.vars.date_from = request.get_vars.date_from if request.get_vars.location_id: query = (db.asset_value.location_value == request.get_vars. location_id) form.vars.location_id = request.get_vars.location_id if request.get_vars.repeated: query = (db.asset_value.boolean_value == request.get_vars. repeated) form.vars.repeated = request.get_vars.repeated Queries are fine and they work, but form.vars are always empty, does that have anything to do with form type being GET? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Dynamic IS_IN_DB
Thanks, i used first method. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Conditional Fields in Custom Forms
Hey Group, I am new to web2py and I am working to create a custom form from the SQLForm.Factory with a conditional field built in. I have two questions. 1. Using a conditional field based on the checkbox, I can get it to work if I don't use the custom form, but I can't get it to work with the custom form. Below is my code in the view. {{extend 'layout.html'}} {{=form.custom.begin}} b Set Model Options /b div Model Name: {{=form.custom.widget.GAWR_Model_Name}} /div div Sales Set: {{=form.custom.widget.Sales_Set}} /div b Determine the Bandwidth /b script jQuery(document).ready(function(){ jQuery('#no_table_band__row').hide(); jQuery('#no_table_CV').change(function(){ if(jQuery('#no_table_CV').attr('checked')) jQuery('#no_table_band__row').show(); else jQuery('#no_table_band__row').hide();});}); /script div {{=form.custom.widget.CV}} Manually Set the Bandwidth (default is Cross Validation) /div {{=form.custom.submit}} {{=form.custom.end}} 2. I would like to be able to make a conditional field based on something other than a checkbox, like the value of a set of radio buttons, multiple checkboxes, or a standard select dropdown. In the latter case, a User would select a certain value in a dropdown and then another dropdown would appear based on the value the User chose. Can you point me toward any resources on how to do that? Thank you. - Josh -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: form.vars form type GET
did you already try request.vars? On Friday, May 3, 2013 5:40:07 AM UTC-4, Domagoj Kovač wrote: Hi, i have a form like this. fields.append(Field(date_from, date, requires=IS_DATE(), label=LABEL(Datum od, _for= no_table_date_from))) fields.append(Field(date_to, date, requires=IS_DATE(), label=LABEL(Datum do, _for= no_table_date_to))) fields.append(Field(location_id, reference asset_location, required=True, requires=IS_NULL_OR(IS_IN_DB(db, ' asset_location.id', '%(name)s', zero=T(Molimo odaberite lokaciju))), label=LABEL(Lokacija, _for= no_table_location_id))) fields.append(Field(repeated, boolean, label=LABEL(Ponovljene, _for= no_table_repeated))) form = SQLFORM.factory(*fields, _method=GET) and then i have: if request.get_vars.date_from or request.get_vars.date_to: query = (db.asset_value.asset_attribute_id == 27) if request.get_vars.date_from: query = (db.asset_value.date_value request.get_vars. date_from) form.vars.date_from = request.get_vars.date_from if request.get_vars.date_to: query = (db.asset_value.date_value request.get_vars. date_to) form.vars.date_from = request.get_vars.date_from if request.get_vars.location_id: query = (db.asset_value.location_value == request.get_vars. location_id) form.vars.location_id = request.get_vars.location_id if request.get_vars.repeated: query = (db.asset_value.boolean_value == request.get_vars. repeated) form.vars.repeated = request.get_vars.repeated Queries are fine and they work, but form.vars are always empty, does that have anything to do with form type being GET? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py doesn't start!
what kind of os did you use and what version of web2py did you use? On Friday, May 3, 2013 3:30:01 AM UTC-4, Nader Emami wrote: I would like to use the web2py framework. When I tried to run *python web2py*, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widget.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widget.py, line 921, in console if not is_loopback_ip_address(ip[4][0])])) File /home/nader/web2py/gluon/utils.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: form.vars form type GET
request.get_vars.repeated - i have my value here, but doesn't work. form.vars.repeated = request.get_vars.repeated -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: form.vars form type GET
i mean request.vars, it handle the boths post and get method on the book : If the HTTP request is a GET, then request.env.request_method is set to GET; if it is a POST,request.env.request_method is set to POST. URL query variables are stored in the request.vars Storage dictionary; they are also stored in request.get_vars (following a GET request) or request.post_vars (following a POST request). ref: http://web2py.com/books/default/chapter/29/04#Dispatching On Friday, May 3, 2013 7:10:50 AM UTC-4, Domagoj Kovač wrote: request.get_vars.repeated - i have my value here, but doesn't work. form.vars.repeated = request.get_vars.repeated -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: form.vars form type GET
At some point, you have to call form.process(request_vars=request.get_vars) if you want your form.vars assignments to get added to the form widgets (call it after all the assignments). You need to do that for validation anyway. Anthony On Friday, May 3, 2013 5:40:07 AM UTC-4, Domagoj Kovač wrote: Hi, i have a form like this. fields.append(Field(date_from, date, requires=IS_DATE(), label=LABEL(Datum od, _for= no_table_date_from))) fields.append(Field(date_to, date, requires=IS_DATE(), label=LABEL(Datum do, _for= no_table_date_to))) fields.append(Field(location_id, reference asset_location, required=True, requires=IS_NULL_OR(IS_IN_DB(db, ' asset_location.id', '%(name)s', zero=T(Molimo odaberite lokaciju))), label=LABEL(Lokacija, _for= no_table_location_id))) fields.append(Field(repeated, boolean, label=LABEL(Ponovljene, _for= no_table_repeated))) form = SQLFORM.factory(*fields, _method=GET) and then i have: if request.get_vars.date_from or request.get_vars.date_to: query = (db.asset_value.asset_attribute_id == 27) if request.get_vars.date_from: query = (db.asset_value.date_value request.get_vars. date_from) form.vars.date_from = request.get_vars.date_from if request.get_vars.date_to: query = (db.asset_value.date_value request.get_vars. date_to) form.vars.date_from = request.get_vars.date_from if request.get_vars.location_id: query = (db.asset_value.location_value == request.get_vars. location_id) form.vars.location_id = request.get_vars.location_id if request.get_vars.repeated: query = (db.asset_value.boolean_value == request.get_vars. repeated) form.vars.repeated = request.get_vars.repeated Queries are fine and they work, but form.vars are always empty, does that have anything to do with form type being GET? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Create a Form.grid from Rows
Lets say I have a Rows object with the info I want to represent in a gird or smartgrid, is there any way to create a grid passing this rows?. Something like this: form = SQLFORM.grid(*ROWS*, - searchable=True, deletable=True, details=True, selectable=False, create=True, sortable=True, paginate=100, maxtextlength=75, links_in_grid=True) I know that SQLFORM needs a query, but I'm in GAE and I have to make the joins by hand, here ROWS contains the result of the join. Thank you in advance -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: SQLFORM.grid seems to overwriting an unshown field.
Are you saying you do or do not want cm_patient_id in the grid? To restrict the fields displayed, the correct argument is fields, not Field. What do you mean when you say you edit the table to put a value in cm_patient_id? How are you doing that (presumably not via the grid, given that editable is False)? Anthony On Friday, May 3, 2013 4:15:26 AM UTC-4, Tim Richardson wrote: I must have missed something. In 2.4.6 I have a MSSQL table with an integer field. When I show the table with SQLFORM.grid, one of the fields is being reset to 0. The definition of this field is Field(cm_patient_id,integer) The table is migrate =False. the SQLFORM.grid is form = SQLFORM.grid(db_vciadmin.web_form_1te,deletable=False, user_signature=False,editable=False,Field=[...] but cm_patient_id is not one of the fields in the Field. If I edit the table to put a value in cm_patient_id, I see that when the SQLFORM.grid controller executes, cm_patient_id is reset to zero. Driving me crazy. Seems a bit odd, and certainly unexpected. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Create a Form.grid from Rows
I don't think so. Would be nice, though. On Friday, May 3, 2013 7:30:57 AM UTC-4, José Manuel López wrote: Lets say I have a Rows object with the info I want to represent in a gird or smartgrid, is there any way to create a grid passing this rows?. Something like this: form = SQLFORM.grid(*ROWS*, - searchable=True, deletable=True, details=True, selectable=False, create=True, sortable=True, paginate=100, maxtextlength=75, links_in_grid=True) I know that SQLFORM needs a query, but I'm in GAE and I have to make the joins by hand, here ROWS contains the result of the join. Thank you in advance -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Sorry, but what should do .list() ? it is a query? it is pre-fetched or cached? The whole point of having an ORM, is for you to not have to worry about the answer to that question - it's gonna do the optimal thing it can, based on the circumstances in which it is called. As I described, like 10 times already, ORMs are statefull - they have cache-management built-in. The question of how these cache-management is working, and so whether or not you can trust it, is a long and complex question. Suffice it to say, that there has been more than a decade of research into this issue, so it is solved. Just as example, if the list has objects in it, it will check that what it has is up-to-date. If it is called within the context of a transaction that is in progress, and it had already did a query for that beforehand within the same transaction, than by ACID's C of Consistency rule, the code should assume that it's cached-data is up-to-date. If between the previously-called query, and this call, a transaction was ended and a new one started, then according to ACID's C of Consistency rule, the code should not assume that the data is up-to-date, and issue a query. ORMs like SQLA's ORM do a 'Unit-Of-Work' patterns, in which these caches are managed for you. Any transaction-commit invalidates the caches, so you can guarantee consistency across transactions. What about if I need the cities of countries where main language is not Spanish, and population is above 1 millon? ORMs allow you to attache filters for that, it really depends on the implementation, but let's think of some options, shell we? The most straight-forward approach I would suggest, is the layered-approach - meaning, the ORM should use the DAL for that internally. It should allow you to construct the filters yourself using the DAL, and have mechanisms to facilitate attaching of filters to these attributes. We can go into a discussion of how it will look like in an ORM in web2py in each of the options - which would be the fun-part, I think - so let's see: First, let's extend the schema and ORM example-definitions to include that: db.define_table('Language', Field('Name', 'String')) db.define_table('Continent', Field('Name', 'string')) db.define_table('Country', Field('Name', 'string'), Field('Continent', db.Continent)) db.define_table('City', Field('Name', 'string'), Field('Country', db.Country), Field('Language', db.Language), Field('Population', 'Integer')) @ORM(db.Language) class Language: pass @ORM(db.City) class City: pass @ORM(db.Country) class Country: pass @ORM(db.Continent) class Continent: pass ... spanish = Language(Name='Spanish') french = Language(Name='French') france.City.Language = french ... Then, we could devise to do any number of things: We can build basic stuff like .isGraterThan() into the ORM classes, and do: ... [city for city in fance.City.list if \ city.Language is not spanish and city.Population.isGraterThan(100)] [City Name:Paris] It almost reads like plain English... Beautiful (!) Alternatively, we could have a set of operators that we can give to a filter function: ... from ORM.operators import not, moreThan france.City.where( Language=not(spanish), Population=moreThan(100)) [City Name:Paris] Lastly, we could let the developer filter objects using the DAL indirectly: ... france.City.FilterBy( (City.Languase != spanish) (City.Population 100)) [City Name:Paris] Please, note that you are mixing a declarative query syntax (DAL), with an imperative one (ORM) No, I am LAYERING imperative-syntax on-top of declarative one. I would like a elegant declarative syntax similar to LINQ, but in python: [city for db.City.ALL in db.City, db.Country if db.Country.Name == 'France' and db.Country.id == db.City.country] My first suggestion was way more readable. Sadly, there is NO possible way to archive a pythonic list comprenhension syntax that query the objects in the server side AFAIK Not sure what you mean... Some libraries uses dis (python disassembler) and other internal dirty python hacks to do something similar, please, see: http://www.aminus.net/geniusql/ http://www.aminus.org/blogs/index.php/2008/04/22/linq-in-python?blog=2 http://www.aminus.net/geniusql/chrome/common/doc/trunk/managing.html Note that web2py is much closer to the pythonic expressions, but without the early / late binding and other issues described there ;-) I will look into that. This would require caching or storing previous queried record in memory (something like a singleton), or is will not work as you are expecting (it is for checking identity)... Exactly! This is exactly what SQLA is already doing - I explained that before - it uses what it calls 'Identity Mapping' internally: http://www.youtube.com/watch?v=woKYyhLCcnU#t=6382shttp://www.youtube.com/watch?v=woKYyhLCcnU ** Time-coded link - watch the
[web2py] Re: scraping utils in controller
That same code works in a controller -- it was merely being demonstrated in a shell. Instead of urllib.urlopen, you can now use fetch (which also works on GAE): from gluon.tools import fetch page = TAG(fetch('http://www.web2py.com')) page.elements('div') # gives you a list of all DIV elements in the page (as web2py DIV helper objects) Actually, at the moment, the above will generate an error because apparently there is an unbalanced a tag somewhere on the web2py.com page. Anthony On Friday, May 3, 2013 3:15:55 AM UTC-4, Timmie wrote: Hello, is there an example how to use this: scraping utils https://groups.google.com/forum/?fromgroups=#!topic/web2py/skcc2ql3zOs in a controller? Especially the first lines (fetching the page and getting it into an element) is what I am looking for. The above example is made for the shell access. Thanks and kind regards, Timmie -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: web2py doesn't start!
Thank for your email. I use Linux (gentoo) with Python-2.7.3. I have got yesterday the web2py_src.zip: (Version 2.4.6-stable+timestamp.2013.04.06.17.37.38) Nader On 3 May 2013 13:10, 黄祥 steve.van.chris...@gmail.com wrote: what kind of os did you use and what version of web2py did you use? On Friday, May 3, 2013 3:30:01 AM UTC-4, Nader Emami wrote: I would like to use the web2py framework. When I tried to run *python web2py*, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widg**et.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widg**et.py, line 921, in console if not is_loopback_ip_address(ip[4][0**])])) File /home/nader/web2py/gluon/util**s.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/t_11PX-hYt0/unsubscribe?hl=en. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: form.vars form type GET
I have a problem, form.validate(request_vars=request.get_vars) works but only when form is not submitted, when i submit my form my values are erased. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: form.vars form type GET
I needed to add keepvalues form.validate(request_vars=request.get_vars, keepvalues=True) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: web2py doesn't start!
i ran it on python 2.7.3 on lubuntu 12.10 and on centos 6.4 never get any problems. did you installed python from souce? On Friday, May 3, 2013 7:49:34 AM UTC-4, Nader Emami wrote: Thank for your email. I use Linux (gentoo) with Python-2.7.3. I have got yesterday the web2py_src.zip: (Version 2.4.6-stable+timestamp.2013.04.06.17.37.38) Nader On 3 May 2013 13:10, 黄祥 steve.van...@gmail.com javascript: wrote: what kind of os did you use and what version of web2py did you use? On Friday, May 3, 2013 3:30:01 AM UTC-4, Nader Emami wrote: I would like to use the web2py framework. When I tried to run *python web2py*, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widg**et.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widg**et.py, line 921, in console if not is_loopback_ip_address(ip[4][0**])])) File /home/nader/web2py/gluon/util**s.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/t_11PX-hYt0/unsubscribe?hl=en. To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Just to clarify, again, the following syntax: [city for city in fance.City.list if \ city.Language is not spanish and city.Population.isGraterThan(100)] Is not a pie-in-the-sky dream-API - there are implementational details that are viable for each section. First, the reason the is not would work, is that there would exist an implementation of 'Identity Mapping that would take care of having a singleton for each ORM-object representing each row. Second, the access to france.City.list is viable, as an attribute-access is totally customization in python, so we can devise anything we want for the access to do. For example, it could return an iterator, if the City attribute of the france ORM-object is valid (meaning, it is cached and not invalidated by a previous transaction-commit), and do a query right-there on the spot, and return an iterator, if the City attribute of the france ORM-object is invalid at the time of the list attribute access. Lastly, the .isGraterThan() can easily be implemented in the ORM-class that would be generated out of the @ORM() class-decorator. It is used for 3 purposes: 1. Readability 2. Beauty. 3. Conciseness. When comparing this: city.Language is not spanish and city.Population.isGraterThan(100) With this: db.Country.Name http://db.country.name/ == 'France' and db.Country.idhttp://db.country.id/ == db.City.country The Zen of Python comes to mind: Beautiful is better than ugly. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py doesn't start!
Did you run python web2py or python web2py.py? On Friday, May 3, 2013 3:30:01 AM UTC-4, Nader Emami wrote: I would like to use the web2py framework. When I tried to run *python web2py*, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widget.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widget.py, line 921, in console if not is_loopback_ip_address(ip[4][0])])) File /home/nader/web2py/gluon/utils.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] psycopg2 or pg8000
OK. I think I know what to do now. I opened a ticket and will review this asap. Thanks Mariano. On Thursday, 2 May 2013 10:35:58 UTC-5, Mariano Reingart wrote: There is new activity in the original pg8000 repo, but AFAIK some of my changes where not merged, and others where not addressd, but you could try that: https://github.com/mfenniak/pg8000 About escaping, the difference with psycopg2 is that pg8000 uses the more advanced query protocol (Prepared Statement) that don't requires escaping and inlining the parameters in the SQL query (so, in theory, it is even safer than psycopg2. and more straightforward as it allows binary parameters directly). Another advantages of de prepared statement protocol is that it could be parsed/analyzed once, and executed many times, that should be faster in some circumstances. IIRC, psycopg2 uses the simple query protocol, with inlined parameters directly in the SQL. It has a mogrify function that escapes the parameters, that should be migrated to pg8000 to avoid this kind of issues, or better, just use the DBAPI call with parameters, so no scaping will be required (IIRC, this is not supported by web2py right now). Sadly, many connectors have different implentation of the DBAPI, so it would not be trivial to adapt, see for example: http://www.python.org/dev/peps/pep-0249/#paramstyle Also, psycopg2 uses libpq (the postgresql client C library), so it will be a lot faster (but a bit harder to install in some scenarios). Its depends highly on which kind of application you're writting (for simple apps, there wouldn't be a significative difference). BTW, if you have a test case with web2py, I could help to fix the issues with pg8000. Best regards, Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com On Thu, May 2, 2013 at 10:13 AM, Massimo Di Pierro massimo@gmail.com javascript: wrote: I do not remember what the bugs were but they were related to escaping and this poses a security issue. It has not been fixed to my knowledge. On Thursday, 2 May 2013 03:02:26 UTC-5, Marin Pranjić wrote: I remember pg8000 having some bugs and I'm not sure if they are fixed. psycopg2 should be better choice Marin On Thu, May 2, 2013 at 1:59 AM, Marco Túlio Cícero de M. Porto mtcp...@gmail.com wrote: Are there any advantages on one or another or are they basically the same thing? I'm using psycopg2 atm. -- []'s Marco Tulio -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Create a Form.grid from Rows
Not possible for various logical reasons. The point of the grid is to do paginations without having all the records. If you do, you do not need the grid. On Friday, 3 May 2013 06:30:57 UTC-5, José Manuel López wrote: Lets say I have a Rows object with the info I want to represent in a gird or smartgrid, is there any way to create a grid passing this rows?. Something like this: form = SQLFORM.grid(*ROWS*, - searchable=True, deletable=True, details=True, selectable=False, create=True, sortable=True, paginate=100, maxtextlength=75, links_in_grid=True) I know that SQLFORM needs a query, but I'm in GAE and I have to make the joins by hand, here ROWS contains the result of the join. Thank you in advance -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
The whole point of having an ORM, is for you to not have to worry about the answer to that question - it's gonna do the optimal thing it can, based on the circumstances in which it is called. Has anyone given you any Kool-Aid to drink recently? The question of how these cache-management is working, and so whether or not you can trust it, is a long and complex question. Suffice it to say, that there has been more than a decade of research into this issue, so it is solved. Famous last words. What about if I need the cities of countries where main language is not Spanish, and population is above 1 millon? ORMs allow you to attache filters for that, it really depends on the implementation, but let's think of some options, shell we? db.define_table('Language', Field('Name', 'String')) db.define_table('Continent', Field('Name', 'string')) db.define_table('Country', Field('Name', 'string'), Field('Continent', db.Continent)) db.define_table('City', Field('Name', 'string'), Field('Country', db. Country), Field('Language', db.Language), Field('Population', 'Integer')) spanish = Language(Name='Spanish') french = Language(Name='French') france.City.Language = french What does france.City.Language = french do? france.City refers to all cities in France, so does this assign French as the language for all cities? Does SQLA employ that syntax? In web2py, this would be: french = db.Language.insert(Name='French') db.Country(france).City.update(Language=french) Looks a lot like your example (maybe even a bit more explicit about what's going on). (Note, Mariano's example actually assumed language to be a country-level field.) [city for city in fance.City.list if \ city.Language is not spanish and city.Population.isGraterThan(100)] [City Name:Paris] The problem here is that you are doing all the filtering in Python rather than in the database. Not a big deal in this example, but with a large initial set of records, this is inefficient because you will return many unnecessary records from the database and Python will likely be slower to do the filtering. It almost reads like plain English... Beautiful (!) There are differing opinions on this. Some prefer symbols like != and over plain English like is not and isGreaterThan because it is easier to scan the line and quickly discern the comparisons being made. In particular, I would much prefer both typing and reading rather than .isGreaterThan(). france.City.where( Language=not(spanish), Population=moreThan(100)) france.City.FilterBy( (City.Languase != spanish) (City.Population 100)) In web2py, you can already do: db.Country(france).City( (db.City.Language != spanish) (db.City.Population 100)).select() So far, for every example you have shown, web2py has fairly similar syntax. Sure, we can quibble over which is more beautiful, but I haven't seen anything to justify building a massive ORM. And the downside of adding an ORM (aside from the time cost of development and maintenance) is that you would then have to learn yet another abstraction and syntax. That could be also archived hacking Row, but you should use == in python for this kind of comparision (equality) Not is SQLA :) Well, if you're actually making such a comparison, you generally would only be interested in ==, not is -- it just so happens that is would also be True in SQLA because of the identity mapping. Web2py *could *do that too. Sure, but it could do it at the DAL level, without an ORM. So far, though, you haven't made a strong case for the utility of such a feature (I don't doubt that it can be helpful -- the question is how helpful). An ORM is MUCH MORE intuitive, as my examples had demonstrated Maybe I missed an example, but I don't think I saw any that were more intuitive at all, let alone MUCH MORE intuitive. Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: SQLFORM.grid seems to overwriting an unshown field.
On Friday, 3 May 2013 21:31:09 UTC+10, Anthony wrote: Are you saying you do or do not want cm_patient_id in the grid? cm_patient_id is not shown on the grid, which is correct. Sorry for the poor post, I am using fields like so: fields=[db_vciadmin.web_form_1te.date_submitted, ... What do you mean when you say you edit the table to put a value in cm_patient_id? How are you doing that (presumably not via the grid, given that editable is False)? I meant that I am editing in directly via the database management tool (in this case MS SQL Management Studio) . I am doing this to try to understand what is going on. In the production app, the edit of cm_patient_id is done with an SQLFORM like so:from_date = request.vars.from_date_date = request.vars.to_date def match_patient(): row_id = request.vars.row_id #get the record web_form_record = db_vciadmin.web_form_1te[row_id] query = db_ps(db_ps.cm_patient.surname.contains(web_form_record.surname )) #this subsets the values sent to the dropbox db_vciadmin.web_form_1te.cm_patient_id.requires = \ IS_IN_DB(query, 'cm_patient.id', '%(surname)s, %(first_name)s DOB: %(dob)s',zero=T('choose one')) form = SQLFORM(db_vciadmin.web_form_1te,record=web_form_record) . . . (match_patient is setup in the SQLFORM.grid using links= ) So I am mucking around a bit with the requires definition in the model. However, the database value is reset in the controller which shows the grid. It is not reset simple because a new request occurs, as far as I can tell. Anthony On Friday, May 3, 2013 4:15:26 AM UTC-4, Tim Richardson wrote: I must have missed something. In 2.4.6 I have a MSSQL table with an integer field. When I show the table with SQLFORM.grid, one of the fields is being reset to 0. The definition of this field is Field(cm_patient_id,integer) The table is migrate =False. the SQLFORM.grid is form = SQLFORM.grid(db_vciadmin.web_form_1te,deletable=False, user_signature=False,editable=False,Field=[...] but cm_patient_id is not one of the fields in the Field. If I edit the table to put a value in cm_patient_id, I see that when the SQLFORM.grid controller executes, cm_patient_id is reset to zero. Driving me crazy. Seems a bit odd, and certainly unexpected. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
When comparing this: city.Language is not spanish and city.Population.isGraterThan(100) With this: db.Country.Name http://db.country.name/ == 'France' and db.Country.idhttp://db.country.id/ == db.City.country Well, we should compare your first line to the DAL equivalent: (db.City.Language != spanish) (db.City.Population 100) I actually find that latter easier to process. The parentheses and make it easier to see there are two separate conditions, and the != and are easier to pick out and comprehend than is not and .isGreaterThan(). A non-programmer may have an easier time with the more English-like version (assuming they happen to speak English, of course), but I think it's reasonable to expect even novice programmers to understand the basic boolean operators. Whatever your opinion on the beauty of one over the other, though, surely this doesn't justify the massive undertaking of building an ORM, particularly since you would still have to know and use the underlying DAL syntax in addition anyway. Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py doesn't start!
I did the second one: python web2py.py. On Friday, May 3, 2013 9:30:01 AM UTC+2, Nader Emami wrote: I would like to use the web2py framework. When I tried to run *python web2py*, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widget.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widget.py, line 921, in console if not is_loopback_ip_address(ip[4][0])])) File /home/nader/web2py/gluon/utils.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: web2py doesn't start!
I didn't install python from source, Gentoo did it. On Friday, May 3, 2013 2:00:39 PM UTC+2, 黄祥 wrote: i ran it on python 2.7.3 on lubuntu 12.10 and on centos 6.4 never get any problems. did you installed python from souce? On Friday, May 3, 2013 7:49:34 AM UTC-4, Nader Emami wrote: Thank for your email. I use Linux (gentoo) with Python-2.7.3. I have got yesterday the web2py_src.zip: (Version 2.4.6-stable+timestamp.2013.04.06.17.37.38) Nader On 3 May 2013 13:10, 黄祥 steve.van...@gmail.com wrote: what kind of os did you use and what version of web2py did you use? On Friday, May 3, 2013 3:30:01 AM UTC-4, Nader Emami wrote: I would like to use the web2py framework. When I tried to run *python web2py*, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widg**et.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widg**et.py, line 921, in console if not is_loopback_ip_address(ip[4][0**])])) File /home/nader/web2py/gluon/util**s.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/t_11PX-hYt0/unsubscribe?hl=en. To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: SQLFORM.grid seems to overwriting an unshown field.
How did the record get created to begin with? Did it start with a cm_patient_id value of 0? Are you sure you committed your change when using the database management tool? Anthony On Friday, May 3, 2013 9:37:10 AM UTC-4, Tim Richardson wrote: On Friday, 3 May 2013 21:31:09 UTC+10, Anthony wrote: Are you saying you do or do not want cm_patient_id in the grid? cm_patient_id is not shown on the grid, which is correct. Sorry for the poor post, I am using fields like so: fields=[db_vciadmin.web_form_1te.date_submitted, ... What do you mean when you say you edit the table to put a value in cm_patient_id? How are you doing that (presumably not via the grid, given that editable is False)? I meant that I am editing in directly via the database management tool (in this case MS SQL Management Studio) . I am doing this to try to understand what is going on. In the production app, the edit of cm_patient_id is done with an SQLFORM like so: def match_patient(): row_id = request.vars.row_id #get the record web_form_record = db_vciadmin.web_form_1te[row_id] query = db_ps(db_ps.cm_patient.surname.contains(web_form_record. surname)) #this subsets the values sent to the dropbox db_vciadmin.web_form_1te.cm_patient_id.requires = \ IS_IN_DB(query, 'cm_patient.id', '%(surname)s, %(first_name)s DOB: %(dob)s',zero=T('choose one')) form = SQLFORM(db_vciadmin.web_form_1te,record=web_form_record) . . . (match_patient is setup in the SQLFORM.grid using links= ) So I am mucking around a bit with the requires definition in the model. However, the database value is reset in the controller which shows the grid. It is not reset simple because a new request occurs, as far as I can tell. Anthony On Friday, May 3, 2013 4:15:26 AM UTC-4, Tim Richardson wrote: I must have missed something. In 2.4.6 I have a MSSQL table with an integer field. When I show the table with SQLFORM.grid, one of the fields is being reset to 0. The definition of this field is Field(cm_patient_id,integer) The table is migrate =False. the SQLFORM.grid is form = SQLFORM.grid(db_vciadmin.web_form_1te,deletable=False, user_signature=False,editable=False,Field=[...] but cm_patient_id is not one of the fields in the Field. If I edit the table to put a value in cm_patient_id, I see that when the SQLFORM.grid controller executes, cm_patient_id is reset to zero. Driving me crazy. Seems a bit odd, and certainly unexpected. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Dynamically generating text file that isn't stored?
I would like to permit users to be able to download a text file of some data that's pulled up from certain fields of a DB table. This text file should be generated when the user clicks on a certain link, and should not be stored on the server's HD. Any ideas as to how to go about doing this? Thanks! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Am Freitag, 3. Mai 2013 13:44:20 UTC+2 schrieb Arnon Marcus: Sorry, but what should do .list() ? it is a query? it is pre-fetched or cached? The whole point of having an ORM, is for you to not have to worry about the answer to that question - it's gonna do the optimal thing it can, based on the circumstances in which it is called. Here's the problem. In a perfect world you don't have to worry about what's going on behind the scenes. In a real application you need to know what exactly the ORM is doing, otherwise you'll run into problems sooner or later. I had to work with an ORM (Hibernate) for many years. The ORM is very convenient but the magic which is going on in the background will cause you trouble (at least performance-wise). I'm really happy to use web2py and the DAL for my own project, I always know what exactly is going on and I never encountered a strange bug where I could not figure out what's going on. Not so with the ORM where I lost many hours debugging unexcepted behavior. In my opinion it does not make sense to define how references are fetched on an object level (at least that's how it is done in Hibernate, don't know about SQLA). E.g. when I query a City object I can't say in advance if I always want to access the Country reference as well. In Hibernate single references have eager loading so they are always fetched. That's bad because when you don't need the reference there is unnecessary data fetched (and of course this is recursive, e.g. if Country has a single reference itself this will also be loaded). With lazy loading you often run into the problem that the session or transaction is not active anymore and the references cannot be accessed (just google for Lazy Loading Exception). Therefor we often loaded all those references when the object is queried to avoid running into a lazy loading exception later on - which is of course also not very good for performance. With the DAL I say exactly what I need (joining the tables I really need for my use case) and when, that's so much better and easier than depending on some ORM magic. For me all the added internal complexity of an ORM is not worth the effort. The complexity is just shifted to a different layer. Maybe the videos and presentations of SQLA look nice and promising but you'll only find out about the disadvantages (which are not mentioned in the videos of course) once you develop a real world application. Alex -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py doesn't start!
Hmm, not sure what's going on then. On Friday, May 3, 2013 9:53:10 AM UTC-4, Nader Emami wrote: I did the second one: python web2py.py. On Friday, May 3, 2013 9:30:01 AM UTC+2, Nader Emami wrote: I would like to use the web2py framework. When I tried to run *python web2py*, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widget.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widget.py, line 921, in console if not is_loopback_ip_address(ip[4][0])])) File /home/nader/web2py/gluon/utils.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: web2py doesn't start!
On 3 May 2013, at 4:49 AM, Nader Emami n.em...@gmail.com wrote: Thank for your email. I use Linux (gentoo) with Python-2.7.3. I have got yesterday the web2py_src.zip: (Version 2.4.6-stable+timestamp.2013.04.06.17.37.38) Run Python from the command line and run (and report) what you get from: import socket socket.getaddrinfo(socket.getfqdn(), 0) Nader On 3 May 2013 13:10, 黄祥 steve.van.chris...@gmail.com wrote: what kind of os did you use and what version of web2py did you use? On Friday, May 3, 2013 3:30:01 AM UTC-4, Nader Emami wrote: I would like to use the web2py framework. When I tried to run python web2py, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widget.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widget.py, line 921, in console if not is_loopback_ip_address(ip[4][0])])) File /home/nader/web2py/gluon/utils.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: SQLFORM.grid seems to overwriting an unshown field.
On Friday, 3 May 2013 23:59:51 UTC+10, Anthony wrote: How did the record get created to begin with? Did it start with a cm_patient_id value of 0? Are you sure you committed your change when using the database management tool? This works: I open up the grid in web2py, and click on the button Match Patients which invokes the controller match_patient, allowing me to edit that record. I match the patient, which updates the foreign key cm_patient_id via the requires=IS_IN_DB. The calculated fields works too. So if I go to Management Studio and look at the table, I can see the foreign key (an integer) and the the calculated field (a string). So I'm definitely convinced that the edit of the record in the SQLFORM of match_patient() is committing. Going back to web2py, if I refresh the SQLFORM.grid or enter it again, at that point the table is reset. The foreign key is set to 0, which is the default value, and the calculated field is set to NULL. Other fields are unaffected. Is it a database migration? (migrate = False in the model). The fact the the calculated field is set to NULL is probably not as interesting as the resetting of cm_patient_id. (if I change the table definition in Management Studio so that the default value is 99, then opening the controller which displays the grid puts 99 in every row (inspected via Management Studio) Then I can edit the definition to make the default value 55, refresh the controller and I get 55 in every row. So the grid is wiping out that field and the database replaces it with the default value. I guess there is something wrong with my table definition. This is what I have right now (I've disabled the compute) db_vciadmin = DAL('mssql://tim:xxx@vci-win2003\hcnsql07/vciadmin', lazy_tables=True,pool_size=10) . . . db_vciadmin.define_table(web_form_1te, Field(patient_details_id,'integer',unique=True), Field(date_submitted,date), Field(first_name,string), Field(surname,string), Field(dob,date), #Field(cm_patient_id,reference cm_patient), Field(cm_patient_id,integer), #Field(patient,string, compute=lambda r: patient_name(r['cm_patient_id'])), Field(patient,string), format='%(first_name)s %(surname)s', migrate=False ) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] You can chain @make_member_of decorator
To make generic query functions truly generic, now you can stack or chain @make_member_of decorator. It's now a slice: http://www.web2pyslices.com/slice/show/1625/turn-a-function-into-a-table-method -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: SQLFORM.grid seems to overwriting an unshown field.
Hard to say what's going on. Just loading the grid doesn't do any writing to the database, so something else must be happening. Can you produce a minimal app that replicates this behavior with SQLite? Anthony On Friday, May 3, 2013 10:15:43 AM UTC-4, Tim Richardson wrote: On Friday, 3 May 2013 23:59:51 UTC+10, Anthony wrote: How did the record get created to begin with? Did it start with a cm_patient_id value of 0? Are you sure you committed your change when using the database management tool? This works: I open up the grid in web2py, and click on the button Match Patients which invokes the controller match_patient, allowing me to edit that record. I match the patient, which updates the foreign key cm_patient_id via the requires=IS_IN_DB. The calculated fields works too. So if I go to Management Studio and look at the table, I can see the foreign key (an integer) and the the calculated field (a string). So I'm definitely convinced that the edit of the record in the SQLFORM of match_patient() is committing. Going back to web2py, if I refresh the SQLFORM.grid or enter it again, at that point the table is reset. The foreign key is set to 0, which is the default value, and the calculated field is set to NULL. Other fields are unaffected. Is it a database migration? (migrate = False in the model). The fact the the calculated field is set to NULL is probably not as interesting as the resetting of cm_patient_id. (if I change the table definition in Management Studio so that the default value is 99, then opening the controller which displays the grid puts 99 in every row (inspected via Management Studio) Then I can edit the definition to make the default value 55, refresh the controller and I get 55 in every row. So the grid is wiping out that field and the database replaces it with the default value. I guess there is something wrong with my table definition. This is what I have right now (I've disabled the compute) db_vciadmin = DAL('mssql://tim:xxx@vci-win2003\hcnsql07/vciadmin', lazy_tables=True,pool_size=10) . . . db_vciadmin.define_table(web_form_1te, Field(patient_details_id,'integer',unique=True), Field(date_submitted,date), Field(first_name,string), Field(surname,string), Field(dob,date), #Field(cm_patient_id,reference cm_patient), Field(cm_patient_id,integer), #Field(patient,string, compute=lambda r: patient_name(r['cm_patient_id'])), Field(patient,string), format='%(first_name)s %(surname)s', migrate=False ) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py doesn't start!
Can you please run a test for me? python import socket print socket.getaddrinfo(socket.getfqdn(), 0) what's the output? Anyway you can run it with web2py.py --nogui It is failing when making a guess for all your IP addresses. On Friday, 3 May 2013 02:30:01 UTC-5, Nader Emami wrote: I would like to use the web2py framework. When I tried to run *python web2py*, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widget.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widget.py, line 921, in console if not is_loopback_ip_address(ip[4][0])])) File /home/nader/web2py/gluon/utils.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Has anyone given you any Kool-Aid to drink recently? I have no idea what you mean by that... Famous last words. I have no idea what you mean by that... What does france.City.Language = french do? france.City refers to all cities in France, so does this assign French as the language for all cities? Does SQLA employ that syntax? Ooops, cought me there... :) Obviously I meant: fance.City.Paris.Language = french The .Paris part can be implemented via* __getAttr__* The .Language = french part can be implemented via a *Property*. It would obviously treat the primary-key internally, for relationships - but that's a pluming-level thing so it's implicit as a convenience layer. But I like your idea - it could be implemented also! :) In web2py, this would be: french = db.Language.insert(Name='French') db.Country(france).City.update(Language=french) Looks a lot like your example (maybe even a bit more explicit about what's going on). There is a hidden fundamental difference - in my approach it is actually making object-references (alongside the database insertion) so that can be used further-on in the code, at the very leas within the same transaction, but even across transactions. Again, this is a domain-model, not just a a database-model. Internally, the values may get invalidated on transaction-sommit, but the object-references would persist within the current runtime. Again, you have to break-away the stateless mind-set and appreciate statefullness. This assumes a very different execution-model than what you are used to in web2py. It is something that would happen within a *module*, not within a *controller-action,* so it is saved within the module-object across transactions/requests/sessions. (Note, Mariano's example actually assumed language to be a country-level field.) [city for city in fance.City.list if \ city.Language is not spanish and city.Population.isGraterThan(100)] [City Name:Paris] The problem here is that you are doing all the filtering in Python rather than in the database. Not a big deal in this example, but with a large initial set of records, this is inefficient because you will return many unnecessary records from the database and Python will likely be slower to do the filtering. Well, that depends a lot on the context in which this is executed. If you have many queries similar to your example, before/around this line of code, that may reuse the same objects for other purposes (which is not uncommon) It may in fact be slower to do it your way in many circumstances, because every specialized-query you are making is another round-trip to the database, which would be orders-of-magnitude slower than doing an eager-loading up-front, and filtering in python. Also, you need to keep in mind that this is assuming a long-lasting set of objects that out-live a single transaction-operation. It almost reads like plain English... Beautiful (!) There are differing opinions on this. Some prefer symbols like != and over plain English like is not and isGreaterThan because it is easier to scan the line and quickly discern the comparisons being made. In particular, I would much prefer both typing and reading rather than .isGreaterThan(). You are right - there are different opinions, but the Zen of Python is conclusive. :) Also, there are both performance AND memory benefits to using is not. An object-id check is much faster that an equality check, and having the same object referenced by different names instead of having copies of it that need to be equality-tested, may save tons of memory. But if you insist in using an ugly form, than in my example you may still do that - it would work just as well - while having the same memory-footprint benefits, just not the performance-benefits. :) france.City.where( Language=not(spanish), Population=moreThan(100)) france.City.FilterBy( (City.Languase != spanish) (City.Population 100)) In web2py, you can already do: db.Country(france).City( (db.City.Language != spanish) (db.City.Population 100)).select() So far, for every example you have shown, web2py has fairly similar syntax. But with radically-different semantics (!!!) Sure, we can quibble over which is more beautiful, but I haven't seen anything to justify building a massive ORM. It is not just more beautiful - it is also faster for long-transactions, and takes less memory. Also it results in developer code being much more readable and concise and hence much more maintainable. And the downside of adding an ORM (aside from the time cost of development and maintenance) is that you would then have to learn yet another abstraction and syntax. This doesn't deter people from using SQLA - how do you account for that? Well, if you're actually making such a comparison, you generally would only be interested in ==, not is -- it just so happens that is would
Re: [web2py] Re: web2py doesn't start!
On 3 May 2013, at 7:03 AM, Anthony abasta...@gmail.com wrote: Hmm, not sure what's going on then. My guess is that socket.getaddrinfo is returning an address that's in a non-IP address family. We should probably be filtering on AF_INET and AF_INET6. On Friday, May 3, 2013 9:53:10 AM UTC-4, Nader Emami wrote: I did the second one: python web2py.py. On Friday, May 3, 2013 9:30:01 AM UTC+2, Nader Emami wrote: I would like to use the web2py framework. When I tried to run python web2py, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widget.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widget.py, line 921, in console if not is_loopback_ip_address(ip[4][0])])) File /home/nader/web2py/gluon/utils.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: SQLFORM.grid seems to overwriting an unshown field.
On Saturday, 4 May 2013 00:33:37 UTC+10, Anthony wrote: Hard to say what's going on. Just loading the grid doesn't do any writing to the database, so something else must be happening. Can you produce a minimal app that replicates this behavior with SQLite? Yes, it seems so. At least, when I change the database vci_admin to by sqlite (and allow migration to create the table), I get exactly the same behavior. I use Windows sqlite software navicat to watch the sqlite database, and it's the same. The match_patient controller updates the table, and everytime I dispaly the sqlform.grid, it resets every value in the cm_patient_id column to the default. tomorrow I'll try to make a minimal app. Anthony On Friday, May 3, 2013 10:15:43 AM UTC-4, Tim Richardson wrote: On Friday, 3 May 2013 23:59:51 UTC+10, Anthony wrote: How did the record get created to begin with? Did it start with a cm_patient_id value of 0? Are you sure you committed your change when using the database management tool? This works: I open up the grid in web2py, and click on the button Match Patients which invokes the controller match_patient, allowing me to edit that record. I match the patient, which updates the foreign key cm_patient_id via the requires=IS_IN_DB. The calculated fields works too. So if I go to Management Studio and look at the table, I can see the foreign key (an integer) and the the calculated field (a string). So I'm definitely convinced that the edit of the record in the SQLFORM of match_patient() is committing. Going back to web2py, if I refresh the SQLFORM.grid or enter it again, at that point the table is reset. The foreign key is set to 0, which is the default value, and the calculated field is set to NULL. Other fields are unaffected. Is it a database migration? (migrate = False in the model). The fact the the calculated field is set to NULL is probably not as interesting as the resetting of cm_patient_id. (if I change the table definition in Management Studio so that the default value is 99, then opening the controller which displays the grid puts 99 in every row (inspected via Management Studio) Then I can edit the definition to make the default value 55, refresh the controller and I get 55 in every row. So the grid is wiping out that field and the database replaces it with the default value. I guess there is something wrong with my table definition. This is what I have right now (I've disabled the compute) db_vciadmin = DAL('mssql://tim:xxx@vci-win2003\hcnsql07/vciadmin', lazy_tables=True,pool_size=10) . . . db_vciadmin.define_table(web_form_1te, Field(patient_details_id,'integer',unique=True), Field(date_submitted,date), Field(first_name,string), Field(surname,string), Field(dob,date), #Field(cm_patient_id,reference cm_patient), Field(cm_patient_id,integer), #Field(patient,string, compute=lambda r: patient_name(r['cm_patient_id'])), Field(patient,string), format='%(first_name)s %(surname)s', migrate=False ) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
I actually find that latter easier to process. The parentheses and make it easier to see there are two separate conditions, and the != and are easier to pick out and comprehend than is not and .isGreaterThan(). A non-programmer may have an easier time with the more English-like version (assuming they happen to speak English, of course), but I think it's reasonable to expect even novice programmers to understand the basic boolean operators. Whatever your opinion on the beauty of one over the other, though, surely this doesn't justify the massive undertaking of building an ORM, particularly since you would still have to know and use the underlying DAL syntax in addition anyway. Anthony Again: There are both performance AND memory benefits to using is not. An object-id check is much faster that an equality check, and having the same object referenced by different names instead of having copies of it that need to be equality-tested, may save tons of memory. But if you insist in using an ugly form, than in my example you may still do that - it would work just as well - while having the same memory-footprint benefits, just not the performance-benefits. :) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
I know a lot of people have been burned in production by many ORMs in the past - and those scares are what anyone suggesting an ORM today has to deal with. SQLA is doing a very good job at that - have you seen the videos I posted here? They are talking about Hibernate, as well as the Active-Record pattern. The guy who wrote it has mentioned all of the worries you are talking about in those videos. For example: Eager-vsLazy loading is configurable - both are supported, and you can use each in you core, depending on circumstances. As I said in the previouse message (I updated it since you posted this one). it depends - the trande-offs are circumstancial - that's why you need both approaches, and the ability to concigure each object to use one or the other in different circumstances - and that's what SQLA provides. As for recursive-queries, it does not occur in eager-loading in SQLA. SQLA features what it called a cascade, which means it traverses through the attribute-accesses, and only fetches what you actually asked for (well, it's not really traversing, there are events that are triggered on each object's attribute-access...) this is for both lazy and eager loading configurations. The cascade makes sure that you only get what you explicitly asked for, no more, no less. As for Magic, he is talking about that also. SQLA is not hiding it's internals like many other ORMs are doing - it is highly configurable, with sane-defaults, so you can go as deep as you like and re-configure things the way you like. In fact, this is not only possible, but rather advised explicitly - at some areas it is even mandatory. The explicit-support for configurability comes in the form of tools for automating manual-configuration, through meta-classes and mix-ins. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: web2py doesn't start!
On 3 May 2013, at 7:50 AM, Jonathan Lundell jlund...@pobox.com wrote: On 3 May 2013, at 7:03 AM, Anthony abasta...@gmail.com wrote: Hmm, not sure what's going on then. My guess is that socket.getaddrinfo is returning an address that's in a non-IP address family. We should probably be filtering on AF_INET and AF_INET6. Proposed fix: pass the entire ip tuple (from getaddrinfo) to is_loopback_ip_address, and maybe (for backward compatibility in case any app is using it?) test the type of the argument. Or something. So, change: options.ips = list(set([ ip[4][0] for ip in socket.getaddrinfo(socket.getfqdn(), 0) if not is_loopback_ip_address(ip[4][0])])) to options.ips = list(set([ addrinfo[4][0] for addrinfo in socket.getaddrinfo(socket.getfqdn(), None) if not is_loopback_ip_address(addrinfo=addrinfo)])) and change: def is_loopback_ip_address(ip): Determines whether the IP address appears to be a loopback address. This assumes that the IP is valid. The IPv6 check is limited to '::1'. if not ip: return False if ip.count('.') == 3: # IPv4 return ip.startswith('127') or ip.startswith(':::127') return ip == '::1' # IPv6 to: def is_loopback_ip_address(ip=None, addrinfo=None): Determines whether the address appears to be an IP loopback address. This assumes that the IP is valid. The IPv6 check is limited to '::1'. addrinfo is a tuple from socket.getaddrinfo() if addrinfo and addrinfo[0] == socket.AF_INET or addrinfo[0] == socket.AF_INET6: ip = addrinfo[4] if not ip: return False if ip.count('.') == 3: # IPv4 return ip.startswith('127') or ip.startswith(':::127') return ip == '::1' # IPv6 On Friday, May 3, 2013 9:53:10 AM UTC-4, Nader Emami wrote: I did the second one: python web2py.py. On Friday, May 3, 2013 9:30:01 AM UTC+2, Nader Emami wrote: I would like to use the web2py framework. When I tried to run python web2py, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widget.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widget.py, line 921, in console if not is_loopback_ip_address(ip[4][0])])) File /home/nader/web2py/gluon/utils.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: routes.py
Well, After some tries, I have found a solution : In web2py folder : *routes.py* # -*- coding: utf-8 -*- routes_app = ((r'/(?Pappadmin)\b.*', r'\gapp'), (r'(.*)', r'myApp'), (r'/?(.*)', r'myApp')) In my app folder : *routes.py* # -*- coding: utf-8 -*- routes_in = ( ('/myApp/!$a', '/myApp/pages/show_page/$a'), ('/myApp', '/myApp/default/index'), ('/myApp/images', '/myApp/images/images'), ('/myApp/contact', '/myApp/default/contact_form'), ) routes_out = [(x, y) for (y, x) in routes_in] Everything works fine excepted one thing : an incoming url like *http://www.myapp.com/pages/show_page/foo* is rewrited in *http://www.myapp.com/foo *== that's OK an incoming url like *http://www.myapp.com/pages/show_page/foo-bar* is not rewrited* * it seems that *hyphens *in the last parameter prevents rewriting Any idea why? thank you * * Le vendredi 3 mai 2013 08:42:03 UTC+2, Loïc a écrit : yes default_app is just to allow access to my app at http://127.0.0.1:8000(without specifying an app name) *You probably still need to specify myApp in your routes.* In my app-specific routes;py tried #!/usr/bin/python # -*- coding: utf-8 -*- routes_in = ( ('/myApp/testme', '/myApp/default/index'), ) routes_out = ( ('/myApp/default/index', '/myApp/testme'), ) But when I go on http://127.0.0.1:8000/myApp/testme I still have an error : invalid controller (testme/index) I'm testing on Windows7 pro x64 with default rocket webserver. Could it cause some issues? Thank you Le jeudi 2 mai 2013 16:57:00 UTC+2, Anthony a écrit : I think default_app just tells it where to go if there is no app, controller, or function. You probably still need to specify myApp in your routes. Anthony On Thursday, May 2, 2013 9:54:20 AM UTC-4, Loïc wrote: Thank you anthony for your quick response. I updated *web2py\routes.py* to remain only the following line : # -*- coding: utf-8 -*- default_application = myApp When I open http://127.0.0.1:8000 I am redirected to myApp. So This routes.py file seems to be OK Then, on *web2py\applications\myApp\routes.py* I wrote : routes_in = ( ('/testme', '/myApp/default/index'), ) routes_out = ( ('/myApp/default/index', '/testme'), ) But when I go to http://127.0.0.1:8000/myApp/testme I still have an error invalid controller (testme/index) I have also tested with *web2py\applications\myApp\routes.py* : #!/usr/bin/python # -*- coding: utf-8 -*- routes_in = ( ('/testme', '/default/index'), ) routes_out = ( ('/default/index', '/testme'), ) But I have the same error : invalid controller (testme/index) Le jeudi 2 mai 2013 15:27:50 UTC+2, Anthony a écrit : You cannot combine the parameter-based and pattern-based rewrite systems -- pick one or the other. On Thursday, May 2, 2013 8:29:37 AM UTC-4, Loïc wrote: Hello all, I want to play with URL revrite. So I took the example in the book ( http://web2py.com/books/default/chapter/29/04?search=routes_in#Pattern-based-system ) In the file *web2py\applications\myApp\routes.py* I have : #!/usr/bin/python # -*- coding: utf-8 -*- routes_in = ( ('/testme', '/myApp/default/index'), ) routes_out = ( ('/myApp/default/index', '/testme'), ) In web2py root dir, I also added a routes.py file containing : # -*- coding: utf-8 -*- routers = dict( BASE=dict( default_application='myApp', ), ) I restarted web2py to reload routes, but when I go on http://127.0.0.1:8000/testme or on http://127.0.0.1:8000/myApp/testmeI have an error : invalid function (default/testme) Can somebody explain me what is wrong is my routes.py files? Thank you -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Has anyone given you any Kool-Aid to drink recently? I have no idea what you mean by that... http://en.wikipedia.org/wiki/Drinking_the_Kool-Aid Famous last words. I have no idea what you mean by that either... http://idioms.yourdictionary.com/famous-last-words french = db.Language.insert(Name='French') db.Country(france).City.update(Language=french) Looks a lot like your example (maybe even a bit more explicit about what's going on). It is not more explicit - it has the same level of explicitness of what's going on - just less pluming-level explicitness. More explicit because it makes it clear we are doing an update. But the important distinction is that there is a hidden fundamental difference - in my approach it is actually making object-references (alongside the database insertion) so that can be used further-on in the code, You can save the object and refer to it later in the code in web2py as well. Again, you have to break-away the stateless mind-set and appreciate statefullness. I understand the distinction. You simply haven't yet demonstrated a compelling use case for the latter. This assumes a very different execution-model than what you are used to in web2py. It is something that would happen within a *module*, not within a *controller-action,* so it is saved within the module-object across transactions/requests/sessions. No, in web applications, SQLA sessions last only as long as a single web request -- basically the same as in web2py. [city for city in fance.City.list if \ city.Language is not spanish and city.Population.isGraterThan(100)] [City Name:Paris] The problem here is that you are doing all the filtering in Python rather than in the database. Not a big deal in this example, but with a large initial set of records, this is inefficient because you will return many unnecessary records from the database and Python will likely be slower to do the filtering. Well, that depends a lot on the context in which this is executed. If you have many queries similar to your example, before/around this line of code, that may reuse the same objects for other purposes (which is not uncommon) It may in fact be slower to do it your way in many circumstances, because every specialized-query you are making is another round-trip to the database, which would be orders-of-magnitude slower than doing an eager-loading up-front, and filtering in python. Yes, and in that case, you can do something exactly like your code above in web2py (i.e., filtering in Python) -- so what? Also, you need to keep in mind that this is assuming a long-lasting set of objects that out-live a single transaction-operation. Not typically. In most cases, you will probably have one transaction per request in both SQLA and web2py. Furthermore, even if you have multiple transactions within a request, SQLA will expire the state of any instances whenever a transaction is committed. Also, bare in mind that I am not suggesting to replace the DAL, only to augment it with a statefull layer on-top. Why not augment it with statefulness at the DAL level? Why do you need a layer on top? The benefits/trade-offs are not absolute/constant - they vary circumstantially. Yes, it would help to understand the circumstances in which your preferred features offer substantial benefits. It almost reads like plain English... Beautiful (!) There are differing opinions on this. Some prefer symbols like != and over plain English like is not and isGreaterThan because it is easier to scan the line and quickly discern the comparisons being made. In particular, I would much prefer both typing and reading rather than .isGreaterThan(). You are right - there are different opinions, but the Zen of Python is conclusive. :) Where in the Zen of Python does it say that English words are more beautiful than boolean operators when expressing boolean logic? Also, there are both performance AND memory benefits to using is not. An object-id check is much faster that an equality check, and having the same object referenced by different names instead of having copies of it that need to be equality-tested, may save tons of memory. If you're talking about building queries, your point is moot -- the operations happen in the database, not Python. As for comparisons in Python, in web2py, you wouldn't be testing equality of a whole object/record -- typically it would be a scalar (e.g., the integer ID). And you wouldn't have multiple copies of records in memory either. france.City.where( Language=not(spanish), Population=moreThan(100)) france.City.FilterBy( (City.Languase != spanish) (City.Population 100)) In web2py, you can already do: db.Country(france).City( (db.City.Language != spanish) (db.City.Population 100)).select() So far, for every example you have shown, web2py has fairly
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Sadly, there is NO possible way to archive a pythonic list comprenhension syntax that query the objects in the server side AFAIK Some libraries uses dis (python disassembler) and other internal dirty python hacks to do something similar, please, see: http://www.aminus.net/geniusql/ http://www.aminus.org/blogs/index.php/2008/04/22/linq-in-python?blog=2 http://www.aminus.net/geniusql/chrome/common/doc/trunk/managing.html Note that web2py is much closer to the pythonic expressions, but without the early / late binding and other issues described there ;-) I didn't know about this, but it's not what I meant. It might be a cool concept, but I'm not sure how viable it would be in production. I haven't read everything yet, I'll read it some other time. In my example, there was no magic involved, beyond what I've described: Just to clarify, again, the following syntax: [city for city in fance.City.list if \ city.Language is not spanish and city.Population.isGraterThan(100)] Is not a pie-in-the-sky dream-API - there are implementational details that are viable for each section. First, the reason the is not would work, is that there would exist an implementation of 'Identity Mapping that would take care of having a singleton for each ORM-object representing each row. Second, the access to france.City.list is viable, as an attribute-access is totally customization in python, so we can devise anything we want for the access to do. For example, it could return an iterator, if the City attribute of the france ORM-object is valid (meaning, it is cached and not invalidated by a previous transaction-commit), and do a query right-there on the spot, and return an iterator, if the City attribute of the france ORM-object is invalid at the time of the list attribute access. it was a simple list-comprehension. I assumes the data is there - if it isn't, it goes and fetches it. Here is a quote from one of the comments in your second link, that I really resonate with: I think the distinction between: Customer.select and source.Customers is quite important as the developer may be thinking quite differently in each. In the first, I am thinking that I'm grabbing objects from some store that is linked with the class Customer via an ORM. In the latter, I may think the same way, but I personally like to think of it as I've got this object that has many customers and now I can play with them. That collection may be backed in a database, or it may just be a collection. None of this is not already accomplished either in Python (generators or list comprehensions) or via the many community modules that address object-relational mapping or extend what itertools already gives you. However, what I can't find in Python is a unified API regardless of what the underlying mechanism of keeping my data is. To me, it doesn't matter if I'm calling into a for loop or generating a monster SQL statement. I'd rather write the same code regardless of which of these is going to happen under the hood. As for the performance-issue, I've later said this: Well, that depends a lot on the context in which this is executed. If you have many queries similar to your example, before/around this line of code, that may reuse the same objects for other purposes (which is not uncommon) It may in fact be slower to do it your way in many circumstances, because every specialized-query you are making is another round-trip to the database, which would be orders-of-magnitude slower than doing an eager-loading up-front, and filtering in python. Also, you need to keep in mind that this is assuming a long-lasting set of objects that out-live a single transaction-operation. And this: Eager-vs-Lazy loading is configurable - both are supported, and you can use each in you core, depending on circumstances. As I said in the previouse message (I updated it since you posted this one). it depends - the trande-offs are circumstancial - that's why you need both approaches, and the ability to concigure each object to use one or the other in different circumstances - and that's what SQLA provides. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: routes.py
On 3 May 2013, at 9:02 AM, Loïc loic.esp...@gmail.com wrote: After some tries, I have found a solution : In web2py folder : routes.py # -*- coding: utf-8 -*- routes_app = ((r'/(?Pappadmin)\b.*', r'\gapp'), (r'(.*)', r'myApp'), (r'/?(.*)', r'myApp')) In my app folder : routes.py # -*- coding: utf-8 -*- routes_in = ( ('/myApp/!$a', '/myApp/pages/show_page/$a'), ('/myApp', '/myApp/default/index'), ('/myApp/images', '/myApp/images/images'), ('/myApp/contact', '/myApp/default/contact_form'), ) routes_out = [(x, y) for (y, x) in routes_in] Everything works fine excepted one thing : an incoming url like http://www.myapp.com/pages/show_page/foo is rewrited in http://www.myapp.com/foo == that's OK an incoming url like http://www.myapp.com/pages/show_page/foo-bar is not rewrited it seems that hyphens in the last parameter prevents rewriting Any idea why? $a is a shortcut for ?Pa\w+,, and \w doesn't match hyphens. You'll need to spell out your pattern. What's the ! doing? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
I actually find that latter easier to process. The parentheses and make it easier to see there are two separate conditions, and the != and are easier to pick out and comprehend than is not and .isGreaterThan(). A non-programmer may have an easier time with the more English-like version (assuming they happen to speak English, of course), but I think it's reasonable to expect even novice programmers to understand the basic boolean operators. Whatever your opinion on the beauty of one over the other, though, surely this doesn't justify the massive undertaking of building an ORM, particularly since you would still have to know and use the underlying DAL syntax in addition anyway. Anthony Again: There are both performance AND memory benefits to using is not. An object-id check is much faster that an equality check, and having the same object referenced by different names instead of having copies of it that need to be equality-tested, may save tons of memory. But if you insist in using an ugly form, than in my example you may still do that - it would work just as well - while having the same memory-footprint benefits, just not the performance-benefits. :) OK, then, again: If you're talking about building queries, your point is moot -- the operations happen in the database, not Python. As for comparisons in Python, in web2py, you wouldn't be testing equality of a whole object/record -- typically it would be a scalar (e.g., the integer ID). And you wouldn't have multiple copies of records in memory either. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Eager-vsLazy loading is configurable - both are supported, and you can use each in you core, depending on circumstances. As I said in the previouse message (I updated it since you posted this one). it depends - the trande-offs are circumstancial - that's why you need both approaches, and the ability to concigure each object to use one or the other in different circumstances - and that's what SQLA provides. In web2py, we have lazy loading for individual references and referencing sets, and when that is inefficient, we would just do an explicit join. I think an eager loading option on the individual references would be a cool addition, though that wouldn't require an ORM layer. As for recursive-queries, it does not occur in eager-loading in SQLA. SQLA features what it called a cascade, which means it traverses through the attribute-accesses, and only fetches what you actually asked for (well, it's not really traversing, there are events that are triggered on each object's attribute-access...) this is for both lazy and eager loading configurations. The cascade makes sure that you only get what you explicitly asked for, no more, no less. When you eager load in SQLA, it doesn't know ahead of time what attributes you will access, so it fetches everything (though in just one, or possibly two queries, depending on the eager method used). Lazy loading requires a query for each attribute accessed, just as in web2py. Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: how to display the value of a reference field, instead of the id in sqlform.grid
Hi Anthony, This is seem not work in case self reference. Ex : Field('boss', 'reference auth_user') How can I solve in this situation? Thanks, On Monday, October 8, 2012 9:17:49 AM UTC+7, dave wrote: Thank you very much, I did not see this in the documentation and yes it would be nice if it is consistent with your expectation On Sunday, October 7, 2012 6:25:09 PM UTC-7, Anthony wrote: If you do: Field('test1', 'reference ranking') and then make sure the format attribute of the ranking table is set to '%(name)s', then the test1 field will automatically get the IS_IN_DB validator you have explicitly defined below, and it will automatically get a represent attribute displaying the name value from the ranking table. However, if you explicitly define your own requires attribute, then you don't get the automatic represent attribute, and you have to explicitly define that as well (I think we should probably change this, though). Anthony On Sunday, October 7, 2012 2:44:44 PM UTC-4, dave wrote: auth.settings.extra_fields['auth_user']= [ #Field('name', requires=IS_NOT_EMPTY()), . . . Field('test1', 'reference ranking', requires=IS_IN_DB(db, 'ranking.id' , '%(name)s')), . . . On Sunday, October 7, 2012 7:37:03 AM UTC-7, Anthony wrote: How is your test1 field defined? On Sunday, October 7, 2012 3:26:31 AM UTC-4, dave wrote: grid = SQLFORM.grid(query, args=[request.args(0)], fields=[db.auth_user.test0, db.auth_user.test1, db.auth_user.test2, I have defined this in my controller, the value of test1 is a reference to another table, how would I make web2py show the referenced value instead of displaying the id, something equivalent to Field('field2', 'reference employees', requires=IS_IN_DB(db, 'employees.id', '%(name)s')) when defining the table -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
If you're talking about building queries, your point is moot -- the operations happen in the database, not Python. I don't know what you mean by this... For complex-queries, I would still be using web2py's DAL layer, even if I had this ORM on top. I would either use them outside the ORM, or insert them into the ORM. My example was not meant to show that you should do complex queries in Python - that would obviously be absurd, and you don't even need a relational database for that - any NoSQL one would do fine. I was giving an example to a case in which I have a simple comparison to make, and want to reuse the ORM objects I already have for it. The DAL is not built for that. As for comparisons in Python, in web2py, you wouldn't be testing equality of a whole object/record -- typically it would be a scalar (e.g., the integer ID). That would still be much slower than an equality-test - especially for large data-sets. And you wouldn't have multiple copies of records in memory either. How so? If I do this: row1 = db.Country[1] ... row2 = db.Country[1] Would I then get: row1 is row2 == True ? How about: row1.Name is row2.Name == True ? I would be surprised to find out this is the case... -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Can we disable creation of non-Auth sessions somehow?
On my site, which is not even used by public right now, I get about 1000 sessions in a day created from various bots (google, yandex etc). I use default option of storing sessions in file system. I created a page for admin, on which admin can see all the sessions in a table and manually remove session files which have no Auth clicking a button. I suppose I can create automatic task of deleting such sessions (by the way what will be the best option for that in Windows?). But can I turn off creation of no-Auth sessions in web2py at all? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
In web2py, we have lazy loading for individual references and referencing sets, and when that is inefficient, we would just do an explicit join. I think an eager loading option on the individual references would be a cool addition, though that wouldn't require an ORM layer. We've been though this already, Anthony, Laziness in web2py has a different meaning - it uses the same word, but it means something completely different. For example, you statement: Lazy loading requires a query for each attribute accessed, just as in web2py. Is plain false. There is another mechanism that exists in SQLA that you are not accounting for, and it is statefullness - a caching-mechanism, using the 'Unit of Work' pattern. I don't know how many times and in how many forms I need to say this. In SQLA, using a LazyLoading configuration on an attribute, would mean that on the first time (within a transaction) that your code accesses this attribute, it would issue a query to the database. The Lazyness here is defined in terms of when you FIRST access the attribute, and NOT BEFORE - but as to what happens AFTER that, THEN the caching-mechanism kicks in - if the attribute has not been invalidated within the same transaction, then the LazyLoading is NOT EVEN ACTIVATED (!) You get the value IMMEDIATELY from the attribute-cache. EagerLoading is therefore a way to configure the attribute to be queried from the database EXPLICITLY, but even in THAT case, that would only apply ONCE within a transaction. Every subsequent accesses to that attribute would use the cached-value just as well. As for recursive-queries, it does not occur in eager-loading in SQLA. When you eager load in SQLA, it doesn't know ahead of time what attributes you will access, so it fetches everything (though in just one, or possibly two queries, depending on the eager method used). You are right about that - my mistake - I meant LazyLoading there. But if I understood correctly, than since the Lazynes vs. Eagerness can be configured on a per-attribute basis, you don't necessarily have to load the whole table - you could configure just the fields you want. If you need a complex query for eager-loading, you can simply execute it at the beginning of your transaction - explicitly. You don't even have to store the results anywhere yourself - they are automatically filled-in within their respective attribute-caches across the object-graph. Every access to those attributes thereafter, within the same transaction, would just use those values - regardless of the Lazyness/Eagerness configurations. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
If you're talking about building queries, your point is moot -- the operations happen in the database, not Python. I don't know what you mean by this... For complex-queries, I would still be using web2py's DAL layer, even if I had this ORM on top. I would either use them outside the ORM, or insert them into the ORM. Not sure what you mean here -- you can do simple queries in the db as well as complex filtering in Python -- they are orthogonal considerations. My example was not meant to show that you should do complex queries in Python - that would obviously be absurd, and you don't even need a relational database for that - any NoSQL one would do fine. Now you've really lost me -- what does any of this have to do with RDBMS vs. NoSQL? And why shouldn't you do complex filtering in Python? I was giving an example to a case in which I have a simple comparison to make, and want to reuse the ORM objects I already have for it. The DAL is not built for that. Not sure what you mean. The DAL returns a Rows object. You can filter it with any simple or complex comparison you like. It even has a .find() method to simplify the process: db.Country(france).select().find(lambda r: r.Language != spanish and r. Population 100) As for comparisons in Python, in web2py, you wouldn't be testing equality of a whole object/record -- typically it would be a scalar (e.g., the integer ID). That would still be much slower than an equality-test - especially for large data-sets. OK, please provide some benchmarks. What percentage decrease in CPU usage can we expect if we compare object identities rather than integer equivalencies? And you wouldn't have multiple copies of records in memory either. How so? If I do this: row1 = db.Country[1] ... row2 = db.Country[1] And why are you doing that? Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Limit SQLFORM.grid results
On Monday, April 23, 2012 7:57:23 PM UTC+5:30, Bruce Wade wrote: Yeah see that was my original question how to tell grid to only select/count the first 50,000 records instead of it just generating pages for all the records. I understand that this is an year-old thread - but I too have a requirement to show ONLY X records out of total Y records it would otherwise show across pages. Other thing that might work for me is if there is a way to NOT show the pagination at all. This way I can set paginate=X and since user can't access pagination, it would provide similar result as if SQLFORM.grid limited the number of records displayed to the user. This is useful when you want to show like Top 10 (Or in case of Bruce Above, Top 200 Ads) of some query. -Mandar -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Scheduler - Recurring task but only during certain hours?
Is there any way to setup a recurring task with the built-in scheduler so that it would say run every 10 minutes between just 8am and 6pm? I know that it is easy enough to setup the every 10 minutes part, but it there any way to restrict the time of day too? ~Brian -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: web2py doesn't start!
The output of print socket.getaddrinfo(socket.getfqdn(), 0) is: [(10, 1, 6, '', (10, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (10, 2, 17, '', (10, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (10, 3, 0, '', (10, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 1, 6, '', ('127.0.0.1', 0)), (2, 2, 17, '', ('127.0.0.1', 0)), (2, 3, 0, '', ('127.0.0.1', 0))] On 3 May 2013 16:36, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Can you please run a test for me? python import socket print socket.getaddrinfo(socket.getfqdn(), 0) what's the output? Anyway you can run it with web2py.py --nogui It is failing when making a guess for all your IP addresses. On Friday, 3 May 2013 02:30:01 UTC-5, Nader Emami wrote: I would like to use the web2py framework. When I tried to run *python web2py*, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widg**et.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widg**et.py, line 921, in console if not is_loopback_ip_address(ip[4][0**])])) File /home/nader/web2py/gluon/util**s.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/t_11PX-hYt0/unsubscribe?hl=en. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
In web2py, we have lazy loading for individual references and referencing sets, and when that is inefficient, we would just do an explicit join. I think an eager loading option on the individual references would be a cool addition, though that wouldn't require an ORM layer. We've been though this already, Anthony, Laziness in web2py has a different meaning - it uses the same word, but it means something completely different. I'm not going to repeat what I already said -- please go back and read it earlier in this thread. In my statement above, the term lazy means* exactly* the same thing as it does in SQLA and that you mean when you say it -- the *database query* is deferred until you access the attribute. Lazy loading requires a query for each attribute accessed, just as in web2py. Is plain false. Or, it's plain true. In SQLA, if you specify lazy loading of relationships (which is the default), the query is deferred until the first time you access the attribute, and there is therefore a query for each attribute accessed. This is in contrast to eager loading, which does a single query to populate all attributes (whether or not they are ever accessed). There is another mechanism that exists in SQLA that you are not accounting for, and it is statefullness - a caching-mechanism, using the 'Unit of Work' pattern. I don't know how many times and in how many forms I need to say this. No more times and in no more forms, because nothing I have said has contradicted this. Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Not sure what you mean here -- you can do simple queries in the db as well as complex filtering in Python -- they are orthogonal considerations. I CAN, but I SHOULDN'T want to... RDBMS are built for complex filtering - this is (part) of what SQL is allabout - I wouldn't want to dismiss that - it would be a bad choice all-around. Conversely, simple-filtering is way too verbose using the DAL - it's an overkill for that, and makes the code much less readable. Again, it's a circumstancial-trade-off: For complex filtering, the price of verbosity in using the DAL is worth it, because the performance-benefits are just too high. For simple filtering, well, I'd rather do it in python and get readability, becuase the performance-benefits are negligible. Now you've really lost me -- what does any of this have to do with RDBMS vs. NoSQL? And why shouldn't you do complex filtering in Python? See above. Not sure what you mean. The DAL returns a Rows object. You can filter it with any simple or complex comparison you like. It even has a .find() method to simplify the process: db.Country(france).select().find(lambda r: r.Language != spanish and r. Population 100) That's actully pretty nice - I didn't know I can do that - but what would the france and spanish objects be in this case? Ids? OK, please provide some benchmarks. What percentage decrease in CPU usage can we expect if we compare object identities rather than integer equivalencies? Really? You think I need to? Identity-checking is a built-in and operates within the VM-level. Equality-checks, even for the simplest of objects, are much more complex internally, and are not exclusively operating on the VM-core level - there are object-attributes and value-type-checking involved, etc. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
RDBMS are built for complex filtering - this is (part) of what SQL is allabout - I wouldn't want to dismiss that - it would be a bad choice all-around. A complex filter on a small set of items might be faster in Python than doing another database hit. And a simple filter might belong in the db if it has to go over lots of records. As I said, these are orthogonal considerations. Conversely, simple-filtering is way too verbose using the DAL - it's an overkill for that, and makes the code much less readable. Don't know why you think that. For simple filtering, well, I'd rather do it in python and get readability, becuase the performance-benefits are negligible. But I thought you were a fan of achieving negligible performance benefits at great cost (see below). Now you've really lost me -- what does any of this have to do with RDBMS vs. NoSQL? And why shouldn't you do complex filtering in Python? See above. Still don't know why you would want a NoSQL database or what it has to do with this topic. db.Country(france).select().find(lambda r: r.Language != spanish and r. Population 100) That's actully pretty nice - I didn't know I can do that - but what would the france and spanish objects be in this case? Ids? Well, you've sure made a lot of claims about what web2py needs without knowing much about what it already has. Those are ids. If they were rows, then you would just do france.id and spanish.id. OK, please provide some benchmarks. What percentage decrease in CPU usage can we expect if we compare object identities rather than integer equivalencies? Really? You think I need to? Yes, I think you need to. If this is only going to save a half a second of CPU time per day, I'm not going to build an ORM to get it. The question isn't how much faster the identity check is (and I don't think it's that much faster) -- the question is how much of your overall application CPU time is spent doing this kind of thing? Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: how to display the value of a reference field, instead of the id in sqlform.grid
What doesn't work exactly? With self references, you have to define your own validator and represent attribute because the table doesn't yet exist at the time the Field is created. Anthony On Friday, May 3, 2013 12:22:56 PM UTC-4, Nguyen Minh Tuan wrote: Hi Anthony, This is seem not work in case self reference. Ex : Field('boss', 'reference auth_user') How can I solve in this situation? Thanks, On Monday, October 8, 2012 9:17:49 AM UTC+7, dave wrote: Thank you very much, I did not see this in the documentation and yes it would be nice if it is consistent with your expectation On Sunday, October 7, 2012 6:25:09 PM UTC-7, Anthony wrote: If you do: Field('test1', 'reference ranking') and then make sure the format attribute of the ranking table is set to '%(name)s', then the test1 field will automatically get the IS_IN_DB validator you have explicitly defined below, and it will automatically get a represent attribute displaying the name value from the ranking table. However, if you explicitly define your own requires attribute, then you don't get the automatic represent attribute, and you have to explicitly define that as well (I think we should probably change this, though). Anthony On Sunday, October 7, 2012 2:44:44 PM UTC-4, dave wrote: auth.settings.extra_fields['auth_user']= [ #Field('name', requires=IS_NOT_EMPTY()), . . . Field('test1', 'reference ranking', requires=IS_IN_DB(db, 'ranking.id ', '%(name)s')), . . . On Sunday, October 7, 2012 7:37:03 AM UTC-7, Anthony wrote: How is your test1 field defined? On Sunday, October 7, 2012 3:26:31 AM UTC-4, dave wrote: grid = SQLFORM.grid(query, args=[request.args(0)], fields=[db.auth_user.test0, db.auth_user.test1, db.auth_user.test2, I have defined this in my controller, the value of test1 is a reference to another table, how would I make web2py show the referenced value instead of displaying the id, something equivalent to Field('field2', 'reference employees', requires=IS_IN_DB(db, 'employees.id', '%(name)s')) when defining the table -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Can we disable creation of non-Auth sessions somehow?
If your app code doesn't use the session, then no session file should be created. Probably you have some code that does use the session, such as form processing. Anthony On Friday, May 3, 2013 12:38:50 PM UTC-4, Andriy wrote: On my site, which is not even used by public right now, I get about 1000 sessions in a day created from various bots (google, yandex etc). I use default option of storing sessions in file system. I created a page for admin, on which admin can see all the sessions in a table and manually remove session files which have no Auth clicking a button. I suppose I can create automatic task of deleting such sessions (by the way what will be the best option for that in Windows?). But can I turn off creation of no-Auth sessions in web2py at all? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: web2py doesn't start!
Odd. Looks like misconfigured IPv6. Need to add a check to my patch to check for a string. On May 3, 2013, at 10:02 AM, Nader Emami n.em...@gmail.com wrote: The output of print socket.getaddrinfo(socket.getfqdn(), 0) is: [(10, 1, 6, '', (10, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (10, 2, 17, '', (10, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (10, 3, 0, '', (10, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 1, 6, '', ('127.0.0.1', 0)), (2, 2, 17, '', ('127.0.0.1', 0)), (2, 3, 0, '', ('127.0.0.1', 0))] On 3 May 2013 16:36, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Can you please run a test for me? python import socket print socket.getaddrinfo(socket.getfqdn(), 0) what's the output? Anyway you can run it with web2py.py --nogui It is failing when making a guess for all your IP addresses. On Friday, 3 May 2013 02:30:01 UTC-5, Nader Emami wrote: I would like to use the web2py framework. When I tried to run python web2py, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widget.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widget.py, line 921, in console if not is_loopback_ip_address(ip[4][0])])) File /home/nader/web2py/gluon/utils.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/t_11PX-hYt0/unsubscribe?hl=en. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Or, it's plain true. In SQLA, if you specify lazy loading of relationships (which is the default), the query is deferred until the first time you access the attribute, and there is therefore a query for each attribute accessed. This is in contrast to eager loading, which does a single query to populate all attributes (whether or not they are ever accessed). I was interpreting your statement of every access to mean every time you access the same attribute and not to mean every attribute you access. Anthony, your use of language is sometimes ambiguous - it is not the first time I have misunderstood you - please be more specific next time. 10x :) As for LazyLoading in web2py: We discussed this in the context of virtual-fields, and we've established that Lazyness in that context was NOT a deferred-access to the database, but a deferred-computation of the results within the run-time heap. Are you now referring to Laziness in web2py within a different context? Say, like in: db.Country(france).City.find(...) ? Because I don't understand how you would consider to see that as Lazy - it is implicit, yes, but a Lazy access to the database can only have meaning within the context of a statefull framework. If every query is accessing the database ANYWAYS, then where is the *laziness* in that case? You mean a LazySet ? Like in Recursive-selects? person = db.person(id) for thing in person.thing.select(orderby=db.thing.name): print person.name, 'owns', thing.name Well, again, it IS implicit, but why call it Lazy? The so-called *LazySet* is in person.thing ? If so, than it isn't Lazy, just implicit and that's a bad choice of name - good thing it isn't in the documentation, as it would have generated even more confusion than already exists there... If not, then where is it? The thing.name ? If so, than It may be legitimate to call the person.thing *lazy, *but then I wouldn't want to use it. The way I see it, the only meaning the term Lazy has for accessing-the-database, can exist within a statefull framework - which is, in relation to eager-loading that can only exist there. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Unable to store incremented values in data store as a next record
Hi, I am facing below challenges/ issue: 1. Unable to store incremented start date and related information in a database because of existing functionality/ limitations. For example: if an event start date is 2013-05-01 and end date is 2013-05-04. In this case we need to store: 1. 2013-05-01 2. 2013-05-02 3. 2013-05-03 4. 2013-05-04 We are able to store only 2013-05-01 as start date and 2013-05-04 as end date. Logically, we have incremented and got all related required information and able to see in a program logs but not able store these values in a database -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
A complex filter on a small set of items might be faster in Python than doing another database hit. And a simple filter might belong in the db if it has to go over lots of records. As I said, these are orthogonal considerations. Perhaps, but again, we are talking about a context of a statefull system - we might already have some data on our object-graph - so it's more complicated then that - If we're talking about the first query of a transaction, we need to think about the context of that whole transaction - will we be using all of the fields in the subsequent attribute-accesses? How about the of the records? Do we need all of them for our access-pattern later on? How should we construct our query so it's optimal for re-use of the results in subsequent attribute-accesses of that same transaction? Such considerations do not even exist in a stateless system like web2py's DAL - it doesn't have the same kind of re-usability of returned data. For example - If I am writing a code for a transaction that would later need to do a simple-filter on a large data-set, but that I also know I'm gonna need some of that data, and also some-other related data for some other attribute-access, than I should construct the first query in the transaction so it would do complex filtering, even if I have a large data-set, so I can have the data cached for me, for when I do the simple-filtering of that data in-python afterwards. As for that extra-data-reuse, it might not pertain to all the records I got, but it might do-pertain to more fields than my simple filtering needed. So in that case, I might do the simple-filtering in python, even if a large-data-set is involved, because I am optimizing the number of queries for a wider-context. Conversely, simple-filtering is way too verbose using the DAL - it's an overkill for that, and makes the code much less readable. Don't know why you think that. Because it is. For simple filtering, well, I'd rather do it in python and get readability, becuase the performance-benefits are negligible. But I thought you were a fan of achieving negligible performance benefits at great cost (see below). Now you're being cynical... Still don't know why you would want a NoSQL database or what it has to do with this topic. You're barking on the wrong tree - It does not relate to this discussion, and I didn't say I need a NoSQL database - I don't. I meant it as a hypothetical-alternative to an imaginary scenario of me doing ALL the filtering in python - for THAT I said well I *might-as-well* use NoSql as I would then not muster the benefits of a relational database. It was statement to emphesize why I wouldn't want to do complex filtering in Python in general - obviousely there are edge-cases as you alluded, and then there's the additional complexity of decision-making as I alluded, due to the introduction of statefull-caching/reuse of results. Well, you've sure made a lot of claims about what web2py needs without knowing much about what it already has. Those are ids. If they were rows, then you would just do france.id and spanish.id. I was simply avoiding making assumptions in that example, as there was no context for these variables in it. Yes, I think you need to. If this is only going to save a half a second of CPU time per day, I'm not going to build an ORM to get it. The question isn't how much faster the identity check is (and I don't think it's that much faster) -- the question is how much of your overall application CPU time is spent doing this kind of thing? Fine, don't make the is not usage a reason for an ORM - you may still benefit from an Identity Mapper in an ORM, in terms of memory-efficiency, even if you stick to your ugly !=s and ==s I wouldn't make my decision of having an Identity Mapper only for the usage of is and is not - in fact, it is rarely used even in SQLA - it was just an example of readability that can be harnesses in addition to the memory efficiency that an Identity-Mapper is providing. For benchmarks on THAT, you may look for SQLAlchemy vs DJango if you like... I don't really case much for that - I just know it is obviousely better... -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Scheduler - Recurring task but only during certain hours?
umh. current scheduling allows you to schedule a task from 8 to 10, to make it occur every 10 minutes but it won't start the next day. Let me explain better: you can do start_time = today 8am stop_time = today 6pm period = 600 seconds (10 minutes) but that single record would run only today. So, you have 2 paths to follow: - code your task to return immediatly without doing nothing if request.now is between 6pm and 8am - use another task that will run at, let's say, 2am, to schedule another task for the following day. the first can be something among the lines of def mytask(): if request.now.hour = 18 or request.now.hour = 8: return None do something and then you can just schedule it with repeats = 0 and period = 600 or, the second one, would be something like def schedule_a_day_task(): start_time = request.now.replace(hour=8, minute=0, second=0) stop_time = request.now.replace(hour=18, minute=0, second=0) unique_id = 'my_task_%s' % request.now.date() scheduler.queue_task(the_other_task, [args], {vars}, period=600,start_time =start_time, stop_time=stop_time, uuid=unique_id, repeats=0) db.commit() in this case you'd schedule schedule_a_day_task as start_time = tomorrow at 2am, repeats=0, period = 60*60*24 and you'd be sure that it will take care of queueing every day a task (the_other_task) that does the work between 8am and 6pm. If you have any doubts please ask. On Friday, May 3, 2013 7:01:03 PM UTC+2, Brian M wrote: Is there any way to setup a recurring task with the built-in scheduler so that it would say run every 10 minutes between just 8am and 6pm? I know that it is easy enough to setup the every 10 minutes part, but it there any way to restrict the time of day too? ~Brian -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Hi Arnon, I really don't see that your requirements in this example are not a good for web2py's DAL. I'd really like to understand what, if anything, I'm missing here. I'm originally an RDBMS developer, and what I think of as the set-oriented approach of web2py's DAL is a much better fit for my mental model of what my application is doing. Conversely, I find many ORM solutions (and Active Record, come to that) to be an anti-pattern [1]. FWIW, my data is typically consumed by more than one application (e.g. not just web2py), and I've tended to let web2py create and manage the schema in its own way, and work in the db with views etc. to address more complex or performance-critical functions, so perhaps my concerns are different to yours. However, the examples you give don't seem to take best advantage of the DAL to my eye. Anthony provided some examples as to how one might do that, but you have not responded directly to that post (apologies if I've missed your response if it was elsewhere in the thread). I'd like to take the liberty of quitting Anthony's responses and asking for your take on them. On 02/05/13 22:20, Arnon Marcus wrote: Using the DAL, the best you might get is: [city for city in db.City.Country.select() if city.Country.Name == ''France'] [Row Name:Paris, Row Name:Nice] Anthony's suggestion: - db.Country(name='France').City.select() europe = Continent(Name='Europe') france = Country(Name='France', Continent=europe) paris = City(Name='Paris', Country=france) nice = City(Name='Nice', Country=france) europe.Country(Name='France') is france True france.City(Name='Paris') is paris True europe.Country(Name='France').City.list [City Name:Paris, City Name:Nice] Anthony's suggestion: - europe = db.Continent.insert(Name='Europe') france = db.Country.insert(Name='France', Continent=europe) paris = db.City.insert(Name='Paris', Country=france) nice = db.City.insert(Name='Nice', Country=france) db.Country(france).City.select() [Row Name:Paris, Row Name:Nice] This would be so intuitive and easy to use... Can you expand on this statement and help me understand how this proposed syntax is any more intuitive or simpler than the web2py suggestions, which to my eye are clearer by dint of being more explict? Am I missing something here? [1] http://seldo.com/weblog/2011/08/11/orm_is_an_antipattern -- Regards, PhilK e: p...@xfr.co.uk - m: 07775 796 747 'work as if you lived in the early days of a better nation' - alasdair gray -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: You can chain @make_member_of decorator
this is a nice shortcut that deserves at least a mention in the book ^_^ On Friday, May 3, 2013 4:27:29 PM UTC+2, viniciusban wrote: To make generic query functions truly generic, now you can stack or chain @make_member_of decorator. It's now a slice: http://www.web2pyslices.com/slice/show/1625/turn-a-function-into-a-table-method -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: I just fresh installed web2py on ubuntu 12.04, cannot find modules?
a little correction. serializers.py in trunk now inverts the order of imports it tries simplejson (cause newer versions of simplejson as an external module are always faster than the standard json shipped with python from 2.6 on) then uses json then uses contrib.simplejson However, if you want to be uber-compatible it's best to use always what Alan suggested (using serializers) so you can lean on the smart-import that it does by default. On Friday, May 3, 2013 3:46:32 AM UTC+2, Alan Etkin wrote: Ouch. I must have used old version of web2py than. I always imported simplejson as import simplejson as json I totally forgot to replicate my setup before terminating my linode server. Maybe you had simplejson installed in your old o.s., so you could simply import it directly. You could do this instead: from serializers import json_parser as json It tries json stdlib, then an installed simplejson, and as fallback the module included in contrib. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: web2py doesn't start!
had you already try disable the ipv6 in your network configuration? On Friday, May 3, 2013 1:02:21 PM UTC-4, Nader Emami wrote: The output of print socket.getaddrinfo(socket.getfqdn(), 0) is: [(10, 1, 6, '', (10, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (10, 2, 17, '', (10, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (10, 3, 0, '', (10, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 1, 6, '', ('127.0.0.1', 0)), (2, 2, 17, '', ('127.0.0.1', 0)), (2, 3, 0, '', ('127.0.0.1', 0))] On 3 May 2013 16:36, Massimo Di Pierro massimo@gmail.comjavascript: wrote: Can you please run a test for me? python import socket print socket.getaddrinfo(socket.getfqdn(), 0) what's the output? Anyway you can run it with web2py.py --nogui It is failing when making a guess for all your IP addresses. On Friday, 3 May 2013 02:30:01 UTC-5, Nader Emami wrote: I would like to use the web2py framework. When I tried to run *python web2py*, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widg**et.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widg**et.py, line 921, in console if not is_loopback_ip_address(ip[4][0**])])) File /home/nader/web2py/gluon/util**s.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/t_11PX-hYt0/unsubscribe?hl=en. To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Scheduler - Recurring task but only during certain hours?
whoopsie, a small bugfix of my post (edits in *red italic*) On Friday, May 3, 2013 8:23:00 PM UTC+2, Niphlod wrote: So, you have 2 paths to follow: - code your task to return *immediately* without doing nothing if request.now is between 6pm and 8am - use another task that will run at, let's say, 2am, to schedule another task for the *current* day. in this case you'd schedule schedule_a_day_task as *start_time = today at 8am, stop_time = today at 6pm* repeats=0, period = 60*60*24 and you'd be sure that it will take care of queueing every day a task (the_other_task) that does the work between 8am and 6pm. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Or, it's plain true. In SQLA, if you specify lazy loading of relationships (which is the default), the query is deferred until the first time you access the attribute, and there is therefore a query for each attribute accessed. This is in contrast to eager loading, which does a single query to populate all attributes (whether or not they are ever accessed). I was interpreting your statement of every access to mean every time you access the same attribute and not to mean every attribute you access. I said, Lazy loading requires a query for each attribute accessed That is a fairly precise statement. It is you who made an error. Anthony, your use of language is sometimes ambiguous - it is not the first time I have misunderstood you - please be more specific next time. 10x :) Interesting that you attribute your misunderstandings to my lack of clarity. Is that the only possibility? As for LazyLoading in web2py: We discussed this in the context of virtual-fields, and we've established that Lazyness in that context was NOT a deferred-access to the database, but a deferred-computation of the results within the run-time heap. No, we didn't establish that at all. I refer you to the written record. Are you now referring to Laziness in web2py within a different context? No. Say, like in: db.Country(france).City.find(...) ? Because I don't understand how you would consider to see that as Lazy - That is not proper web2py code, so I don't see it as anything. but a Lazy access to the database can only have meaning within the context of a statefull framework. Nope. In web2py, if a Row object contains a reference attribute, a query is fired when the attribute is accessed, not when the Row object was first created. This is lazy. person = db.person(id) for thing in person.thing.select(orderby=db.thing.name): print person.name, 'owns', thing.name Well, again, it IS implicit, but why call it Lazy? It's actually not even implicit there -- you explicitly call .select(). Anyway, thing is an attribute of the person object, but there is no database query to retrieve the things when the person object is first created -- instead, the query for things is deferred until actually needed. The so-called *LazySet* is in person.thing ? Yes. If so, than it isn't Lazy, just implicit and that's a bad choice of name... Says you. - good thing it isn't in the documentation, as it would have generated even more confusion than already exists there... More confusion among whom? The way I see it, the only meaning the term Lazy has for accessing-the-database, can exist within a statefull framework - which is, in relation to eager-loading that can only exist there. No, web2py could implement eager loading of these Reference and LazySet attributes by doing a single query and filling in all the attributes with the retrieved values. This would be in contrast to the current behavior, which is lazy (i.e., the values are not retrieved when the Row objects are initially created but at some later time upon access/explicit request). Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Conditional Fields in Custom Forms
when you are using custom form, please analyze your output source code first in browser (inspect elements or view source code). after that please add the jquery things based on the row of field you want to have the jquery effect (show or hide) when you use custom form. best regards On Thursday, May 2, 2013 10:48:11 PM UTC-4, Josh Myers wrote: Hey Group, I am new to web2py and I am working to create a custom form from the SQLForm.Factory with a conditional field built in. I have two questions. 1. Using a conditional field based on the checkbox, I can get it to work if I don't use the custom form, but I can't get it to work with the custom form. Below is my code in the view. {{extend 'layout.html'}} {{=form.custom.begin}} b Set Model Options /b div Model Name: {{=form.custom.widget.GAWR_Model_Name}} /div div Sales Set: {{=form.custom.widget.Sales_Set}} /div b Determine the Bandwidth /b script jQuery(document).ready(function(){ jQuery('#no_table_band__row').hide(); jQuery('#no_table_CV').change(function(){ if(jQuery('#no_table_CV').attr('checked')) jQuery('#no_table_band__row').show(); else jQuery('#no_table_band__row').hide();});}); /script div {{=form.custom.widget.CV}} Manually Set the Bandwidth (default is Cross Validation) /div {{=form.custom.submit}} {{=form.custom.end}} 2. I would like to be able to make a conditional field based on something other than a checkbox, like the value of a set of radio buttons, multiple checkboxes, or a standard select dropdown. In the latter case, a User would select a certain value in a dropdown and then another dropdown would appear based on the value the User chose. Can you point me toward any resources on how to do that? Thank you. - Josh -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Let's take a look at identity comparison vs integer comparison... import timeit setup = def isequalItems(itemone, itemtwo): return itemone is itemtwo def isequalInts(itemone, itemtwo): return itemone == itemtwo def testOne(): a = 1 b = 2 isequalItems(a,b) def testTwo(): a = 1 b = 2 isequalInts(a,b) print isequalitems, timeit.timeit(stmt=testOne(), setup=setup, number=1000) print isequalints, timeit.timeit(stmt=testTwo(), setup=setup, number=1000) I get isequalitems 2.77487170111 isequalints 2.73482146489 So, integer comparison is faster. This is with Python 2.7. PyPy 1.9... isequalitems 0.067024457849 isequalints 0.0263884617855 Integer comparison is still faster. On Friday, May 3, 2013 10:36:10 AM UTC-7, Anthony wrote: RDBMS are built for complex filtering - this is (part) of what SQL is allabout - I wouldn't want to dismiss that - it would be a bad choice all-around. A complex filter on a small set of items might be faster in Python than doing another database hit. And a simple filter might belong in the db if it has to go over lots of records. As I said, these are orthogonal considerations. Conversely, simple-filtering is way too verbose using the DAL - it's an overkill for that, and makes the code much less readable. Don't know why you think that. For simple filtering, well, I'd rather do it in python and get readability, becuase the performance-benefits are negligible. But I thought you were a fan of achieving negligible performance benefits at great cost (see below). Now you've really lost me -- what does any of this have to do with RDBMS vs. NoSQL? And why shouldn't you do complex filtering in Python? See above. Still don't know why you would want a NoSQL database or what it has to do with this topic. db.Country(france).select().find(lambda r: r.Language != spanish and r. Population 100) That's actully pretty nice - I didn't know I can do that - but what would the france and spanish objects be in this case? Ids? Well, you've sure made a lot of claims about what web2py needs without knowing much about what it already has. Those are ids. If they were rows, then you would just do france.id and spanish.id. OK, please provide some benchmarks. What percentage decrease in CPU usage can we expect if we compare object identities rather than integer equivalencies? Really? You think I need to? Yes, I think you need to. If this is only going to save a half a second of CPU time per day, I'm not going to build an ORM to get it. The question isn't how much faster the identity check is (and I don't think it's that much faster) -- the question is how much of your overall application CPU time is spent doing this kind of thing? Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: I just fresh installed web2py on ubuntu 12.04, cannot find modules?
Great to know! Thank you On Fri, May 3, 2013 at 1:31 PM, Niphlod niph...@gmail.com wrote: a little correction. serializers.py in trunk now inverts the order of imports it tries simplejson (cause newer versions of simplejson as an external module are always faster than the standard json shipped with python from 2.6 on) then uses json then uses contrib.simplejson However, if you want to be uber-compatible it's best to use always what Alan suggested (using serializers) so you can lean on the smart-import that it does by default. On Friday, May 3, 2013 3:46:32 AM UTC+2, Alan Etkin wrote: Ouch. I must have used old version of web2py than. I always imported simplejson as import simplejson as json I totally forgot to replicate my setup before terminating my linode server. Maybe you had simplejson installed in your old o.s., so you could simply import it directly. You could do this instead: from serializers import json_parser as json It tries json stdlib, then an installed simplejson, and as fallback the module included in contrib. -- --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/qRO3Lzm9hWs/unsubscribe?hl=en. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: scraping utils in controller
Thank you very much. This is helpful! Actually, what I wanna do is 1) read a *tableDATA/table* from a exteranl page and insert it to the database. 2) Using a cron /scheduler to update the database table periodically if the source web page had changed Could you give me a idea how to get going with 1)? Say I have done this: * fetch the rows (tdCONTENT/td) of the table into the elements collection * stripped unwanted parts off and separated the columns Now how do I push into the table? Here's what I plan to do: * create a model corresponding table columns and data (all strings, numbers) * read the data sliced from the elements collection by a for loop and assign it to the database table fields. Would you confirm this approach? Is there a more efficient way? Thank you and kind regards, Timmie Am Freitag, 3. Mai 2013 13:48:14 UTC+2 schrieb Anthony: That same code works in a controller -- it was merely being demonstrated in a shell. Instead of urllib.urlopen, you can now use fetch (which also works on GAE): from gluon.tools import fetch page = TAG(fetch('http://www.web2py.com')) page.elements('div') # gives you a list of all DIV elements in the page (as web2py DIV helper objects) Actually, at the moment, the above will generate an error because apparently there is an unbalanced a tag somewhere on the web2py.compage. Anthony On Friday, May 3, 2013 3:15:55 AM UTC-4, Timmie wrote: Hello, is there an example how to use this: scraping utils https://groups.google.com/forum/?fromgroups=#!topic/web2py/skcc2ql3zOs in a controller? Especially the first lines (fetching the page and getting it into an element) is what I am looking for. The above example is made for the shell access. Thanks and kind regards, Timmie -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
A complex filter on a small set of items might be faster in Python than doing another database hit. And a simple filter might belong in the db if it has to go over lots of records. As I said, these are orthogonal considerations. Perhaps, but again, we are talking about a context of a statefull system - we might already have some data on our object-graph - so it's more complicated then that... No, your statement had nothing to do with any of this. Anyway, sounds like you now agree with me that it depends on the context. - If we're talking about the first query of a transaction, we need to think about the context of that whole transaction - will we be using all of the fields in the subsequent attribute-accesses? How about the of the records? Do we need all of them for our access-pattern later on? How should we construct our query so it's optimal for re-use of the results in subsequent attribute-accesses of that same transaction? Such considerations do not even exist in a stateless system like web2py's DAL - it doesn't have the same kind of re-usability of returned data. I think it would help if you are more precise about what you mean by stateless and stateful (preferably with code examples). I don't see why these considerations would not be applicable to web2py. I also don't know why you say web2py lacks re-usability of returned data. Perhaps you could offer some examples. Conversely, simple-filtering is way too verbose using the DAL - it's an overkill for that, and makes the code much less readable. Don't know why you think that. Because it is. OK, apparently your assertions no longer require arguments and evidence. Perhaps you could have started and ended this entire thread with a much more simple, Hey, could you people please build an ORM, because I have determined that *it is* better. Then we would all know the truth and could get to coding. For simple filtering, well, I'd rather do it in python and get readability, becuase the performance-benefits are negligible. But I thought you were a fan of achieving negligible performance benefits at great cost (see below). Now you're being cynical... A bit sarcastic, but a serious point -- in one breath you claim to care deeply about what is probably a negligible performance benefit, and in the next you are willing to tolerate some inefficiency. It appears you are being disagreeable for the sake of being disagreeable rather than trying to progress the discussion. I meant it as a hypothetical-alternative to an imaginary scenario of me doing ALL the filtering in python - for THAT I said well I * might-as-well* use NoSql OK, got it. Well, you've sure made a lot of claims about what web2py needs without knowing much about what it already has. Those are ids. If they were rows, then you would just do france.id and spanish.id. I was simply avoiding making assumptions in that example, as there was no context for these variables in it. I was referring to the fact that you didn't know about the .find() method. You also didn't seem to know much about recursive selects, virtual and method fields, etc. you may still benefit from an Identity Mapper in an ORM, in terms of memory-efficiency Why do you need an ORM to have an identity mapper? And how much benefit are you expecting here? Do you have an example of where this would create big savings? even if you stick to your ugly !=s and ==s Ouch, you better tell Guido to change the equals and not equals operators in Python. I wouldn't make my decision of having an Identity Mapper only for the usage of is and is not - in fact, it is rarely used even in SQLA What do you mean? Since != and == are so obviously ugly, aren't all the SQLA users doing is and is not everywhere, you know, because they can? - it was just an example of readability that can be harnesses is not is very readable within English prose, but it is not more readable in code (though it can be fairly readable with proper syntax highlighting). Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
OK, Arnon, now you have to change all your SQLA code to compare id's instead of objects. Bummer. On Friday, May 3, 2013 3:24:22 PM UTC-4, Derek wrote: Let's take a look at identity comparison vs integer comparison... import timeit setup = def isequalItems(itemone, itemtwo): return itemone is itemtwo def isequalInts(itemone, itemtwo): return itemone == itemtwo def testOne(): a = 1 b = 2 isequalItems(a,b) def testTwo(): a = 1 b = 2 isequalInts(a,b) print isequalitems, timeit.timeit(stmt=testOne(), setup=setup, number=1000) print isequalints, timeit.timeit(stmt=testTwo(), setup=setup, number=1000) I get isequalitems 2.77487170111 isequalints 2.73482146489 So, integer comparison is faster. This is with Python 2.7. PyPy 1.9... isequalitems 0.067024457849 isequalints 0.0263884617855 Integer comparison is still faster. On Friday, May 3, 2013 10:36:10 AM UTC-7, Anthony wrote: RDBMS are built for complex filtering - this is (part) of what SQL is allabout - I wouldn't want to dismiss that - it would be a bad choice all-around. A complex filter on a small set of items might be faster in Python than doing another database hit. And a simple filter might belong in the db if it has to go over lots of records. As I said, these are orthogonal considerations. Conversely, simple-filtering is way too verbose using the DAL - it's an overkill for that, and makes the code much less readable. Don't know why you think that. For simple filtering, well, I'd rather do it in python and get readability, becuase the performance-benefits are negligible. But I thought you were a fan of achieving negligible performance benefits at great cost (see below). Now you've really lost me -- what does any of this have to do with RDBMS vs. NoSQL? And why shouldn't you do complex filtering in Python? See above. Still don't know why you would want a NoSQL database or what it has to do with this topic. db.Country(france).select().find(lambda r: r.Language != spanish and r. Population 100) That's actully pretty nice - I didn't know I can do that - but what would the france and spanish objects be in this case? Ids? Well, you've sure made a lot of claims about what web2py needs without knowing much about what it already has. Those are ids. If they were rows, then you would just do france.id and spanish.id. OK, please provide some benchmarks. What percentage decrease in CPU usage can we expect if we compare object identities rather than integer equivalencies? Really? You think I need to? Yes, I think you need to. If this is only going to save a half a second of CPU time per day, I'm not going to build an ORM to get it. The question isn't how much faster the identity check is (and I don't think it's that much faster) -- the question is how much of your overall application CPU time is spent doing this kind of thing? Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Graphs
Dear. I am trying to make a graph temperature vs time with NVD3.js But it's my first experience with D3 and JsON and i think i am wrong because i can't show graphic. I am getting data from a database: My controller: def grafico_temp(): rows=db(db.temperaturas).select(db.temperaturas.fecha,db.temperaturas.temp).as_list() return dict(rows=rows) My view: {{extend 'layout.html'}} link href=https://raw.github.com/novus/nvd3/master/src/nv.d3.css; rel=stylesheet/ script type=text/javascript src=https://raw.github.com/novus/nvd3/master/lib/d3.v2.min.js;/script script type=text/javascript src=https://raw.github.com/novus/nvd3/master/nv.d3.min.js;/script style #chart svg { height: 400px; } /style div id=chart svg/svg /div script type=text/javascript nv.addGraph(function() { var chart = nv.models.lineChart(); chart.xAxis .axisLabel('Fecha') .tickFormat(d3.format(',r')); chart.yAxis .axisLabel('Temperatura') .tickFormat(d3.format('.02f')); d3.select('#chart svg') .datum(data()) .transition().duration(500) .call(chart); nv.utils.windowResize(function() { d3.select('#chart svg').call(chart) }); return chart; }); function data() { var camara1 = {{=response.json(rows)}} //[]; //var t = {{=len(rows)}}; //{{for r in rows:}} // var f = {{r.fecha}}, t = {{r.temp}}; //for (var i = 0; i = t; i++) { // camara1.push({x: f, y: t}); //cos.push({x: i, y: .5 * Math.cos(i/10)}); //{{pass}} } return [ { values: camara1, key: 'Camara 1' color: '#ff7f0e' }, ]; } /script I appreciated you help. --- On Thu, 8/16/12, Andrew awillima...@gmail.com wrote: From: Andrew awillima...@gmail.com Subject: Re: [web2py] Graphs To: web2py@googlegroups.com Date: Thursday, August 16, 2012, 7:41 AM I plan to do one, but you simply provide a json or csv service / URL with web2py, and then use it in a view with the d3 JavaScript code. D3 takes some learning, and I still have a long way to go. -- -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Conditional Fields in Custom Forms
Assuming you are using the default SQLFORM formstyle, which is table. Use Firebug or similar to look at the id SQLFORM assigns to the table rows and table cells. Also look at the class SQLFORM assigns to the table, table rows and table cells. You will notice a pattern. Set up your custom form to follow the same pattern and the javascript that works on the SQLFORM should also work on your custom form. I recommend Firebug because it's easier to see the patterns than looking at the source code. On Thursday, May 2, 2013 10:48:11 PM UTC-4, Josh Myers wrote: Hey Group, I am new to web2py and I am working to create a custom form from the SQLForm.Factory with a conditional field built in. I have two questions. 1. Using a conditional field based on the checkbox, I can get it to work if I don't use the custom form, but I can't get it to work with the custom form. Below is my code in the view. {{extend 'layout.html'}} {{=form.custom.begin}} b Set Model Options /b div Model Name: {{=form.custom.widget.GAWR_Model_Name}} /div div Sales Set: {{=form.custom.widget.Sales_Set}} /div b Determine the Bandwidth /b script jQuery(document).ready(function(){ jQuery('#no_table_band__row').hide(); jQuery('#no_table_CV').change(function(){ if(jQuery('#no_table_CV').attr('checked')) jQuery('#no_table_band__row').show(); else jQuery('#no_table_band__row').hide();});}); /script div {{=form.custom.widget.CV}} Manually Set the Bandwidth (default is Cross Validation) /div {{=form.custom.submit}} {{=form.custom.end}} 2. I would like to be able to make a conditional field based on something other than a checkbox, like the value of a set of radio buttons, multiple checkboxes, or a standard select dropdown. In the latter case, a User would select a certain value in a dropdown and then another dropdown would appear based on the value the User chose. Can you point me toward any resources on how to do that? Thank you. - Josh -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: scraping utils in controller
I think that sounds reasonable. On Friday, May 3, 2013 3:50:29 PM UTC-4, Timmie wrote: Thank you very much. This is helpful! Actually, what I wanna do is 1) read a *tableDATA/table* from a exteranl page and insert it to the database. 2) Using a cron /scheduler to update the database table periodically if the source web page had changed Could you give me a idea how to get going with 1)? Say I have done this: * fetch the rows (tdCONTENT/td) of the table into the elements collection * stripped unwanted parts off and separated the columns Now how do I push into the table? Here's what I plan to do: * create a model corresponding table columns and data (all strings, numbers) * read the data sliced from the elements collection by a for loop and assign it to the database table fields. Would you confirm this approach? Is there a more efficient way? Thank you and kind regards, Timmie Am Freitag, 3. Mai 2013 13:48:14 UTC+2 schrieb Anthony: That same code works in a controller -- it was merely being demonstrated in a shell. Instead of urllib.urlopen, you can now use fetch (which also works on GAE): from gluon.tools import fetch page = TAG(fetch('http://www.web2py.com')) page.elements('div') # gives you a list of all DIV elements in the page (as web2py DIV helper objects) Actually, at the moment, the above will generate an error because apparently there is an unbalanced a tag somewhere on the web2py.compage. Anthony On Friday, May 3, 2013 3:15:55 AM UTC-4, Timmie wrote: Hello, is there an example how to use this: scraping utils https://groups.google.com/forum/?fromgroups=#!topic/web2py/skcc2ql3zOs in a controller? Especially the first lines (fetching the page and getting it into an element) is what I am looking for. The above example is made for the shell access. Thanks and kind regards, Timmie -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: web2py doesn't start!
No! Because I don't know how I can do it. Cheers! On 3 May 2013 20:53, 黄祥 steve.van.chris...@gmail.com wrote: had you already try disable the ipv6 in your network configuration? On Friday, May 3, 2013 1:02:21 PM UTC-4, Nader Emami wrote: The output of print socket.getaddrinfo(**socket.getfqdn(), 0) is: [(10, 1, 6, '', (10, '\x00\x00\x00\x00\x00\x00\x00\** x00\x00\x00\x00\x00\x00\x00'))**, (10, 2, 17, '', (10, '\x00\x00\x00\x00\x00\x00\x00\**x00\x00\x00\x00\x00\x00\x00'))**, (10, 3, 0, '', (10, '\x00\x00\x00\x00\x00\x00\x00\** x00\x00\x00\x00\x00\x00\x00'))**, (2, 1, 6, '', ('127.0.0.1', 0)), (2, 2, 17, '', ('127.0.0.1', 0)), (2, 3, 0, '', ('127.0.0.1', 0))] On 3 May 2013 16:36, Massimo Di Pierro massimo@gmail.com wrote: Can you please run a test for me? python import socket print socket.getaddrinfo(**socket.getfqdn(), 0) what's the output? Anyway you can run it with web2py.py --nogui It is failing when making a guess for all your IP addresses. On Friday, 3 May 2013 02:30:01 UTC-5, Nader Emami wrote: I would like to use the web2py framework. When I tried to run *python web2py*, I got the next error: Traceback (most recent call last): File web2py.py, line 27, in module gluon.widget.start(cron=True) File /home/nader/web2py/gluon/widget.py, line 1054, in start (options, args) = console() File /home/nader/web2py/gluon/widget.py, line 921, in console if not is_loopback_ip_address(ip[4][0])])) File /home/nader/web2py/gluon/utils.py, line 306, in is_loopback_ip_address if ip.count('.') == 3: # IPv4 AttributeError: 'int' object has no attribute 'count' Would somebody help me to solve this problem? Best regards, Nader -- --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/** topic/web2py/t_11PX-hYt0/**unsubscribe?hl=enhttps://groups.google.com/d/topic/web2py/t_11PX-hYt0/unsubscribe?hl=en . To unsubscribe from this group and all its topics, send an email to web2py+un...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- Nader -- --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/t_11PX-hYt0/unsubscribe?hl=en. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Nader -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Scheduler - Recurring task but only during certain hours?
Thanks Niphlod! I've been doing the first option - just having the task's first step be to check the time and quick return if it is outside of the desired time of day, but that seemed inelegant since it's then hard-coded and more of a hassle to maintain. Maybe I'll have to try out option #2. On Friday, May 3, 2013 1:54:40 PM UTC-5, Niphlod wrote: whoopsie, a small bugfix of my post (edits in *red italic*) On Friday, May 3, 2013 8:23:00 PM UTC+2, Niphlod wrote: So, you have 2 paths to follow: - code your task to return *immediately* without doing nothing if request.now is between 6pm and 8am - use another task that will run at, let's say, 2am, to schedule another task for the *current* day. in this case you'd schedule schedule_a_day_task as *start_time = today at 8am, stop_time = today at 6pm* repeats=0, period = 60*60*24 and you'd be sure that it will take care of queueing every day a task (the_other_task) that does the work between 8am and 6pm. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] mobile menu links won't work. %3Ca%20href=
Hi, I just discovered the my menu links don't work when one uses a mobile device. they work fine with firefox chrome (I haven't tested all the other browsers but I guess they work perfectly as well). but once the user agent is mobile and the menue changes to one big drop down menu all links direct you to url/%3Ca%20href= which gives you a bad request as expected. Any ideas why this could be the case. And the entries in the menu look funny too for example: Start Here is one line of my menu.py file: response.menu = [ ('', False,A('Start',_href=URL('default','index'),_title=Back to the main page), []),... -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: You can chain @make_member_of decorator
Very cool. On Friday, May 3, 2013 10:27:29 AM UTC-4, viniciusban wrote: To make generic query functions truly generic, now you can stack or chain @make_member_of decorator. It's now a slice: http://www.web2pyslices.com/slice/show/1625/turn-a-function-into-a-table-method -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Well, no, since as I said, SQLA's Identity Map is actually equating the primary-keys of the object, so I guess they got it right! :P Anyway, I haven't seen this identity-checking actually being used in SQLA code-examples, it was just a side-benefit I though could be cool that you could do that, to make code more readable. It IS weird thought that it's slower - quite surprising. Still, it's not THAT much slower, so if it was me I would still be using identity-checks - you are talking about a difference of 0.01% - whose meddling in negligible stuff now...? :P -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: routes.py
The '!' character comes from the following thread : https://groups.google.com/forum/?fromgroups=#!searchin/web2py/routes_in$20massimo$20%22!$24a%22/web2py/WLEtec0asUc/PfT9pAlMv5QJ In this thread, Massimo said : *You need the ! or some other id to prevent conflits with admin and other internal URLs* But I tried without '!' and it seems to work fine... Finally I updated my routes.py to : # -*- coding: utf-8 -*- routes_in = ( (r'/myapp', r'/myapp/default/index'), (r'/myapp/images', r'/myapp/images/images'), (r'/myapp/contact', r'/myapp/default/contact_form'), (r'/myapp/(?Purl[\w_.-]+)', r'/myapp/pages/show_page/\gurl'), ) routes_out = [(x, y) for (y, x) in routes_in[:-1:]] routes_out += [ (r'/myapp/pages/show_page/(?Purl[\w_.-]+)', r'/myapp/\gurl'), ] And everything seems to works as expected Thank you very much Jonathan Le vendredi 3 mai 2013 18:12:47 UTC+2, Jonathan Lundell a écrit : On 3 May 2013, at 9:02 AM, Loïc loic@gmail.com javascript: wrote: After some tries, I have found a solution : In web2py folder : *routes.py* # -*- coding: utf-8 -*- routes_app = ((r'/(?Pappadmin)\b.*', r'\gapp'), (r'(.*)', r'myApp'), (r'/?(.*)', r'myApp')) In my app folder : *routes.py* # -*- coding: utf-8 -*- routes_in = ( ('/myApp/!$a', '/myApp/pages/show_page/$a'), ('/myApp', '/myApp/default/index'), ('/myApp/images', '/myApp/images/images'), ('/myApp/contact', '/myApp/default/contact_form'), ) routes_out = [(x, y) for (y, x) in routes_in] Everything works fine excepted one thing : an incoming url like *http://www.myapp.com/pages/show_page/foo* is rewrited in *http://www.myapp.com/foo *== that's OK an incoming url like *http://www.myapp.com/pages/show_page/foo-bar* is not rewrited* * it seems that *hyphens *in the last parameter prevents rewriting Any idea why? $a is a shortcut for ?Pa\w+,, and \w doesn't match hyphens. You'll need to spell out your pattern. What's the ! doing? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
For me it has been very worthwhile to learn the DAL because it abstracts away most of the problems of switching databases. However, I believe it is still of fundamental importance that we can see how it maps into SQL. The idea of adding an ORM on top of DAL is one abstraction too far for me. My experience is that the further your data travels from home (the DB) the more difficult it is to manage. It somehow reminds me of taking the plates off the table and spinning them on sticks. It looks spectacular and clever at first, but of course the smallest problem makes them all crash. I believe that this link summarises many of my thoughts in a nice readable way: http://seldo.com/weblog/2011/06/15/orm_is_an_antipattern -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
Well, no, since as I said, SQLA's Identity Map is actually equating the primary-keys of the object, so I guess they got it right! :P Wasn't saying the SQLA ORM code needs to be changed -- I was talking about your application code comparing object identities rather than comparing primary keys. And of course, it was a joke. whose meddling in negligible stuff now...? :P See http://www.thefreedictionary.com/sense+of+humor. Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: SQLFORM.grid seems to overwriting an unshown field.
Solved. My bug. Process of recreating a minimal app revealed that the code which fetches data from a webservice was not doing what I thought. Thanks. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: mobile menu links won't work. %3Ca%20href=
Please open a ticket about this. On Friday, 3 May 2013 15:43:29 UTC-5, BlueShadow wrote: Hi, I just discovered the my menu links don't work when one uses a mobile device. they work fine with firefox chrome (I haven't tested all the other browsers but I guess they work perfectly as well). but once the user agent is mobile and the menue changes to one big drop down menu all links direct you to url/%3Ca%20href= which gives you a bad request as expected. Any ideas why this could be the case. And the entries in the menu look funny too for example: Start Here is one line of my menu.py file: response.menu = [ ('', False,A('Start',_href=URL('default','index'),_title=Back to the main page), []),... -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: You can chain @make_member_of decorator
Nice! This should be added to web2py. I can to it sunday. I will open a ticket meanwhile. On Friday, 3 May 2013 09:27:29 UTC-5, viniciusban wrote: To make generic query functions truly generic, now you can stack or chain @make_member_of decorator. It's now a slice: http://www.web2pyslices.com/slice/show/1625/turn-a-function-into-a-table-method -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Graphs
In your javascript console type d3 Do you get something? Try this download d3 and nvd3 files to your app static folder. then change your code to this {{response.files.extend([URL('static','js/d3.v2.js')])}} {{extend 'layout.html'}} 2013/5/3 FERNANDO VILLARROEL fvillarr...@yahoo.com Dear. I am trying to make a graph temperature vs time with NVD3.js But it's my first experience with D3 and JsON and i think i am wrong because i can't show graphic. I am getting data from a database: My controller: def grafico_temp(): rows=db(db.temperaturas).select(db.temperaturas.fecha,db.temperaturas.temp).as_list() return dict(rows=rows) My view: {{extend 'layout.html'}} link href=https://raw.github.com/novus/nvd3/master/src/nv.d3.css; rel=stylesheet/ script type=text/javascript src= https://raw.github.com/novus/nvd3/master/lib/d3.v2.min.js;/script script type=text/javascript src= https://raw.github.com/novus/nvd3/master/nv.d3.min.js;/script style #chart svg { height: 400px; } /style div id=chart svg/svg /div script type=text/javascript nv.addGraph(function() { var chart = nv.models.lineChart(); chart.xAxis .axisLabel('Fecha') .tickFormat(d3.format(',r')); chart.yAxis .axisLabel('Temperatura') .tickFormat(d3.format('.02f')); d3.select('#chart svg') .datum(data()) .transition().duration(500) .call(chart); nv.utils.windowResize(function() { d3.select('#chart svg').call(chart) }); return chart; }); function data() { var camara1 = {{=response.json(rows)}} //[]; //var t = {{=len(rows)}}; //{{for r in rows:}} // var f = {{r.fecha}}, t = {{r.temp}}; //for (var i = 0; i = t; i++) { // camara1.push({x: f, y: t}); //cos.push({x: i, y: .5 * Math.cos(i/10)}); //{{pass}} } return [ { values: camara1, key: 'Camara 1' color: '#ff7f0e' }, ]; } /script I appreciated you help. --- On Thu, 8/16/12, Andrew awillima...@gmail.com wrote: From: Andrew awillima...@gmail.com Subject: Re: [web2py] Graphs To: web2py@googlegroups.com Date: Thursday, August 16, 2012, 7:41 AM I plan to do one, but you simply provide a json or csv service / URL with web2py, and then use it in a view with the d3 JavaScript code. D3 takes some learning, and I still have a long way to go. -- -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
It may be 0.01% difference on Python 2.7, but on PyPy, that's a 3x difference in speed there! On Friday, May 3, 2013 2:02:24 PM UTC-7, Arnon Marcus wrote: Well, no, since as I said, SQLA's Identity Map is actually equating the primary-keys of the object, so I guess they got it right! :P Anyway, I haven't seen this identity-checking actually being used in SQLA code-examples, it was just a side-benefit I though could be cool that you could do that, to make code more readable. It IS weird thought that it's slower - quite surprising. Still, it's not THAT much slower, so if it was me I would still be using identity-checks - you are talking about a difference of 0.01% - whose meddling in negligible stuff now...? :P -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
On 02/05/13 22:20, Arnon Marcus wrote: Using the DAL, the best you might get is: [city for city in db.City.Country.select() if city.Country.Name == ''France'] [Row Name:Paris, Row Name:Nice] Anthony's suggestion: - db.Country(name='France').City.select() It is a comparison between 2 options to do the same thing in web2py, not a comparison between a web2py way of doing it, vs. my suggested-API's way of doing it. Yes, Anthony is right - there is a better-looking way of doing that compared to what I thought would be the best you could get from the DAL. But it is not a testament to web2py's superioriy/equivalence to my suggestions (only to my poof familiarity with some web2py DAL usages), as there is none in that case. If you would construct an equivalence in my suggestion in this case, it would look like this: Country(name='France').City.list vs. db.Country(name='France').City.select() Now, there are syntactic as well as semantic differences here. Syntactically is it shorted and more concise. Semantically, it returns very different kinds of objects. They both may represent rows in the the same table in the database, but they would be fundamentally diffenet in their utility - which would be a function of their API-context. A sequence of ORM objects is no the same thing as a ROWS object - they differ less in what they contain, and more with what you can do with them. The exact same difference goes for the second comparison: europe = Continent(Name='Europe') france = Country(Name='France', Continent=europe) paris = City(Name='Paris', Country=france) nice = City(Name='Nice', Country=france) europe.Country(Name='France') is france True france.City(Name='Paris') is paris True europe.Country(Name='France').City.list [City Name:Paris, City Name:Nice] Anthony's suggestion: - europe = db.Continent.insert(Name='Europe') france = db.Country.insert(Name='France', Continent=europe) paris = db.City.insert(Name='Paris', Country=france) nice = db.City.insert(Name='Nice', Country=france) db.Country(france).City.select() [Row Name:Paris, Row Name:Nice] In my suggestions, you get an ORM instance, which can do more things. In the first example, you get a Rows object, and in the second you get an ID. Granted, you could use the ID in a DAL context, in a similar way that you would use an ORM-class-instance within the ORM context, but there are other things that an ORM-object can do within an ORM context (aside from these examples), that an ID or a Rows object can not do in the DAL context. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: web2py doesn't start!
I think you need to edit /etc/modprobe.d/modprobe.conf and /etc/modprobe.d/aliases.conf. In the files I found out this: *Code:* # Uncomment the network protocols you don't want loaded: # alias net-pf-2 off# IPv4 alias net-pf-10 off # IPv6 after that please restart your network service and run python web2py.py again not tested, because i'm don't have gentoo machine, hope this can help ref: http://forums.gentoo.org/viewtopic-t-880109-view-next.html?sid=690f3daa672e303e6c7588a3b6b1591d -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal
I would just add that I often do:: City = db.define_table('City', Field('Name', 'string'), Field('Country', db.Country)) paris = City.insert(Name='Paris', Country=france) apart for the .insert this is the same as what Arnon suggests. The lack of .insert in ORMs: paris = City(Name='Paris', Country=france) make the time when the data is actually stored in the database undefined (deferred). This is why Django and Active Records need a City.save(). The developer loses controls about it and then the internal consistency problem arises. When some people like about ORMs is also their most criticized feature: You do not know when they do DB IO. In web2py DAL we managed to achieve a notation that is very similar to ORMs while preserving the 1-to-1 mapping from API and SQL. We may extend this but I would not want to lose this explicit mapping. In fact in web2py DAL insert, delete, update, selet are the only methods (apart for auxiliar ones like record_update, record_update, tables, files). Almost everything else is achieved by operator overloading. On Thursday, 2 May 2013 18:14:17 UTC-5, Anthony wrote: db.define_table('Continent', Field('Name', 'string')) db.define_table('Country', Field('Name', 'string'), Field('Continent', db.Continent)) db.define_table('City', Field('Name', 'string'), Field('Country', db. Country)) Using an ORM, you could do something like: Country(Name='France').City.list [City Name:Paris, City Name:Nice] Using the DAL, the best you might get is: [city for city in db.City.Country.select() if city.Country.Name == ''France'] [Row Name:Paris, Row Name:Nice] Actually, you can do this with the DAL: db.Country(name='France').City.select() Almost identical to your ORM code (not that I think it needs to be similar looking code to be useful). europe = Continent(Name='Europe') france = Country(Name='France', Continent=europe) paris = City(Name='Paris', Country=france) nice = City(Name='Nice', Country=france) europe.Country(Name='France').City.list [City Name:Paris, City Name:Nice] In the DAL, you can do (I think I got this right): europe = db.Continent.insert(Name='Europe') france = db.Country.insert(Name='France', Continent=europe) paris = db.City.insert(Name='Paris', Country=france) nice = db.City.insert(Name='Nice', Country=france) db.Country(france).City.select() [Row Name:Paris, Row Name:Nice] Of course, you don't get the is equivalencies, but your example doesn't actually require that. Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.