[web2py] Re: Checking if db query was successful

2013-06-04 Thread Anthony
db(q1&q2).select().first() will return None if no records are returned, so you should be able to do: if selected_record: [code to execute when a record is returned] If that's not working, let's see some more code. Anthony On Tuesday, June 4, 2013 7:43:27 PM UTC-4, Jordan Ladora wrote: > >

[web2py] Re: [newbie] example authorization

2013-06-04 Thread Anthony
You didn't update the action of the login form, so it's trying to post to the URL of the page it is on. Should be: auth.login().update(_action=URL('default', 'user', args='login'), ...) or whatever your login URL is. Anthony On Tuesday, June 4, 2013 6:33:28 PM UTC-4, lesssugar wrote: > > OK, I

[web2py] Re: Custom reset-password email message, with username- Plain text, not html

2013-06-04 Thread Massimo Di Pierro
Or replace db.auth_user.username with db.auth_user.username.name On Tuesday, 4 June 2013 22:01:28 UTC-5, Rob_McC wrote: > > Hey.. > > I want to customize the reset-password message, to in include the username, > > > I get this error: > > cannot concatenate 'str' and 'Field' objects > > What am

[web2py] Re: Custom reset-password email message, with username- Plain text, not html

2013-06-04 Thread Massimo Di Pierro
replace auth.messages.reset_password = 'Hey ' + db.auth_user.username + ' click on the link ...' with auth.messages.reset_password = 'Hey %s click on the link ...' % db. auth_user.username On Tuesday, 4 June 2013 22:01:28 UTC-5, Rob_McC wrote: > > Hey.. > > I want to customize the reset-pa

[web2py] Re: css help

