[web2py] SQLFORM.grid: trigger edit when clicking anywhere on the row itself

2015-10-24 Thread Julian Sanchez
Is there an easy way to trigger the same URL you get when pressing the 
built-in 'edit' button of the SQLFORM.grid without having to show that 
button?  I have a few grids that would show cleaner if users could go 
directly to the edit page by clicking on the row itself (no need to view 
details).  I can do some jQuery stuff for that but I lose the '_signature' 
argument.  I could disable it but I would rather keep it for added security.

-- 
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.


[web2py] Is it intended that TABLE(rows) makes a table within a table?

2015-10-24 Thread Edward Shave
TABLE(rows) is a nice shorthand way to make a table but I'm getting a table 
within a table starting as below.

...

Is this right?

Or should I not be doing this anyway?

-- 
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.


[web2py] Re: Is it intended that TABLE(rows) makes a table within a table?

2015-10-24 Thread Anthony
Rows objects have an .xml() method that serializes them to a SQLTABLE, so 
when you include them directly in a view (e.g., {{=rows}}) or inside 
another HTML helper (such as TABLE), you get a TABLE. In short, no need to 
wrap it in TABLE().

Anthony

On Saturday, October 24, 2015 at 9:22:59 AM UTC-4, Edward Shave wrote:
>
> TABLE(rows) is a nice shorthand way to make a table but I'm getting a 
> table within a table starting as below.
>
> ...
>
> Is this right?
>
> Or should I not be doing this anyway?
>

-- 
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.


[web2py] Re: Is it intended that TABLE(rows) makes a table within a table?

2015-10-24 Thread Anthony
Also, note that the reason for the odd behavior is that TABLE must take one 
of the HTML elements that is allowed inside the  tag, such as tbody, 
thead, tfoot, tr, col, or colgroup). If you pass anything else, it will be 
wrapped in a TR by default.

Anthony

On Saturday, October 24, 2015 at 9:36:44 AM UTC-4, Anthony wrote:
>
> Rows objects have an .xml() method that serializes them to a SQLTABLE, so 
> when you include them directly in a view (e.g., {{=rows}}) or inside 
> another HTML helper (such as TABLE), you get a TABLE. In short, no need to 
> wrap it in TABLE().
>
> Anthony
>
> On Saturday, October 24, 2015 at 9:22:59 AM UTC-4, Edward Shave wrote:
>>
>> TABLE(rows) is a nice shorthand way to make a table but I'm getting a 
>> table within a table starting as below.
>>
>> ...
>>
>> Is this right?
>>
>> Or should I not be doing this anyway?
>>
>

-- 
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.


[web2py] Re: Is it intended that TABLE(rows) makes a table within a table?

2015-10-24 Thread Edward Shave
Thanks Anthony,

The reason I was trying TABLE was because I wanted to include a class in 
the table tag and was thinking this might work...

TABLE(rows, _class="fred")

taking account of your answer I'm now using...

table_as_string = ''+rows.xml(0)[7:]

-- 
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.


[web2py] Encoding-related exceptions produced when doing DB inserts or lookups

2015-10-24 Thread Spokes
An application has suddenly started generating exceptions pertaining to 
encoding, when I attempt to perform database inserts or lookups.

The lookup operation produces this exception: 

3. Exception in 'Agent_Base check_comparable_record_exists_in_db()': 'ascii' 
codec can't decode byte 0xe2 in position 502: ordinal not in range(128) | 
Time: 2015-10-24 17:49:06.155000 
Traceback:

The insert operation produces this exception:

3. Exception in 'BaseModel insert_record()': 'ascii' codec can't decode 
byte 0xc2 in position 715: ordinal not in range(128) | Time: 2015-10-24 
17:49:06.155000 
Traceback:

I suspect that some bad data may have gotten into the DB;  but also appears 
that I'm not permitted to access the DB logs on my host's server. If I run 
the same functions, using a sqlite DB instead of the postgres production 
DB, the above errors do not occur.

Any ideas regarding how to go about determining what's causing the errors? 
Is there a way to get more detailed error output with web2py?

-- 
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.


[web2py] How to check if my user's profile is complete in web2py?

