Re: [web2py] Re: Google Groups problem
Hmm, email updates seem to be working for me (I just turned it on since the Forum interface is no longer working). Anyway, if you go to https://groups.google.com/forum/#!forum/web2py and are logged in, the options dropdown (gear icon) in the upper right should include a "Feedback" option, which you can use to report problems (it even grabs a screenshot and lets you highlight). Anthony On Tue, Dec 6, 2011 at 10:44 AM, Omi Chiba wrote: > Didn't know the problem but "Email updates to me" option is not > working since a few days ago and I'm so annoyed. I don't where we > should report to. > > On Dec 6, 9:39 am, Anthony wrote: > > Has anyone else noticed that new messages are not appearing in the new > > Google Groups interface (https://groups.google.com/forum/#!forum/web2py > ), > > but are appearing in the old interface > > (https://groups.google.com/group/web2py/topics?hl=en&start=)? > > > > Anthony >
Re: [web2py] Re: vars passed to LOAD become strings
> > One question related to the A() callback. > > Defining a and adding a target="some_id" to > the A works very well. > > I tried to do session.flash/response.flash inside the callback > function but it didn't work. Is there a way to do it? > > def callback_function(): >it does some stuff... >if s == "1": >return something >elif s == "2": >return something else >else: >session.flash = "Message" >return ??? > Is this possible??? Not like this. The way response.flash works is that the layout.html includes {{=response.flash}} in a div, and some JS code shows the div. The callback happens via Ajax and its result simply updates a single element -- it doesn't update the flash div. If you want to add a flash, you'll probably have to return some JS that will both update the element you want to update, and update and show the flash div via: jQuery('.flash').html('your flash message').slideDown(); Anthony
Re: [web2py] Re: Numbers only field
How about: replace(/[^ .0-9]/g,'') On Tue, Dec 6, 2011 at 11:36 AM, Vineet wrote: > But it doesn't accept decimal point either. > How to make it accept the decimal point? > > --- Vineet > > On Dec 6, 10:25 am, Saurabh S wrote: > > Thanks Massimo :) > > > > On Dec 6, 9:18 am, Massimo Di Pierro > > wrote: > > > > > > > > > > > > > > > > > jQuery('#tablename_fieldname').keyup(function() > > > {this.value=this.value.replace(/[^ 0-9]/g,'');}); > > > > > On Dec 5, 9:46 pm, Saurabh S wrote: > > > > > > Hi i have used custom form in my application > > > > > > example: > > > > > > > > > > {{=form.custom.label.mobile}}: > > > > {{=form.custom.widget.mobile}} > > > > {{=form.custom.label.email}}: > > > > {{=form.custom.widget.email}} > > > > > > > > > > I need a javascript/jqeury function to allow spaces and numbers only > > > > in the mobile field, even if user tries to enter some character or > > > > special character or anything else other than spaces and number , it > > > > should not allow the user to write it there. > > > > > > Please suggest.. >
Re: [web2py] Re: Numbers only field
I think \. will work, but it shouldn't be necessary inside the brackets (even in Python) -- metacharacters (like the dot) don't operate inside brackets, so no need to escape them there. Anthony On Tue, Dec 6, 2011 at 1:08 PM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote: > I think it should be > > replace(/[^ \.0-9]/g,'') > > not sure bout JS regex but in python . matches any character > > On Dec 6, 10:46 am, Anthony Bastardi wrote: > > How about: > > > > replace(/[^ .0-9]/g,'') > > > > > > > > > > > > > > > > On Tue, Dec 6, 2011 at 11:36 AM, Vineet > wrote: > > > But it doesn't accept decimal point either. > > > How to make it accept the decimal point? > > > > > --- Vineet > > > > > On Dec 6, 10:25 am, Saurabh S wrote: > > > > Thanks Massimo :) > > > > > > On Dec 6, 9:18 am, Massimo Di Pierro > > > > wrote: > > > > > > > jQuery('#tablename_fieldname').keyup(function() > > > > > {this.value=this.value.replace(/[^ 0-9]/g,'');}); > > > > > > > On Dec 5, 9:46 pm, Saurabh S wrote: > > > > > > > > Hi i have used custom form in my application > > > > > > > > example: > > > > > > > > > > > > > > {{=form.custom.label.mobile}}: > > > > > > {{=form.custom.widget.mobile}} > > > > > > {{=form.custom.label.email}}: > > > > > > {{=form.custom.widget.email}} > > > > > > > > > > > > > > I need a javascript/jqeury function to allow spaces and numbers > only > > > > > > in the mobile field, even if user tries to enter some character > or > > > > > > special character or anything else other than spaces and number > , it > > > > > > should not allow the user to write it there. > > > > > > > > Please suggest.. >
Re: [web2py] Re: Implementing tornado chat server with web2py
On Tue, Dec 6, 2011 at 1:15 PM, Saurabh Kumar wrote: > Thanks again for the reply. > The chat room thing is OK. Instead what I am concerned about is if the > code is efficient enough to handle thousands of request. > It should be. That's why Tornado is used -- it is a non-blocking web server. See http://www.tornadoweb.org/. Anthony
Re: [web2py] Re: Scope authenticated users revisited
Can you show all of your code? On Tue, Dec 6, 2011 at 2:17 PM, lyn2py wrote: > Thank you Anthony! That works well! > > Just a small question, I am trying to understand web2py better: > I am using 2 other tables to enable the above scenario: > (1) auth_account table to hold the account information > (2) auth_many table for many to many relationship > > And when joining both tables and returning the session.account, > myset = db( >(db.auth_account.id==db.auth_many.account_id) & >(db.auth_many.user_id==auth.user_id) > ) > session.account = myset.select(db.auth_account.ALL).first() > > I get an extra entry called "auth_many" in the session like: > account : auth_many : > > Why does this happen (I didn't "select" auth_many table), and how can > it be removed? > session is blind to users right? > > > On Dec 6, 11:06 pm, Anthony wrote: > > Presumably session.account is not always defined -- first you have to > > save 'account' to the session, so any request before that happens > > won't include 'account' in the session. > > > > session is a Storage() object, so when you attempt to access keys that > > are not defined, it simply returns None. That's why session.account > > doesn't produce an error, even if 'account' hasn't been defined. > > However, session.account.id produces an error because session.account > > is None, and None does not have an attribute named 'id'. > > > > What do you want the default to be in case there is no 'account' in > > session? Maybe something like: > > > > default=session.account and session.account.id or None > > > > Anthony > > > > On Dec 6, 2:06 am, lyn2py wrote: > > > > > > > > > > > > > > > > > Reference post: > > > Scope authenticated users in accountshttps:// > groups.google.com/group/web2py/browse_thread/thread/4e2bfa3f4... > > > > > I used fishwebby's method to scope authenticated users. The code used > > > is: > > > > > >> db._request_tenant = 'account_id' > > > >> db._common_fields=[Field('account_id',default=session.account.id, > writable=False, readable=False)] > > > > > But I get this error: > > > AttributeError: 'NoneType' object has no attribute 'id' > > > > > When I change default to session.account,>> > db._common_fields=[Field('account_id',default=session.account, > writable=False, readable=False)] > > > > > It doesn't give error, but when I use session.account.id or > > > session.account['id'] the error comes back. > > > > > Because session.account holds all the account info, it is better than > > > just to have the id in session.account. > > > Is this a bug or must I use session.account to hold only the account > > > id? > > > > > Or to solve this another way: > > > How can I create an accessible "account" variable like "auth", so that > > > I can use default=account.id or default=auth.account_id? > > > > > Thanks. >
Re: [web2py] Re: Scope authenticated users revisited
Model definitions, and maybe any other code that might be assigning to session. On Tue, Dec 6, 2011 at 2:42 PM, lyn2py wrote: > Hi Anthony, I am not sure what code you need, can you be specific? > > I have shown my code in my previous post, maybe I highlight my code: > >> myset = db( > >> (db.auth_account.id==db.auth_many.account_id) & > >> (db.auth_many.user_id==auth.user_id) > >> ) > >> session.account = myset.select(db.auth_account.ALL).first() > > It is in model. > > Thank you! > > > On Dec 7, 3:30 am, Anthony Bastardi wrote: > > Can you show all of your code? >
Re: [web2py] Web2py breaks with [IS_INT_IN_RANGE(), IS_IN_SET()]
What happens if you reverse the order of the validators: Mytable.payday.requires = [ IS_IN_SET(G_DAYS_AVAILABLE, error_message="Choose one day"), IS_INT_IN_RANGE(0,31)] Or what happens if you leave out the IS_INT_IN_RANGE validator altogether? Anthony On Tue, Dec 6, 2011 at 3:27 PM, Vinicius Assef wrote: > Guys, I need some help with IS_INT_IN_RANGE() plus IS_IN_SET() validators. > > I have the following structure, to adjust Mytable.payday.requires: > > [code] > G_DAYS_AVAILABLE = [ > (1, "Day 1st"), > (5, "Day 5th"), > (10, "Day 10th")] > > Mytable.payday.requires = IS_IN_SET(G_DAYS_AVAILABLE, >error_message="Choose one day") > [/code] > > This code works fine. But Mytable.payday field is integer. So, > according to the book [1], I must precede IS_IN_SET() with > IS_INT_IN_RANGE(). > > [code] > Mytable.payday.requires = [ >IS_INT_IN_RANGE(0,31), >IS_IN_SET(G_DAYS_AVAILABLE, >error_message="Choose one day")] > [/code] > > This code generates a ticket reporting this error: > SyntaxError: widget cannot determine options of no_table.payday > > I am using SQLFORM.factory() with web2py 1.99.2 (last stable) > > Where's my error? Any ideias? > > [1] http://web2py.com/book/default/chapter/07#Validators > > -- > Vinicius Assef >
Re: [web2py] Re: web2py Application Development Cookbook
On Tue, Dec 6, 2011 at 4:46 PM, greenpoise wrote: > Is this (web2py Application development cookbook) the same book as the > upcoming 3.xx edition of the web2py book? name change?? > > > No, it's a completely new book of recipes. The upcoming 4th edition of the web2py book is simply an update of the main reference book, and will be available for free online as usual (as well as for purchase in hard copy or PDF form). Anthony
Re: [web2py] Re: web2py Application Development Cookbook
I think it's supposed to be out very soon. Massimo will know better. Note, many of the updates are already available in the current online book, though there are some new things not yet posted there. Anthony On Tue, Dec 6, 2011 at 4:58 PM, greenpoise wrote: > Thanks! do you know the status of the 4th edition? > > > > > > On Dec 6, 1:54 pm, Anthony Bastardi wrote: > > On Tue, Dec 6, 2011 at 4:46 PM, greenpoise > wrote: > > > Is this (web2py Application development cookbook) the same book as the > > > upcoming 3.xx edition of the web2py book? name change?? > > > > No, it's a completely new book of recipes. The upcoming 4th edition of > the > > web2py book is simply an update of the main reference book, and will be > > available for free online as usual (as well as for purchase in hard copy > or > > PDF form). > > > > Anthony >
Re: [web2py] Web2py breaks with [IS_INT_IN_RANGE(), IS_IN_SET()]
Looks like the book is wrong. IS_IN_SET automatically converts the integer values in the set to strings, so if IS_INT_IN_RANGE is used first, it will pass an integer to IS_IN_SET, which will fail. As far as I can tell, everything works fine without using IS_INT_IN_RANGE at all, using SQLFORM or SQLFORM.factory. I don't think you even have to cast to int before doing the manual db insert. Try just using IS_IN_SET as you have, and just do the insert without any transformation -- does that work? Anthony On Tue, Dec 6, 2011 at 4:40 PM, Vinicius Assef wrote: > On Tue, Dec 6, 2011 at 7:04 PM, Anthony Bastardi > wrote: > > What happens if you reverse the order of the validators: > > > > Mytable.payday.requires = [ > > IS_IN_SET(G_DAYS_AVAILABLE, error_message="Choose one day"), > > IS_INT_IN_RANGE(0,31)] > > Anthony, the book says if I want an integer field, I must put > IS_INT_IN_RANGE() before IS_IN_SET(). Otherwise, the content will be a > string. > > > > Or what happens if you leave out the IS_INT_IN_RANGE validator > altogether? > > Actually, I solved this problem with just IS_IN_SET(). I made a > typecasting before inserting data in database, because I'm using > SQLFORM.factory(). > > But, if I was using just SQLFORM, this error could not occur, right? > > Or it is a bug and need a correction. Or the book needs to be updated, > to strip out that part about the 2 validators to get an int field. > > -- > Vinicius Assef. >
[web2py] Re: Sum issues while computing the total of a table field
Hey all, Please don't cc my personal email address on web2py Google Group posts. I'll see any posts directly on the group. Thanks. Anthony On Fri, Sep 30, 2016 at 7:48 AM, 黄祥 wrote: > pls try not tested : > def dashboard_admin(): > query = (db.payslip.state == 'Confirmed') > sum = db.payslip.gross.sum() > sum_result = db(query).select(sum).first()[sum] > return locals() > #return dict(sum_result = sum_result) # try if return locals() not work > > this should try in python console not in web2py controller > >>> query = (db.payslip.state == 'Confirmed') > >>> sum = db.payslip.gross.sum() > >>> print db(query).select(sum).first()[sum] > > best regards, > stifan > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
Re: [web2py] Re: Custom auth
Well, the post below made it onto the group, as that's where I saw it and responded. Looks like someone approved your individual post but didn't give you general approval to post. Anyway, I changed your status, so you should now be able to post without moderation. Anthony On Sun, Jun 1, 2014 at 1:46 PM, Shubham Sinha wrote: > Hi Anthony, > > I have been trying to post on the google group of web2py since > yesterday but everytime I click the post button, I get something like > "it will be posted after approval" but it never gets posted. I have > posted three times now and I still don't see any of my posts, It would > be great if you could help me out here. > > Regards, > > Shubham Sinha > > On Sun, Jun 1, 2014 at 8:18 AM, Anthony wrote: > > See > > > http://web2py.com/books/default/chapter/29/09/access-control#Customizing-Auth > > for the fields that are required. > > > > > > On Sunday, June 1, 2014 10:23:47 AM UTC-4, zahar wrote: > >> > >> > >> Is it possible for auth_user table to consist of username & password > only > >> apart for the auto generated id. > >> > >> In my situation the username which can be set by > >> auth.define_tables(username=True), but the other fields in the auth_user > >> table is not required. The reason is that I only need to dump the > username > >> (the student id) and their password (crypt and salted) from another > table to > >> auth_user table, so as not to reinvent the wheel. > >> > > -- > > Resources: > > - http://web2py.com > > - http://web2py.com/book (Documentation) > > - http://github.com/web2py/web2py (Source code) > > - https://code.google.com/p/web2py/issues/list (Report Issues) > > --- > > 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/d/optout. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.