2013-06-04 Thread Massimo Di Pierro
Thank you Paolo! On Tuesday, 4 June 2013 19:14:18 UTC-5, Paolo Caruccio wrote: > > In order to eliminate the issue under point 1, we could modify slightly > the interested code in layout.html in: > > > > > > > {{if response.title is not None

[web2py] Re: web2py 2.4.7 is Out

2013-06-04 Thread Massimo Di Pierro
Let me know if you can isolate the reason for your memory leak. There are two known potential causes for leaks. 1) you use cache too much in ram without clearing the cache; 2) you create instances of objects with a __del__ method (this may create circular references which cannot be garbage coll

[web2py] Custom reset-password email message, with username- Plain text, not html

2013-06-04 Thread Rob_McC
Hey.. I want to customize the reset-password message, to in include the username, I get this error: cannot concatenate 'str' and 'Field' objects What am I missing? File: db.py auth.messages.reset_password = 'Hey ' + db.auth_user.username + ' click on the link http://'+request.env.http_

[web2py] Re: what is step to access to MSSQL

2013-06-04 Thread Jose
El martes, 4 de junio de 2013 18:01:13 UTC-3, Nam Soo In escribió: > > I am trying to access remote mssql > My working env is ubuntu and mssql 2008 > Do I need any additional installs? > Thank you. > > connection: DAL -> pyodbc -> unixODBC -> FreeTDS -> SQLServer José -- --- You received t

[web2py] Re: previous url

2013-06-04 Thread Jose
Thanks Niphlod,Anthony was written this way: def previous_url(): from collections import deque if session.previous_url is None: session.previous_url = deque([request.url, request.url], maxlen=2) if session.previous_url[1] != request.url: session.previous_url.app

[web2py] Re: css help

2013-06-04 Thread Paolo Caruccio
In order to eliminate the issue under point 1, we could modify slightly the interested code in layout.html in: {{if response.title is not None:}} {{=response.title}} {{=response.subtitle or ''}}{{pass}

[web2py] Re: web2py Safety discussion

2013-06-04 Thread Limedrop
I have often wondered if changing the names "admin" and "appadmin" would be an easy and simple way to add another layer of security? In other words, add these as command-line arguments that can be set on startup? In this way www.mysite.com/admin could be changed to something like www.mysite.c

[web2py] Checking if db query was successful

2013-06-04 Thread Jordan Ladora
Hi, If I set up a query like so, q1 = auth.accessible_query('read', db.stuff) q2 = db.stuff.id==3 selected_record = db(q1&q2).select().first() # how to check if this successfully got db record? selected_records = db(q1&q2).select()# how to check if this successfu

[web2py] Re: previous url

2013-06-04 Thread Niphlod
or, a perfect usecase for a deque if you put this at the top of your controller, every controller function can access session.previous_url[0] as the last url visited. from collections import deque if session.previous_url is None: session.previous_url = deque([request.url], maxlen=2) else:

[web2py] Re: what is step to access to MSSQL

2013-06-04 Thread Anthony
Microsoft also has a Linux driver as well: http://www.microsoft.com/en-us/download/details.aspx?id=28160. Says it's for Red Hat, but I've heard it works on Ubuntu as well. You'll have to Google for instructions on installation. Anthony On Tuesday, June 4, 2013 5:33:18 PM UTC-4, Niphlod wrote:

[web2py] Re: [newbie] example authorization

2013-06-04 Thread lesssugar
OK, I have this in my view: {{if not auth.user:}} {{auth.settings.login_next = URL('default', 'test')}} {{=auth.login().update(_name='global_login')}} Forgot password? {{else:}} Logout {{pass}} As you say, if login data are correct, user should be automatically logged in and [in this case] r

[web2py] Re: previous url

2013-06-04 Thread Anthony
It may not be quite as reliable as recording the URL yourself, but you could also use request.env.http_referer. Anthony On Tuesday, June 4, 2013 5:48:20 PM UTC-4, Jose wrote: > > Hello > > I need to know what the last url visited (not the current url). I did > this, but it seems ugly. There a b

[web2py] Re: web2py 2.4.7 is Out

2013-06-04 Thread Aurelio Tinio
Thanks for the prompt response Massimo. It doesn't look like we are using the TAG helper for our application but good to know nonetheless. Cheers. On Tuesday, June 4, 2013 2:42:09 PM UTC-7, Massimo Di Pierro wrote: > > The only memory leak I am aware of is when one use the TAG helper. It is > f

[web2py] Re: Web Development Introduction Based On Web2py

2013-06-04 Thread 黄祥
unreachable. it return : 502 Bad Gateway -- nginx/1.4.0best regard -- --- 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+unsub

[web2py] previous url

2013-06-04 Thread Jose
Hello I need to know what the last url visited (not the current url). I did this, but it seems ugly. There a better way to do what I need. def previous_url(): if not session.previous_url: session.previous_url = [] session.previous_url.insert(0, request.url) session.previ

[web2py] Re: web2py 2.4.7 is Out

2013-06-04 Thread Massimo Di Pierro
The only memory leak I am aware of is when one use the TAG helper. It is fixed in trunk and will be foxed in 2.4.8 but it is not fixed in 2.4.6. I am not aware of other memory leaks. On Tuesday, 4 June 2013 16:22:10 UTC-5, Aurelio Tinio wrote: > > Hi Massimo, > If you don't mind, could you ela

[web2py] Re: what is step to access to MSSQL

2013-06-04 Thread Niphlod
and freedts too. https://gist.github.com/rduplain/1293636 forget about the sqlalchemy part, but the requirements are the same. On Tuesday, June 4, 2013 11:27:49 PM UTC+2, Derek wrote: > > You need odbc installed. > > On Tuesday, June 4, 2013 2:01:13 PM UTC-7, Nam Soo In wrote: >> >> I am tryin

Re: [web2py] Re: New feature in trunk conditional fields RFC

2013-06-04 Thread Massimo Di Pierro
Uploading to trunk. Please check it. On Tuesday, 4 June 2013 16:25:15 UTC-5, Niphlod wrote: > > fix for that. > > > function web2py_show_if(target) { > var triggers = {}; > var show_if = function () { > var t = jQuery(this); > var id = t.attr('id'); > t.attr('value', t.val()); >

[web2py] Re: what is step to access to MSSQL

2013-06-04 Thread Derek
You need odbc installed. On Tuesday, June 4, 2013 2:01:13 PM UTC-7, Nam Soo In wrote: > > I am trying to access remote mssql > My working env is ubuntu and mssql 2008 > Do I need any additional installs? > Thank you. > > -- --- You received this message because you are subscribed to the Googl

Re: [web2py] Re: New feature in trunk conditional fields RFC

2013-06-04 Thread Niphlod
fix for that. function web2py_show_if(target) { var triggers = {}; var show_if = function () { var t = jQuery(this); var id = t.attr('id'); t.attr('value', t.val()); for(var k = 0; k < triggers[id].length; k++) { var dep = jQuery('#' + triggers[id][k], target); var

[web2py] Re: web2py 2.4.7 is Out

2013-06-04 Thread Aurelio Tinio
Hi Massimo, If you don't mind, could you elaborate on what these bugfixes are? We've just upgraded our system to use v2.4.6 and trying to assess if it's worth it to do the upgrade to v2.4.7 before our launch. Specifically, we've noticed a possible memory leak with our deployment and currently

[web2py] Re: MongoDB and list:reference?

2013-06-04 Thread Alex Schlegel
update seems to work fine with list:reference as long as the field's value is actually an iterable. I'll do some more testing and make a pull request later. Thanks! On Tuesday, June 4, 2013 2:17:37 PM UTC-4, Alan Etkin wrote: > > By the way, I can get around this by changing this line in >> M

Re: [web2py] Re: New feature in trunk conditional fields RFC

2013-06-04 Thread Niphlod
BTW2: doesn't work on LOADed forms. -- --- 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://gr

Re: [web2py] Re: New feature in trunk conditional fields RFC

2013-06-04 Thread Niphlod
yep. BTW: this just hides the field. if someone fills the "bb" field, it gets sent with the form anyway. On Tuesday, June 4, 2013 10:55:31 PM UTC+2, Ramos wrote: > > Show if =visible when > No dia 04/06/2013 21:51, "Niphlod" > > escreveu: > >> it works, but a few hiccups with the examples post

[web2py] Re: Use newly inserted row after form.process().accepted

2013-06-04 Thread Niphlod
you are mistaken. request.args(0) is just the first arg of the url /appname/controller/function/this_is_request_args(0). try form.vars.id instead ^_^ On Tuesday, June 4, 2013 10:57:36 PM UTC+2, Robin Manoli wrote: > > I'm trying to use the newly created record after submitting a form. I get > t

[web2py] what is step to access to MSSQL

2013-06-04 Thread Nam Soo In
I am trying to access remote mssql My working env is ubuntu and mssql 2008 Do I need any additional installs? 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, sen

[web2py] Use newly inserted row after form.process().accepted

2013-06-04 Thread Robin Manoli
I'm trying to use the newly created record after submitting a form. I get the error from myFunc, telling me row is a NoneType. How can I fetch the newly created record? *form = SQLFORM(db.mytable) * *if form.process().accepted: * *row = db.mytable( request.args(0) ) # **request.args(0) shoul

Re: [web2py] Re: New feature in trunk conditional fields RFC

2013-06-04 Thread António Ramos
Show if =visible when No dia 04/06/2013 21:51, "Niphlod" escreveu: > it works, but a few hiccups with the examples posted > > def index1(): > """ shows bb only if aa is checked """ > db.define_table('thing', Field('aa','boolean'),Field('bb')) > db.thing.bb.show_if = db.thing.aa==T

[web2py] Re: New feature in trunk conditional fields RFC

2013-06-04 Thread Niphlod
it works, but a few hiccups with the examples posted def index1(): """ shows bb only if aa is checked """ db.define_table('thing', Field('aa','boolean'),Field('bb')) db.thing.bb.show_if = db.thing.aa==True form = SQLFORM(db.thing) return locals() def index2(): """ show

[web2py] Re: scheduler - looping queueing task

2013-06-04 Thread Niphlod
yep, but every time a scheduler task starts, it executes models to recreate the environment. given that you commit() in your task, the "queueing" gets committed too (that's probably the reason why it worked for you until now) You can use the uuid column to specify a unique name for your task, in

[web2py] Re: scheduler - looping queueing task

2013-06-04 Thread operE Aperte
I'll move queue_task() in controller, but the fact is that (till now) I always used queue_task() in model with no issues, and actually there is no request other then the ones I trigger visiting my site (site is demo, no "audience")... On Tuesday, June 4, 2013 9:13:54 PM UTC+2, Niphlod wrote: >

[web2py] Re: scheduler - looping queueing task

2013-06-04 Thread Niphlod
that's probably because your code queueing the task is inside models, that are executed for every request. Of course, models are executed also in the "fake" environment that executes the task (so you have at hand, e.g., the database). Move the "queue_task()" to a controller and queue it only one

[web2py] scheduler - looping queueing task

2013-06-04 Thread operE Aperte
Hi, I use scheduler from few months with - basically - no big issues. In the last days I saw a strange behaviour: tasks queued multiple time when in my shceduler.py I have only one scheduler.queue_task instruction. At first I thougth of multiple scheduler instances thrown by cron jobs (I even d

[web2py] Re: AD LDAP manage_user problem

2013-06-04 Thread mrendon
Thank you! It works now! On Tuesday, June 4, 2013 9:56:39 AM UTC-6, Massimo Di Pierro wrote: > > In > > from gluon.contrib.login_methods.ldap_auth import ldap_auth > auth.settings.login_methods.append(ldap_auth(mode='ad', >server='xxx..xxx', >base_dn='OU=,DC=,DC=xx

[web2py] Re: MongoDB and list:reference?

2013-06-04 Thread Alan Etkin
> By the way, I can get around this by changing this line in > MongoDBAdapter's insert function in dal.py: > values[fieldname] = self.object_id(v) > > to this: > if isinstance(v,list): > values[fieldname] = [self.object_id(x) for x in v] > else: > values[fieldname] = self.object_id(v) >

[web2py] Re: [newbie] example authorization

2013-06-04 Thread Anthony
The auth.login() action automatically verifies the login and logs the user in (which involves adding the user record to the user's session) -- you don't have to do any of that explicitly. If you want to redirect to a specific URL after login, you can set auth.settings.login_next to the desired

[web2py] MongoDB and list:reference?

2013-06-04 Thread Alex Schlegel
I am having a problem using a list:reference field with a MongoDB database, like so: db.define_table('page', ... Field('id_moderator','list:reference auth_user',default=auth.user_id), ... ) When I insert a record into this table with a list for the id_moderator field, like so: d

[web2py] Re: Web Development Introduction Based On Web2py

2013-06-04 Thread Kyle Pennell
I'm guessing you're aware that it's down today.. On Tuesday, December 20, 2011 10:33:21 AM UTC-8, ma...@rockiger.com wrote: > > I published the first 3 chapters of my web development tutorial at > http://killer-web-development.com > > It's aimed at total web development beginners and uses web2py

[web2py] [newbie] example authorization

2013-06-04 Thread lesssugar
In my layoyt.html I have the following code {{=auth.login().update(_action=URL('default', 'login'), _name='global_login' )}} The login form takes user email and password. It generates correctly. Let's assume there are test users in db.auth_user. I would be grateful if someone provided a short e

[web2py] Re: Gateway time-out 504 error with enable_record_versioning

2013-06-04 Thread Lamps902
Nevermind - sorted it out. Seems that a bunch of my tables had a dependency on "auth_user", and since a new db was created, with table names set to [original_table_name]_archive by default, there was no "auth_user" table, and the dependency was not being satisfied. If using auth.enable_record_v

[web2py] Re: app about page

2013-06-04 Thread Derek
Negative numbers would indicate lines deleted? Anyway, I think the graph is fine, it should be thought of like a heartbeat - if it's flatline, it's no good. On Sunday, June 2, 2013 2:47:49 AM UTC-7, BlueShadow wrote: > > >

Re: [web2py] Re: More Manual Issues

2013-06-04 Thread REM
Ok, I made this problem go away: Beneath this code was some earlier stuff which had been commented out. That, as well as the extra unmatched parentheses was together apparently the source of the problem - though the trace didn't show any problems related to the commented-out stuff and said noth

Re: [web2py] Re: More Manual Issues

2013-06-04 Thread Anthony
OK, not sure what to say -- it definitely works for me. Can you show the full traceback you are getting? Anthony On Tuesday, June 4, 2013 11:45:05 AM UTC-4, REM wrote: > > Yep, that's the first thing I tried - dinna work. > > Actually, I tried lots of variations before I devolved to begging for

[web2py] Re: Setting SELECT to request.vars with value/_value?

2013-06-04 Thread villas
Anthony, Yes I see, and Massimo's suggestion to backport the superior helpers from Web3py is probably better than making changes to the existing code. However, thanks very much for explaining this effect. D On Tuesday, 4 June 2013 16:36:42 UTC+1, Anthony wrote: > > On Tuesday, June 4, 2013

[web2py] Re: AD LDAP manage_user problem

2013-06-04 Thread Massimo Di Pierro
In from gluon.contrib.login_methods.ldap_auth import ldap_auth auth.settings.login_methods.append(ldap_auth(mode='ad', server='xxx..xxx', base_dn='OU=,DC=,DC=xx', bind_dn='CN=xxx,CN=x,DC=xx,DC=x', bind_pw='xx', manage_user=True, us

[web2py] Gateway time-out 504 error with enable_record_versioning

2013-06-04 Thread Lamps902
I've defined a new db to be used for archiving purposes with the following: db_archive = DAL("postgres://[address/authentication_info]/db_archive") Then, I attempt to enable archiving of a table by doing this: db.[table_name]._enable_record_versioning(db_archive) The app seems to be successfully

[web2py] Re: How can I get the SQLFORM in HTML example in book 5th Edition to work?

2013-06-04 Thread JoeCodeswell
Dear Massimo, Yesterday, I should have said, "Anthony's fix changed the first line [defining the form tag]". Sorry about that. was: now: This fix made the example in the book work for me. However I am not sure there wasn't a greater point being made about GET vs POST methods. Thanks for th

Re: [web2py] Re: More Manual Issues

2013-06-04 Thread Robert Moore
Yep, that's the first thing I tried - dinna work. Actually, I tried lots of variations before I devolved to begging for alms on the web - as one always should. On Tue, Jun 4, 2013 at 11:42 AM, Anthony wrote: > This works for me: > > {{=DIV(B(I("hello ", "")), _class="myclass")}} > > The extra "

[web2py] Re: Setting SELECT to request.vars with value/_value?

2013-06-04 Thread rppowell
I verified that using 'deepcopy()' resolves issue in my example; Thanks! -Rob Powell -- --- 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...@go

[web2py] Re: More Manual Issues

2013-06-04 Thread Anthony
This works for me: {{=DIV(B(I("hello ", "")), _class="myclass")}} The extra ")" was after "". Anthony On Tuesday, June 4, 2013 11:28:51 AM UTC-4, REM wrote: > > Still working through the manual, however puzzling and unexplained things > do still occur. For instance: why does this code (cut and

[web2py] Re: Avoiding extra quries when using DAL

2013-06-04 Thread Anthony
{{=response.toolbar()}} includes a button for all the queries and their execution times (this is also available as a list of 2-tuples in db._timings). Anthony On Tuesday, June 4, 2013 10:05:49 AM UTC-4, guruyaya wrote: > > OK, so I could be wrong about this. > Is there a way to get the number

[web2py] Re: Setting SELECT to request.vars with value/_value?

2013-06-04 Thread Anthony
On Tuesday, June 4, 2013 10:04:46 AM UTC-4, villas wrote: > Very interesting explanation, but it still seems obscure and not the kind > of thing the average user would consider. Isn't there an easier way to > make this work as expected? > > For example, shouldn't differently named SELECTs be p

[web2py] More Manual Issues

2013-06-04 Thread REM
Still working through the manual, however puzzling and unexplained things do still occur. For instance: why does this code (cut and pasted from P.233) - placed in a view of course - always generate a syntax error? {{=DIV(B(I("hello ", ""))), _class="myclass")}} Well, first I thought it was beca

Re: [web2py] css help

2013-06-04 Thread Richard Vézina
For 1, I do that : /* -- */ /* In order to allow footer to stick at the bottom even if the page core is empty Main design come from this tutorial : http://fvsch.com/code/page-hauteur-100/ Other help may be find here

[web2py] css help

2013-06-04 Thread Massimo Di Pierro
I would like help with two css issues: 1) In layout.html if there is no response.title, the page content slides up and may disappear under the menu banner. Can we prevent this? 2) In web2py_bootstrap.css I would like to have example code to change the colors without changing the bootstrap.css (

[web2py] Re: AD LDAP manage_user problem

2013-06-04 Thread szimszon
It's like you do not have a "db" DAL object. Where is your db connection settings? 2013. június 3., hétfő 23:22:30 UTC+2 időpontban mrendon a következőt írta: > > Thanks! Is this it? > > Traceback (most recent call last): > File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricte

[web2py] Re: Setting SELECT to request.vars with value/_value?

2013-06-04 Thread Massimo Di Pierro
I agree it should. The price to pay is copying the tree all times even when not necessary. Another solution would be to move to the new helpers (web3py). hopefully we will backport them soon. On Tuesday, 4 June 2013 09:04:46 UTC-5, villas wrote: > > Very interesting explanation, but it still se

[web2py] Re: Avoiding extra quries when using DAL

2013-06-04 Thread guruyaya
OK, so I could be wrong about this. Is there a way to get the number of GAE datastore reads per request? On Tuesday, June 4, 2013 12:25:06 PM UTC+3, guruyaya wrote: > > Lets examine this code for a sec: > db.define_table('table1',Field('name')) > db.define_table('table2',Field('table1', db.table1

[web2py] Re: Setting SELECT to request.vars with value/_value?

2013-06-04 Thread villas
Very interesting explanation, but it still seems obscure and not the kind of thing the average user would consider. Isn't there an easier way to make this work as expected? For example, shouldn't differently named SELECTs be parsed independently from each other? On Tuesday, 4 June 2013 14:1

[web2py] Re: changing the flash message, inside the onaccept / onvalidation function

2013-06-04 Thread Anthony
The other way is to do something in onaccept: def do_stuff(bla): session.flash = "I've just changed the flash message" def set_flash(form): if session.flash: response.flash = session.flash orm = crud.create(db.some_table, next=URL()+'?id=[id]', onvalidation= do_stuff, onaccept=set

[web2py] Re: Few controllers in the same basic layout

2013-06-04 Thread lesssugar
Yes, the direct including works like charm. On Monday, June 3, 2013 7:09:10 PM UTC+2, Anthony wrote: > > If you don't want to do an Ajax request on every page to fetch the login > form, you might consider either (a) retrieving the form via Ajax only when > the user clicks on a link/button, or (b

[web2py] Re: Disable button in /admin

2013-06-04 Thread Rob_McC
Just a comment, this wasn't obvious to me, but is now. I found this, which helped * http://www.web2py.com/book/default/chapter/03#Startup enable/disable* each application. When an application is disabled it cannot be called remotely but it is not disabled form localhost. This means disabled app

[web2py] Re: Setting SELECT to request.vars with value/_value?

2013-06-04 Thread Anthony
When you set the "value" attribute of a SELECT, it then sets the "_selected" attribute of the associated OPTION to "selected" (and the "_selected" attribute of all other OPTIONs to None). In this case, you have passed the same list of OPTIONs to each SELECT. The list of OPTIONs is mutable, and

[web2py] current.session

2013-06-04 Thread Matt
Hi, In one of my modules I'm trying to create a local socket connection that persists across a single session (one socket per one user logged into the system from a given browser), and thought that current.session would give me the info I needed. Specifically, we use a lot of REST calls in our

Re: [web2py] Re: Avoiding extra quries when using DAL

2013-06-04 Thread Carlos Costa
Hum, I forgot the problem has two tables. Nice! 2013/6/4 Massimo Di Pierro > I would replace > > retVal = [] > for entity in db(db.table2.id > 0).select(): > retVal += entity.table1.name > > with > > table1_map = db(db.table2 ).select().as_dict() > retVal = [table1_map

[web2py] Re: Grouping more than two fields in the same column of a smartgrid

2013-06-04 Thread Massimo Di Pierro
You can also do: db.protocol.region.represent = lambda v,r: "%(region)s-%(sequence)s/%(year)s" % r.protocol On Tuesday, 4 June 2013 07:19:07 UTC-5, Fred Guedes Pereira wrote: > > I found a solution: > > db.protocol.region.represent = lambda v,r: str(r.protocol.region) + '-' + > str(r.protocol.

[web2py] Re: Avoiding extra quries when using DAL

2013-06-04 Thread Massimo Di Pierro
I would replace retVal = [] for entity in db(db.table2.id > 0).select(): retVal += entity.table1.name with table1_map = db(db.table2 ).select().as_dict() retVal = [table1_map[entity.table1].name for entity in db(db.table2

Re: [web2py] Avoiding extra quries when using DAL

2013-06-04 Thread Carlos Costa
Maybe something like that. You could do the query and save it as a dict and work on it. result = db(db.table2.id > 0).select().as_dict() retVal = [entity.name for entity in result] 2013/6/4 guruyaya > Lets examine this code for a sec: > db.define_table('table1',Field('name')) > db.define_table

[web2py] Help us check new cool features!

2013-06-04 Thread Massimo Di Pierro
Conditional fields in forms: https://groups.google.com/forum/?fromgroups=#!topic/web2py/A-St4TX1xls Virtual fields in grids: https://groups.google.com/forum/?fromgroups=#!topic/web2py-developers/DvHvwYYi_Kc New appadmin interface (to manage groups, permissions, tables) that can be expo

[web2py] Re: Grouping more than two fields in the same column of a smartgrid

2013-06-04 Thread Fred Guedes Pereira
I found a solution: db.protocol.region.represent = lambda v,r: str(r.protocol.region) + '-' + str(r.protocol.sequence) + '/' + str(r.protocol.year) In the controller, you must also set readable to false for db.protocol.sequence and db.protocol.year , and they must be present in the grid´s fiel

[web2py] Re: Avoiding extra quries when using DAL

2013-06-04 Thread Anthony
> > for entity in db(db.table2.id > 0).select(): > retVal += entity.table1.name > No, web2py does not retrieve entity.table1.name when the first line above is executed. Rather, it does a separate select when the second line is executed. entity.table1 is a DAL Reference object -- when you ac

[web2py] Re: Setting SELECT to request.vars with value/_value?

2013-06-04 Thread Massimo Di Pierro
Very strange. What is the the generated HTML after submit? On Tuesday, 4 June 2013 00:33:36 UTC-5, rppowell wrote: > > Hello; > > I am using SELECT in a FORM and I noticed this behavior. > > Using the following in a controller, such as default.py: > > def selector_test(): > items = [ >

[web2py] Re: Scheduler task in GAE

2013-06-04 Thread José Manuel López
Hi Niphlod, Do you have any example about how use GAE tash queue from web2py?, can I use it inside my main controller without problem? something like this: # Add the task to the default queue. taskqueue.add(url='/worker', params={'key': key}) I've see this example: https://developers.

[web2py] Avoiding extra quries when using DAL

2013-06-04 Thread guruyaya
Lets examine this code for a sec: db.define_table('table1',Field('name')) db.define_table('table2',Field('table1', db.table1), Field('name2')) Now, if I need a list of all table2 entries, but not the table1 entries, I'll do something like this: retVal = [] for entity in db(db.table2.id > 0).sele

[web2py] Re: changing the flash message, inside the onaccept / onvalidation function

2013-06-04 Thread guruyaya
No, the outcome changes as a result of the onvalidatoion / onaccept operation. Is there any other way, or I'll just use SQLFORM and forget about it? On Monday, June 3, 2013 6:36:29 PM UTC+3, Anthony wrote: > > Is it possible to determine the message before calling crud.create()? If > so, you ca

[web2py] Re: Code changes not honored (by web2py?)

2013-06-04 Thread burhan cerit
Chr_M writes: > > > No, I am not using Ajax callbacks. I have done some more research, but I could be a Python thing as well.http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a- python-modulehttp://stackoverflow.com/questions/2918898/prevent-python-from- caching-the-imported-

[web2py] Re: in a view

2013-06-04 Thread Domagoj Kovač
This works. Thanks On Monday, June 3, 2013 5:14:37 PM UTC+2, villas wrote: > > Try this: > > {{cell_value = XML("".join(map(str, cell_value)))}} > > > > > On Monday, 3 June 2013 16:03:01 UTC+1, Domagoj Kovač wrote: >> >> Hi, >> >> I have a code like this: >> {{for row in table:}} >