2015-10-24 Thread Upendra Kumar
I have made a 'user_details' table whose 'user_id' field I have referenced 
to default 'auth_user' table. Now after registration, I show the user his 
profile and ask him to complete it. But, the problem is that how can I 
check if the profile is complete or not after the user submits the updated 
profile.

Here is my user_details table,

db.define_table('user_details',
Field('user_id'),
Field('gender',requires=IS_IN_SET(['Male','Female','Other'])),
Field('phone_number',requires=IS_MATCH('\d{10}')),
Field('preferred_mess'),
Field('preferred_caterer'),
Field('state_name','string'),
Field('account_initial_balance'),
Field('account_curr_balance'),
Field('your_booking_preference',requires=IS_IN_SET(['''Don't Book Food 
Automatically''','Book Food Automatically'])))



-- 
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: Enabling Google Sign-In

2015-10-24 Thread Donald McClymont
It is on github at https://github.com/bnmnetp/w2p-social-auth  but doesn't 
appear to be getting maintained.

I agree it would be good if it was more promoted - it seems to work but is 
using version 0.1.24 or so of psa which is a good bit behind latest version 
- but it seems to work fine with Facebook, Twitter and Mozilla Persona in 
some way allows emails from Google and the like - however I have yet to get 
Google or Microsoft to work.

On Thursday, October 22, 2015 at 9:54:52 PM UTC+1, mcm wrote:
>
> yup it would be nice if it were maintained and moved to github...
>
> 2015-10-22 17:40 GMT+02:00 Niphlod >:
>
>> I didn't know about w2p-social-auth and I'm starting to thinking that we 
>> should "promote it" and discourage all social-own-cooked pieces inside 
>> contrib/login_methods...
>>
>>
>> On Thursday, October 22, 2015 at 1:27:35 PM UTC+2, mcm wrote:
>>
>>>
>>> http://web2py.com/books/default/chapter/29/09/access-control?search=oauth#Other-login-methods-and-login-forms
>>>
>>>
>>> Grab the file google_auth.json from the google developer console and put 
>>> in private dir of your app
>>>
>>> put  code similar to the one below in db.py:
>>>
>>>
>>> from gluon.contrib.login_methods.oauth20_account import OAuthAccount
>>>
>>> try:
>>> import json
>>> except ImportError:
>>> from gluon.contrib import simplejson as json
>>>
>>>
>>> class GoogleAccount(OAuthAccount):
>>> "OAuth 2.0 for Google"
>>>
>>> def __init__(self):
>>> with open(os.path.join(request.folder, 
>>> 'private/google_auth.json'), 'rb') as f:
>>> gai = Storage(json.load(f)['web'])
>>> 
>>> OAuthAccount.__init__(self, None, gai.client_id, 
>>> gai.client_secret,
>>>   gai.auth_uri, gai.token_uri,
>>>   scope='
>>> https://www.googleapis.com/auth/userinfo.profile 
>>> https://www.googleapis.com/auth/userinfo.email',
>>>   approval_prompt='force', 
>>> state="auth_provider=google")
>>>
>>>
>>> def get_user(self):
>>>
>>> token = self.accessToken()
>>> if not token:
>>> return None
>>>
>>> uinfo_url = '
>>> https://www.googleapis.com/oauth2/v1/userinfo?access_token=%s' % 
>>> urllib2.quote(token, safe='')
>>>
>>> uinfo = None
>>>
>>> try:
>>> uinfo_stream = urllib2.urlopen(uinfo_url)
>>> except:
>>> session.token = None
>>> return
>>> data = uinfo_stream.read()
>>> uinfo = json.loads(data)
>>>
>>> username = uinfo['id']
>>> 
>>> return dict(first_name = uinfo['given_name'],
>>> last_name = uinfo['family_name'],
>>> username = username,
>>> email = uinfo['email'])
>>>
>>> auth.settings.login_form = GoogleAccount()
>>>
>>>
>>> 2015-10-22 11:02 GMT+02:00 Leonel Câmara :
>>>
 I would try to use this:

 https://code.google.com/p/w2p-social-auth/

 -- 
 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+un...@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+un...@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.


[web2py] cannot disable automatic login after registration

2015-10-24 Thread Pierre
Hi everyone,

I tried to do it with no success with this:

auth.settings.login_after_registration = False

thanks for your help

-- 
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.


[web2py] uwsgi/nginx encode error

2015-10-24 Thread Gustavo Moreira Freitas


Hi guys,


i have some issues to send json with special chars. i am using nginx,ubuntu 
14.04 uwsgi and web2py.


as follwing images, when i send a json without special chars (like ç é) it 
bring me response ,request.post_vars or **vars not empty.


However when i sent any special chars i got nothing/None.Someone can help 
me?


i am using last version from web2py 

2.12.3-stable+timestamp.2015.08.19.00.18.03
(Running on nginx/1.4.6, Python 2.7.6)





 


 

-- 
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.


[web2py] Code in view seems not to be processing variables passed by sessions

2015-10-24 Thread Arlindo Gomes Filho

Hi everybody,

I’m beginner, trying to develop a code in which the user is asked to answer 
three questions (presented in two sequential forms) and, based on the 
combination of those answers the code (in the view “result”)  is supposed 
to present the user the one procedure among four available that best apply 
to the situation.


The first form (LIC_ZON) is correctly redirecting to the second one, which 
is also correctly redirecting to the view “result”. My problem is that it 
seems my code in the view “result” is not processing the answers chosen by 
the user and that are passed by the sessions.   No matter the options 
chosen by the user, only one and the same procedure is always presented in 
the view (procedure four). I can't get what I'm missing.

 

Thanks for any help.


Complete code in: https://github.com/argofix/Bungo


My contoller:



def LIC_ZON(): form = SQLFORM.factory( Field('emp', label='Type of license:', 
requires=IS_IN_SET(['EIA', 'SEIA', 'NALIC'])), Field('UC', label='Type of 
zone:', requires=IS_IN_SET(['CZA', 'SZA', 'NAZA'])) ) if 
form.process().accepted: session.flash = 'Option succesfully inserted!' 
session.emp = form.vars.emp session.UC = form.vars.UC emp = request.vars.emp 
UC = request.vars.UC if form.vars.UC == 'CZA': redirect(URL('UCCZA')) if 
form.vars.UC == 'SZA': if form.vars.emp == 'EIA': redirect(URL('UCSZA3')) if 
form.vars.emp == 'SEIA': redirect(URL('UCSZA2')) if form.vars.emp == 'NALIC'
: redirect(URL('UCNALIC')) if form.vars.UC == 'NAZA': redirect(URL('UCNAZA'
)) return dict(form=form) def UCCZA(): form = SQLFORM.factory( Field('uccza', 
label='Where is the activity located?', requires=IS_IN_SET(['IUC', 'IZA', '
FZA'])) ) if form.process().accepted: response.flash = 'Option succesfully 
inserted!' session.uccza = form.vars.uccza uccza = request.vars.uccza 
redirect(URL('result')) return dict(form=form) def UCSZA3(): form = 
SQLFORM.factory( Field('ucsza3', label='Where is the activity located?', 
requires=IS_IN_SET(['IUC', 'ZPD3', 'FZPD3'])) ) if form.process().accepted: 
response.flash = 'Option succesfully inserted!' session.ucsza3 = 
form.vars.ucsza3 ucsza3 = request.vars.ucsza3 redirect(URL('result')) return 
dict(form=form) def UCSZA2(): form = SQLFORM.factory( Field('ucsza2', label=
'Where is the activity located?', requires=IS_IN_SET(['IUC', 'ZPD2', 'FZPD2'
])) ) if form.process().accepted: response.flash = 'Option succesfully 
inserted!' session.ucsza2 = form.vars.ucsza2 ucsza2 = request.vars.ucsza2 
redirect(URL('result')) return dict(form=form) def UCNALIC(): form = 
SQLFORM.factory( Field('ucnalic', label='Where is the activity located?', 
requires=IS_IN_SET(['IUC', 'FUC'])) ) if form.process(vars).accepted: 
response.flash = 'Option succesfully inserted!' session.ucnalic = 
form.vars.ucnalic ucnalic = request.vars.ucnalic redirect(URL('result')) 
return dict(form=form) def UCNAZA(): form = SQLFORM.factory( Field('ucnaza', 
label='Where is the activity located?', requires=IS_IN_SET(['IUC', 'FUC'])) 
) if form.process().accepted: response.flash = 'Option succesfully inserted!
' session.ucnaza = form.vars.ucnaza ucnaza = request.vars.ucnaza 
redirect(URL('result')) return dict(form=form) def result(): return dict()


My view:


{{extend 'layout.html'}} Procedure you shoud apply {{if (emp 
== 'EIA' and UC == 'CZA' and uccza == 'IUC') or (emp == 'EIA' and UC == 
'CZA' and uccza == 'IZA') or (emp == 'EIA' and UC == 'CZA' and uccza == 
'FZA') or (emp == 'SEIA' and UC == 'CZA' and uccza == 'IUC') or (emp == 
'SEIA' and UC == 'CZA' and uccza == 'FZA') or (emp == 'EIA' and UC == 'SZA' 
and ucsza1 == 'IUC') or (emp == 'EIA' and UC == 'SZA' and ucsza1 == 'ZPD3') 
or (emp == 'SEIA' and UC == 'SZA' and ucsza2 == 'IUC'):}} Apply procedure 1 
{{elif 
(emp == 'SEIA' and UC == 'CZA' and uccza == 'IZA') or (emp == 'SEIA' and UC 
== 'SZA' and ucsza2 == 'ZPD2'):}} Apply procedure 2 {{elif (emp == 'NALIC' 
and UC == 'CZA' and uccza == 'IUC') or (emp == 'NALIC' and UC == 'SZA' and 
ucnalic == 'IUC') or (emp == 'EIA' and UC == 'NAZA' and ucnaza == 'IUC') or 
(emp == 'SEIA' and UC == 'NAZA' and ucnaza == 'IUC') or (emp == 'NALIC' and 
UC == 'NAZA' and ucnaza == 'IUC'):}} Apply procedure 3 {{else:}} Apply 
procedure 4{{pass}}

-- 
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.


[web2py] Course Subscription form

2015-10-24 Thread Wadson Dias
Hi everyone!

How can I limit number of subscribers in certain course? Only 20 in Oficina 
1, and 15 in oficina 2...

My Model:
db = DAL('sqlite://storage.sqlite')
db.define_table('inscritos',
Field('nome','string'),
Field('email','string'),
Field('cpf','string', unique = True),
Field('dtcadastro','date'),
Field('Oficina', requires=IS_IN_SET(['Oficina 1', 'Oficina 
2', 'Oficina 3'])),
   Field('Resumo','upload'))


-- 
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.


[web2py] Appconfig - what's the best way to handle missing values

2015-10-24 Thread Donald McClymont
I like the appconfig file approach however I am not clear if there is a 
recommended approach to handling missing values in the file.  It seems 
reasonable and convenient that you might want to update the code and the 
appconfig separately and use a default value if the key isn't present. 
 However at present a missing value seems to raise a BaseException error 
which isn't ideal for try... except type structures.

Can someone recommend how to handle or if this situation should just be 
avoided?

-- 
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.


[web2py] Newby question about referencing fields in a lookup table

2015-10-24 Thread Bill Lugg
I am vary new to Web2py and am very impressed with what I see so far.  I 
come from a MS Access background and am looking for an easy way to develop 
small db applications in similar fashion and offering some of the same 
features that are offered in Access, but without the proprietary chains 
that MS imposes.

I've been experimenting with a simple inventory app and I have a situation 
where I have some lookup tables that I want to reference in my main item 
form.  In my first attempt, the lookup table contains an integer item type 
and a string item type description.  I'd like the main form to display the 
descriptions, but store either a link or a copy of the integer item type in 
the items table (at this point I'm not too picky).  FWIW, I used the wizard 
to generat the application to start.

Here's the code as I modified it to display the item type description in 
the items form:

db.define_table('t_items',
Field('f_itemname_string', type='string', notnull=True,
  label=T('Itemname String')),
Field('f_itemtype', type='reference t_itemtypes',
  requires=IS_IN_DB(db, 't_itemtypes.f_itemtype', 
't_itemtypes.f_itemtypedesc_string'),
  label=T('Itemtype')),


This works, but when I insert a record I get the following error:
e IntegrityError('FOREIGN KEY constraint failed',)

Looking at the arguments up the stack a bit, it appears to be trying to put 
an integer in for the item type so I'm a little stumped as to what might be 
wrong.  I wonder if someone might be able to point me in the right 
direction as I will want to do this with a couple of other fields as well.

In addition, I have a couple of integer fields that I want to make a fixed 
list from 1 to 4, inclusive.  I was going to use the requires=IS_IN_SET 
construct for this; am I headed in the right direction?

Thanks for the help with this.

Bill Lugg

-- 
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.


[web2py] Re: How to check if my user's profile is complete in web2py?

2015-10-24 Thread 'DenesL' via web2py-users

Try 
http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#onvalidation
 
the example is pretty clear.


On Saturday, October 24, 2015 at 8:28:15 PM UTC-4, Upendra Kumar wrote:
>
> I have made a 'user_details' table whose 'user_id' field I have referenced 
> to default 'auth_user' table. Now after registration, I show the user his 
> profile and ask him to complete it. But, the problem is that how can I 
> check if the profile is complete or not after the user submits the updated 
> profile.
>
> Here is my user_details table,
>
> db.define_table('user_details',
> Field('user_id'),
> Field('gender',requires=IS_IN_SET(['Male','Female','Other'])),
> Field('phone_number',requires=IS_MATCH('\d{10}')),
> Field('preferred_mess'),
> Field('preferred_caterer'),
> Field('state_name','string'),
> Field('account_initial_balance'),
> Field('account_curr_balance'),
> Field('your_booking_preference',requires=IS_IN_SET(['''Don't Book Food 
> Automatically''','Book Food Automatically'])))
>
>
>
>

-- 
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.


[web2py] Re: Code in view seems not to be processing variables passed by sessions

2015-10-24 Thread 'DenesL' via web2py-users

Your view(s) can only see the variables that you return from the 
controller, in your case mainly 1: form.

So your result view is not getting any variables from its controller.
You have two options:
1) retrieve the values from the session directly in the view (you have been 
saving them)
2) retrieve the values from the session in the controller and return the 
variables needed in a dictionary

Option 1 might look like this in the view:

{{if (session.emp == 'EIA' and session.UC == 'CZA'}}

or initialize the vars without changing the ifs:

{{emp = session.emp
UC = session.UC
...
}}
{{if (emp == 'EIA' and UC == 'CZA' ...


Option 2 is similar but in the controller:

return {'emp': session.emp, 'UC': session.UC, ...}

Denes.


On Saturday, October 24, 2015 at 8:32:00 PM UTC-4, Arlindo Gomes Filho 
wrote:
>
>
> Hi everybody,
>
> I’m beginner, trying to develop a code in which the user is asked to 
> answer three questions (presented in two sequential forms) and, based on 
> the combination of those answers the code (in the view “result”)  is 
> supposed to present the user the one procedure among four available that 
> best apply to the situation.
>
>
> The first form (LIC_ZON) is correctly redirecting to the second one, which 
> is also correctly redirecting to the view “result”. My problem is that it 
> seems my code in the view “result” is not processing the answers chosen by 
> the user and that are passed by the sessions.   No matter the options 
> chosen by the user, only one and the same procedure is always presented in 
> the view (procedure four). I can't get what I'm missing.
>
>  
>
> Thanks for any help.
>
>
> Complete code in: https://github.com/argofix/Bungo
>
>
> My contoller:
>
>
>
> def LIC_ZON(): form = SQLFORM.factory( Field('emp', label='Type of 
> license:', requires=IS_IN_SET(['EIA', 'SEIA', 'NALIC'])), Field('UC', 
> label='Type of zone:', requires=IS_IN_SET(['CZA', 'SZA', 'NAZA'])) ) if 
> form.process().accepted: session.flash = 'Option succesfully inserted!' 
> session.emp = form.vars.emp session.UC = form.vars.UC emp = 
> request.vars.emp UC = request.vars.UC if form.vars.UC == 'CZA': 
> redirect(URL('UCCZA')) if form.vars.UC == 'SZA': if form.vars.emp == 'EIA'
> : redirect(URL('UCSZA3')) if form.vars.emp == 'SEIA': redirect(URL('UCSZA2
> ')) if form.vars.emp == 'NALIC': redirect(URL('UCNALIC')) if form.vars.UC 
> == 'NAZA': redirect(URL('UCNAZA')) return dict(form=form) def UCCZA(): 
> form = SQLFORM.factory( Field('uccza', label='Where is the activity 
> located?', requires=IS_IN_SET(['IUC', 'IZA', 'FZA'])) ) if 
> form.process().accepted: response.flash = 'Option succesfully inserted!' 
> session.uccza = form.vars.uccza uccza = request.vars.uccza redirect(URL('
> result')) return dict(form=form) def UCSZA3(): form = SQLFORM.factory( 
> Field('ucsza3', label='Where is the activity located?', requires=
> IS_IN_SET(['IUC', 'ZPD3', 'FZPD3'])) ) if form.process().accepted: 
> response.flash = 'Option succesfully inserted!' session.ucsza3 = 
> form.vars.ucsza3 ucsza3 = request.vars.ucsza3 redirect(URL('result')) 
> return dict(form=form) def UCSZA2(): form = SQLFORM.factory( Field('ucsza2
> ', label='Where is the activity located?', requires=IS_IN_SET(['IUC', '
> ZPD2', 'FZPD2'])) ) if form.process().accepted: response.flash = 'Option 
> succesfully inserted!' session.ucsza2 = form.vars.ucsza2 ucsza2 = 
> request.vars.ucsza2 redirect(URL('result')) return dict(form=form) def 
> UCNALIC(): form = SQLFORM.factory( Field('ucnalic', label='Where is the 
> activity located?', requires=IS_IN_SET(['IUC', 'FUC'])) ) if form.process(
> vars).accepted: response.flash = 'Option succesfully inserted!' 
> session.ucnalic = form.vars.ucnalic ucnalic = request.vars.ucnalic 
> redirect(URL('result')) return dict(form=form) def UCNAZA(): form = 
> SQLFORM.factory( Field('ucnaza', label='Where is the activity located?', 
> requires=IS_IN_SET(['IUC', 'FUC'])) ) if form.process().accepted: 
> response.flash = 'Option succesfully inserted!' session.ucnaza = 
> form.vars.ucnaza ucnaza = request.vars.ucnaza redirect(URL('result')) 
> return dict(form=form) def result(): return dict()
>
>
> My view:
>
>
> {{extend 'layout.html'}} Procedure you shoud apply {{if (emp 
> == 'EIA' and UC == 'CZA' and uccza == 'IUC') or (emp == 'EIA' and UC == 
> 'CZA' and uccza == 'IZA') or (emp == 'EIA' and UC == 'CZA' and uccza == 
> 'FZA') or (emp == 'SEIA' and UC == 'CZA' and uccza == 'IUC') or (emp == 
> 'SEIA' and UC == 'CZA' and uccza == 'FZA') or (emp == 'EIA' and UC == 'SZA' 
> and ucsza1 == 'IUC') or (emp == 'EIA' and UC == 'SZA' and ucsza1 == 'ZPD3') 
> or (emp == 'SEIA' and UC == 'SZA' and ucsza2 == 'IUC'):}} Apply procedure 1 
> {{elif 
> (emp == 'SEIA' and UC == 'CZA' and uccza == 'IZA') or (emp == 'SEIA' and UC 
> == 'SZA' and ucsza2 == 'ZPD2'):}} Apply procedure 2 {{elif (emp == 
> 'NALIC' and UC == 'CZA' and uccza == 'IUC') or (emp == 'NALIC' and UC == 
> 'SZA' and ucnalic == 'IUC') or (emp == 'EIA' and UC =

[web2py] Re: Course Subscription form

2015-10-24 Thread 黄祥
i think you can use the query (count() ) and check condition according to 
your need (if query >= value), if condition meet, redirect to another page 
redirect(URL(redirect) ), if not insert the data (db.table.insert() ).

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.


[web2py] Re: Appconfig - what's the best way to handle missing values

2015-10-24 Thread 'DenesL' via web2py-users

from gluon.contrib.appconfig import AppConfig
myconfig = AppConfig('/private/appconfig.ini', reload=False)

does not cause an exception even when loading the default ini below, which 
has an empty value (last one):
; App configuration

; db configuration
[db]
uri   = sqlite://storage.sqlite
migrate   = 1
pool_size = 1

; smtp address and credentials
[smtp]
server = smtp.gmail.com:587
sender = y...@gmail.com
login  = username:password


; form styling
[forms]
formstyle = bootstrap3_inline
separator =

Can you post an example of what you are doing and the error?.

Denes



On Saturday, October 24, 2015 at 8:31:45 PM UTC-4, Donald McClymont wrote:
>
> I like the appconfig file approach however I am not clear if there is a 
> recommended approach to handling missing values in the file.  It seems 
> reasonable and convenient that you might want to update the code and the 
> appconfig separately and use a default value if the key isn't present. 
>  However at present a missing value seems to raise a BaseException error 
> which isn't ideal for try... except type structures.
>
> Can someone recommend how to handle or if this situation should just be 
> avoided?
>

-- 
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.


[web2py] Re: Is it intended that TABLE(rows) makes a table within a table?

2015-10-24 Thread 'DenesL' via web2py-users

You can do
SQLTABLE(rows, _class="fred")



On Saturday, October 24, 2015 at 5:29:17 PM UTC-4, Edward Shave wrote:
>
> Thanks Anthony,
>
> The reason I was trying TABLE was because I wanted to include a class in 
> the table tag and was thinking this might work...
>
> TABLE(rows, _class="fred")
>
> taking account of your answer I'm now using...
>
> table_as_string = ''+rows.xml(0)[7:]
>
>

-- 
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.


[web2py] Re: cannot disable automatic login after registration

2015-10-24 Thread 'DenesL' via web2py-users

You also need

settings.registration_requires_verification = True



On Saturday, October 24, 2015 at 8:30:52 PM UTC-4, Pierre wrote:
>
> Hi everyone,
>
> I tried to do it with no success with this:
>
> auth.settings.login_after_registration = False
>
> thanks for your help
>
>

-- 
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.


[web2py] Re: Newby question about referencing fields in a lookup table

2015-10-24 Thread 'DenesL' via web2py-users

The second argument of IS_IN_DB should be the key to the reference.
And the third should be a format string to represent that key.

So your models should look something like
db.define_table('t_itemtypes',
Field('f_itemtypedesc_string', 'string'),
)
db.define_table('t_items',
Field('f_itemname_string', type='string', notnull=True, label=T(
'ItemName')),
Field('f_itemtype', type='reference t_itemtypes', label=T('ItemType')),
  requires=IS_IN_DB(db, 't_itemtypes.id', 
'%(f_itemtypedesc_string)s')
)



On Saturday, October 24, 2015 at 8:31:27 PM UTC-4, Bill Lugg wrote:
>
> I am vary new to Web2py and am very impressed with what I see so far.  I 
> come from a MS Access background and am looking for an easy way to develop 
> small db applications in similar fashion and offering some of the same 
> features that are offered in Access, but without the proprietary chains 
> that MS imposes.
>
> I've been experimenting with a simple inventory app and I have a situation 
> where I have some lookup tables that I want to reference in my main item 
> form.  In my first attempt, the lookup table contains an integer item type 
> and a string item type description.  I'd like the main form to display the 
> descriptions, but store either a link or a copy of the integer item type in 
> the items table (at this point I'm not too picky).  FWIW, I used the wizard 
> to generat the application to start.
>
> Here's the code as I modified it to display the item type description in 
> the items form:
>
> db.define_table('t_items',
> Field('f_itemname_string', type='string', notnull=True,
>   label=T('Itemname String')),
> Field('f_itemtype', type='reference t_itemtypes',
>   requires=IS_IN_DB(db, 't_itemtypes.f_itemtype', 
> 't_itemtypes.f_itemtypedesc_string'),
>   label=T('Itemtype')),
>
>
> This works, but when I insert a record I get the following error:
> e IntegrityError('FOREIGN KEY constraint failed',)
>
> Looking at the arguments up the stack a bit, it appears to be trying to 
> put an integer in for the item type so I'm a little stumped as to what 
> might be wrong.  I wonder if someone might be able to point me in the right 
> direction as I will want to do this with a couple of other fields as well.
>
> In addition, I have a couple of integer fields that I want to make a fixed 
> list from 1 to 4, inclusive.  I was going to use the requires=IS_IN_SET 
> construct for this; am I headed in the right direction?
>
> Thanks for the help with this.
>
> Bill Lugg
>

-- 
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.