[web2py] Re: Cookies and redirect

2018-08-21 Thread Anthony
On Tuesday, August 21, 2018 at 12:37:16 PM UTC-4, Carlos Correia wrote:
>
> Hi,
>
>
> Is it possible to set a cookie and redirect to another page in the same 
> controller?
>
> If yes, how? I tried this simple example but the cookie is lost if I use 
> the redirect...
>
> def cookies2():
> cookie_name = 'name'cookie_value = 'value'response.cookies[ 
> cookie_name ] = cookie_value
> response.cookies[ cookie_name ][ 'expires' ] = 24 * 3600
> response.cookies[ cookie_name ][ 'path' ] = '/'response.cookies[ 
> cookie_name ][ 'secure' ] = Trueredirect( URL( c='test', 
> f='cookie_result' ) )
>
>
Instead of using redirect, you can use HTTP() directly:

raise HTTP(303, cookies=response.cookies, Location=URL('test', 
'cookie_result'))

redirect() is simply a shortcut for the above (minus the cookies).

Anthony

-- 
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: custom form web2py not work when i use selectpicker

2018-08-21 Thread Anthony
It seems selectpicker is causing a change in what gets sent to web2py. In 
the browser developer tools, can you check what form data gets sent to the 
server with and without selectpicker enabled? Maybe that will provide a 
clue.

Anthony

On Tuesday, August 21, 2018 at 4:42:30 PM UTC-4, Rodrigo Gomes wrote:
>
> jim, thank you for you time,  what is causing the error is, if i use 
> {{=form}} my code works, but if i use the form.custom as you suggested, my 
> code not work, if i 
> remove form.element(_id='no_table_cities').update(_class='selectpicker') in 
> my controller, form custom work again, so i have not idea about what is 
> goin on here, 
>
> iam using my own custom html, because, form custom, and form, generate 
> much bootstrap classes betwen my code, and iam using a custom theme, This 
> is a bit of a problem, I like to have control in my hands, since I 
> identified that web2py identifies my inputs by the id and name of the 
> element, I have not used it the old way.
>
> I think it is well related to selectpicker, because if I use any other 
> class besides this, it does not interfere with the capture of my select data
>
> terça-feira, 21 de Agosto de 2018 às 17:07:23 UTC-3, Jim S escreveu:
>>
>> Ok, now that we know the problem isn't with SQLFORM.factory lets look 
>> closer at the generated html when using {{=form}} vs the html you typed in.
>>
>> Specifically:
>>
>> > name="address_type" data-style="btn-info btn-outline-info">
>> 
>> {{for t in address_type_list:}}
>> {{=t.type}}
>> {{pass}}
>> 
>>
>> I'm curious why you're using your own custom html instead of using the 
>> custom form technique.
>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms
>>
>> {{=form.custom.begin}}
>> {{=form.custom.widget.name}}
>> {{=form.custom.widget.cpf}}
>> {{=form.custom.widget.email}}
>> {{=form.custom.widget.address_type}}
>> {{=form.custom.widget.cities}}
>> {{=form.custom.widget.person}}
>> {{=form.custom.submit}}
>> {{=form.custom.end}}
>>
>> Good luck
>>
>> -Jim
>>
>> On Tuesday, August 21, 2018 at 2:57:33 PM UTC-5, Rodrigo Gomes wrote:
>>>
>>> I just tested with {{= form}} and it really worked, so the problem is 
>>> between
>>>
>>> >> method="post">
>>>
>>> >> >> >> >>
>>> {{=form.hidden_fields()}}
>>> 
>>>
>>>  
>>> 
>>>
>>>
>>>
>>>
>>> terça-feira, 21 de Agosto de 2018 às 13:46:55 UTC-3, Jim S escreveu:

 Have you tried just displaying the form in your view using {{=form}}.  
 Then add a requires=IS_IN_DB to the fields in your model.  I'd do this 
 just 
 to make sure that SQLFORM.factory is working as expected.  Make sense?


 http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators

 -Jim

 On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote:
>
> i really think its a bug in form.factory, i tried modify by the 
> controller too, like 
> form.element(_id=no_table_cities).update(_class="selectpicker")
>
> and no sucess.
>
> terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes 
> escreveu:
>>
>> @auth.requires_login()
>> def students():
>> form = form=SQLFORM.factory(db.person, db.address)
>>
>> cities_list = db(db.cities.id>0).select(db.cities.ALL)
>> address_type_list = db(db.address_type.id>0
>> ).select(db.address_type.ALL)
>> person_list = db(db.person.id>0).select(db.person.ALL)
>>
>>
>> if form.process().accepted:
>> id = db.person.insert(**db.person._filter_fields(form.vars))
>> form.vars.person=id
>> id = db.address.insert(**db.address._filter_fields(form.vars))
>> redirect(URL('default','students'))
>> response.flash='Form Submetido com sucesso!' 
>> elif form.errors:
>> print(form.errors)
>> print(form.vars)
>> else:
>> print('please fill out the form')
>> return dict(form=form, cities_list=cities_list, 
>> address_type_list=address_type_list, 
>> person_list=person_list)
>>
>>
>> terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang 
>> escreveu:
>>>
>>> How did you define your cities_list?
>>>
>>> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes 
>>> wrote:


 Good evening, folks, I've come here to unveil a mystery, I'm 
 developing an application with web2py, (framework that I use about 3 
 years 
 ago)

 I am using sqlform.factory, passing 2 tables, being that I do this 
 to fill in a single form, table, person and address, for better 
 understanding follows my controller, 


 @auth.requires_login()
 def students():
 form = form=SQLFORM.factory(db.person, db.address)
  
 if form.process().accepted:
  

[web2py] Re: custom form web2py not work when i use selectpicker

2018-08-21 Thread Peng Wang
Did you include all the necessary files?

.selectpicker() is a function defined under bootstrap-select lib and not in 
core bootstrap library,hence you need to include that library as well

//silviomoreto.github.io/bootstrap-select/javascripts/bootstrap-select.js

//silviomoreto.github.io/bootstrap-select/stylesheets/bootstrap-select.css

HTML:

 
  All
  Businesses
  Events
  News
  Lifestyle
 

JQUERY CODE:

$('.selectpicker').selectpicker();



On Tuesday, August 21, 2018 at 1:42:30 PM UTC-7, Rodrigo Gomes wrote:
>
> jim, thank you for you time,  what is causing the error is, if i use 
> {{=form}} my code works, but if i use the form.custom as you suggested, my 
> code not work, if i 
> remove form.element(_id='no_table_cities').update(_class='selectpicker') in 
> my controller, form custom work again, so i have not idea about what is 
> goin on here, 
>
> iam using my own custom html, because, form custom, and form, generate 
> much bootstrap classes betwen my code, and iam using a custom theme, This 
> is a bit of a problem, I like to have control in my hands, since I 
> identified that web2py identifies my inputs by the id and name of the 
> element, I have not used it the old way.
>
> I think it is well related to selectpicker, because if I use any other 
> class besides this, it does not interfere with the capture of my select data
>
> terça-feira, 21 de Agosto de 2018 às 17:07:23 UTC-3, Jim S escreveu:
>>
>> Ok, now that we know the problem isn't with SQLFORM.factory lets look 
>> closer at the generated html when using {{=form}} vs the html you typed in.
>>
>> Specifically:
>>
>> > name="address_type" data-style="btn-info btn-outline-info">
>> 
>> {{for t in address_type_list:}}
>> {{=t.type}}
>> {{pass}}
>> 
>>
>> I'm curious why you're using your own custom html instead of using the 
>> custom form technique.
>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms
>>
>> {{=form.custom.begin}}
>> {{=form.custom.widget.name}}
>> {{=form.custom.widget.cpf}}
>> {{=form.custom.widget.email}}
>> {{=form.custom.widget.address_type}}
>> {{=form.custom.widget.cities}}
>> {{=form.custom.widget.person}}
>> {{=form.custom.submit}}
>> {{=form.custom.end}}
>>
>> Good luck
>>
>> -Jim
>>
>> On Tuesday, August 21, 2018 at 2:57:33 PM UTC-5, Rodrigo Gomes wrote:
>>>
>>> I just tested with {{= form}} and it really worked, so the problem is 
>>> between
>>>
>>> >> method="post">
>>>
>>> >> >> >> >>
>>> {{=form.hidden_fields()}}
>>> 
>>>
>>>  
>>> 
>>>
>>>
>>>
>>>
>>> terça-feira, 21 de Agosto de 2018 às 13:46:55 UTC-3, Jim S escreveu:

 Have you tried just displaying the form in your view using {{=form}}.  
 Then add a requires=IS_IN_DB to the fields in your model.  I'd do this 
 just 
 to make sure that SQLFORM.factory is working as expected.  Make sense?


 http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators

 -Jim

 On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote:
>
> i really think its a bug in form.factory, i tried modify by the 
> controller too, like 
> form.element(_id=no_table_cities).update(_class="selectpicker")
>
> and no sucess.
>
> terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes 
> escreveu:
>>
>> @auth.requires_login()
>> def students():
>> form = form=SQLFORM.factory(db.person, db.address)
>>
>> cities_list = db(db.cities.id>0).select(db.cities.ALL)
>> address_type_list = db(db.address_type.id>0
>> ).select(db.address_type.ALL)
>> person_list = db(db.person.id>0).select(db.person.ALL)
>>
>>
>> if form.process().accepted:
>> id = db.person.insert(**db.person._filter_fields(form.vars))
>> form.vars.person=id
>> id = db.address.insert(**db.address._filter_fields(form.vars))
>> redirect(URL('default','students'))
>> response.flash='Form Submetido com sucesso!' 
>> elif form.errors:
>> print(form.errors)
>> print(form.vars)
>> else:
>> print('please fill out the form')
>> return dict(form=form, cities_list=cities_list, 
>> address_type_list=address_type_list, 
>> person_list=person_list)
>>
>>
>> terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang 
>> escreveu:
>>>
>>> How did you define your cities_list?
>>>
>>> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes 
>>> wrote:


 Good evening, folks, I've come here to unveil a mystery, I'm 
 developing an application with web2py, (framework that I use about 3 
 years 
 ago)

 I am using sqlform.factory, passing 2 tables, being that I do this 
 to fill in a single form, table, person and address, for better 
 understanding follows my 

Re: [web2py] custom form web2py not work when i use selectpicker

2018-08-21 Thread Carlos Correia
Às 20:41 de 21-08-2018, Rodrigo Gomes escreveu:
> thanks, but the problem is not adding the selectpicker in the selects, the
> problem is that by adding it to any select it does not recognize the input 
> data
>
> terça-feira, 21 de Agosto de 2018 às 14:17:48 UTC-3, Carlos Correia escreveu:
>
> Às 00:39 de 17-08-2018, Rodrigo Gomes escreveu:
>>
>> Good evening, folks, I've come here to unveil a mystery, I'm developing
>> an application with web2py, (framework that I use about 3 years ago)
>>
>> I am using sqlform.factory, passing 2 tables, being that I do this to
>> fill in a single form, table, person and address, for better
>> understanding follows my controller, 
>>
>>
>> |
>> @auth.requires_login()defstudents():    form
>> =form=SQLFORM.factory(db.person,db.address)     
>> ifform.process().accepted:       id
>> =db.person.insert(**db.person._filter_fields(form.vars))     
>>  form.vars.person=id        id
>> =db.address.insert(**db.address._filter_fields(form.vars))     
>>  response.flash='Form Submetido com sucesso!'      elifform.errors:     
>>  print(form.errors)    else:       print('please fill out the form')
>> |
>>
>>
>>
>> if it helps, this is my model, the tables and their relationships, 
>>
>> |
>> db.define_table("person",    Field("name","string",length=50),   
>> Field("cpf","string",length=11),    Field("birthday","date",length=11), 
>>   Field("email","string",length=40),   
>> Field("registration_date","date",length=40)   
>> )db.define_table("cities",    Field("name","string"),   
>> Field("state","reference state")    )db.define_table("address_type",   
>> Field("type","string",length=100),    )db.define_table("address",   
>> Field("number","integer"),    Field("public_place","string"),   
>> Field("cep","string",length=15),    Field("complement","string"),   
>> Field("cities",'reference cities'),    Field("address_type",'reference
>> address_type'),    Field("person",'reference
>> person',writable=False,readable=False)    )
>> |
>>
>>
>>
>> This is my view
>>
>> |
>> 
>> 
>>  
>>                      
>>                            
>> 
>> 
>>  
>>                                      
>>                
>> 
>> 
>>  
>>                                      
>>                            
>> 
>> 
>>  
>>                                                                    
>>                                          
>>                              
>>   > selectpicker" 
>> id="no_table_address_type"name="address_type"data-style="btn-info
>> btn-outline-info">                                                       
>>                                         {{for t in address_type_list:}}  
>>                   > }}">{{=t.type}}                    {{pass}}        
>>                                 > m-b-20">               
>> > btn-outline-info"required>                    {{for city in
>> cities_list:}}                     > }}">{{=city.name }}           
>>         {{pass}}                                          
>>                                
>>       {{=form.hidden_fields()}}                              
>>               > btn-info"type="submit"value="Salvar">           
>> > waves-effect"data-dismiss="modal">Cancelar           
>> 
>> |
>>
>>
>>
>> now the problem: this selectpicker, simply my form can not store the
>> value of select, when I add this class, I needed it, I do not need it
>> that much, but it became a mission to understand what's happening here, I
>> gave a print em form. vars.cities and she's just like None, help please
>>
>> > 'rodg...@gmail.com ', 'registration_date' public_place ':'
>> ',' '' '' '' '' '' '' '' '' '' 'cities': None, 'address_type': None,
>> 'person': 4}>
>> -- 
>> 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
>> .
>
> Hi,
>
> I just add this piece of javascript at the end of layout.html to add the
> selectpicker class to select elements:
>
> jQuery(function(){ jQuery( 'select' ).selectpicker();
> jQuery('.selectpicker').selectpicker('refresh'); } );
> This 

[web2py] Re: custom form web2py not work when i use selectpicker

2018-08-21 Thread Jim S
I'm not aware of 'selectpicker'.  What does it offer that the default 
select widget doesn't?

I'm guessing you're also aware that you can override all of that bootstrap 
form style by creating your own formstyle and specifying it on 
SQLFORM.factory(formstyle=my_formstyle) call.

I'm not sure if this helps but just thought I'd mention it.

-Jim

On Tuesday, August 21, 2018 at 3:42:30 PM UTC-5, Rodrigo Gomes wrote:
>
> jim, thank you for you time,  what is causing the error is, if i use 
> {{=form}} my code works, but if i use the form.custom as you suggested, my 
> code not work, if i 
> remove form.element(_id='no_table_cities').update(_class='selectpicker') in 
> my controller, form custom work again, so i have not idea about what is 
> goin on here, 
>
> iam using my own custom html, because, form custom, and form, generate 
> much bootstrap classes betwen my code, and iam using a custom theme, This 
> is a bit of a problem, I like to have control in my hands, since I 
> identified that web2py identifies my inputs by the id and name of the 
> element, I have not used it the old way.
>
> I think it is well related to selectpicker, because if I use any other 
> class besides this, it does not interfere with the capture of my select data
>
> terça-feira, 21 de Agosto de 2018 às 17:07:23 UTC-3, Jim S escreveu:
>>
>> Ok, now that we know the problem isn't with SQLFORM.factory lets look 
>> closer at the generated html when using {{=form}} vs the html you typed in.
>>
>> Specifically:
>>
>> > name="address_type" data-style="btn-info btn-outline-info">
>> 
>> {{for t in address_type_list:}}
>> {{=t.type}}
>> {{pass}}
>> 
>>
>> I'm curious why you're using your own custom html instead of using the 
>> custom form technique.
>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms
>>
>> {{=form.custom.begin}}
>> {{=form.custom.widget.name}}
>> {{=form.custom.widget.cpf}}
>> {{=form.custom.widget.email}}
>> {{=form.custom.widget.address_type}}
>> {{=form.custom.widget.cities}}
>> {{=form.custom.widget.person}}
>> {{=form.custom.submit}}
>> {{=form.custom.end}}
>>
>> Good luck
>>
>> -Jim
>>
>> On Tuesday, August 21, 2018 at 2:57:33 PM UTC-5, Rodrigo Gomes wrote:
>>>
>>> I just tested with {{= form}} and it really worked, so the problem is 
>>> between
>>>
>>> >> method="post">
>>>
>>> >> >> >> >>
>>> {{=form.hidden_fields()}}
>>> 
>>>
>>>  
>>> 
>>>
>>>
>>>
>>>
>>> terça-feira, 21 de Agosto de 2018 às 13:46:55 UTC-3, Jim S escreveu:

 Have you tried just displaying the form in your view using {{=form}}.  
 Then add a requires=IS_IN_DB to the fields in your model.  I'd do this 
 just 
 to make sure that SQLFORM.factory is working as expected.  Make sense?


 http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators

 -Jim

 On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote:
>
> i really think its a bug in form.factory, i tried modify by the 
> controller too, like 
> form.element(_id=no_table_cities).update(_class="selectpicker")
>
> and no sucess.
>
> terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes 
> escreveu:
>>
>> @auth.requires_login()
>> def students():
>> form = form=SQLFORM.factory(db.person, db.address)
>>
>> cities_list = db(db.cities.id>0).select(db.cities.ALL)
>> address_type_list = db(db.address_type.id>0
>> ).select(db.address_type.ALL)
>> person_list = db(db.person.id>0).select(db.person.ALL)
>>
>>
>> if form.process().accepted:
>> id = db.person.insert(**db.person._filter_fields(form.vars))
>> form.vars.person=id
>> id = db.address.insert(**db.address._filter_fields(form.vars))
>> redirect(URL('default','students'))
>> response.flash='Form Submetido com sucesso!' 
>> elif form.errors:
>> print(form.errors)
>> print(form.vars)
>> else:
>> print('please fill out the form')
>> return dict(form=form, cities_list=cities_list, 
>> address_type_list=address_type_list, 
>> person_list=person_list)
>>
>>
>> terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang 
>> escreveu:
>>>
>>> How did you define your cities_list?
>>>
>>> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes 
>>> wrote:


 Good evening, folks, I've come here to unveil a mystery, I'm 
 developing an application with web2py, (framework that I use about 3 
 years 
 ago)

 I am using sqlform.factory, passing 2 tables, being that I do this 
 to fill in a single form, table, person and address, for better 
 understanding follows my controller, 


 @auth.requires_login()
 def students():
 form = 

[web2py] Re: custom form web2py not work when i use selectpicker

2018-08-21 Thread Rodrigo Gomes
jim, thank you for you time,  what is causing the error is, if i use 
{{=form}} my code works, but if i use the form.custom, my code not work, if 
i remove form.element(_id='no_table_cities').update(_class='selectpicker') 
in my controller, form custom work again, so i have not idea about what is 
goin on here, 

iam using my own custom html, because, form custom, and form, generate much 
bootstrap classes betwen my code, and iam using a custom theme, This is a 
bit of a problem, I like to have control in my hands, since I identified 
that web2py identifies my inputs by the id and name of the element, I have 
not used it the old way.

I think it is well related to selectpicker, because if I use any other 
class besides this, it does not interfere with the capture of my select data

terça-feira, 21 de Agosto de 2018 às 17:07:23 UTC-3, Jim S escreveu:
>
> Ok, now that we know the problem isn't with SQLFORM.factory lets look 
> closer at the generated html when using {{=form}} vs the html you typed in.
>
> Specifically:
>
>  name="address_type" data-style="btn-info btn-outline-info">
> 
> {{for t in address_type_list:}}
> {{=t.type}}
> {{pass}}
> 
>
> I'm curious why you're using your own custom html instead of using the 
> custom form technique.
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms
>
> {{=form.custom.begin}}
> {{=form.custom.widget.name}}
> {{=form.custom.widget.cpf}}
> {{=form.custom.widget.email}}
> {{=form.custom.widget.address_type}}
> {{=form.custom.widget.cities}}
> {{=form.custom.widget.person}}
> {{=form.custom.submit}}
> {{=form.custom.end}}
>
> Good luck
>
> -Jim
>
> On Tuesday, August 21, 2018 at 2:57:33 PM UTC-5, Rodrigo Gomes wrote:
>>
>> I just tested with {{= form}} and it really worked, so the problem is 
>> between
>>
>> > method="post">
>>
>> > > > >
>> {{=form.hidden_fields()}}
>> 
>>
>>  
>> 
>>
>>
>>
>>
>> terça-feira, 21 de Agosto de 2018 às 13:46:55 UTC-3, Jim S escreveu:
>>>
>>> Have you tried just displaying the form in your view using {{=form}}.  
>>> Then add a requires=IS_IN_DB to the fields in your model.  I'd do this just 
>>> to make sure that SQLFORM.factory is working as expected.  Make sense?
>>>
>>>
>>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators
>>>
>>> -Jim
>>>
>>> On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote:

 i really think its a bug in form.factory, i tried modify by the 
 controller too, like 
 form.element(_id=no_table_cities).update(_class="selectpicker")

 and no sucess.

 terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes 
 escreveu:
>
> @auth.requires_login()
> def students():
> form = form=SQLFORM.factory(db.person, db.address)
>
> cities_list = db(db.cities.id>0).select(db.cities.ALL)
> address_type_list = db(db.address_type.id>0
> ).select(db.address_type.ALL)
> person_list = db(db.person.id>0).select(db.person.ALL)
>
>
> if form.process().accepted:
> id = db.person.insert(**db.person._filter_fields(form.vars))
> form.vars.person=id
> id = db.address.insert(**db.address._filter_fields(form.vars))
> redirect(URL('default','students'))
> response.flash='Form Submetido com sucesso!' 
> elif form.errors:
> print(form.errors)
> print(form.vars)
> else:
> print('please fill out the form')
> return dict(form=form, cities_list=cities_list, 
> address_type_list=address_type_list, 
> person_list=person_list)
>
>
> terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang 
> escreveu:
>>
>> How did you define your cities_list?
>>
>> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote:
>>>
>>>
>>> Good evening, folks, I've come here to unveil a mystery, I'm 
>>> developing an application with web2py, (framework that I use about 3 
>>> years 
>>> ago)
>>>
>>> I am using sqlform.factory, passing 2 tables, being that I do this 
>>> to fill in a single form, table, person and address, for better 
>>> understanding follows my controller, 
>>>
>>>
>>> @auth.requires_login()
>>> def students():
>>> form = form=SQLFORM.factory(db.person, db.address)
>>>  
>>> if form.process().accepted:
>>>id = db.person.insert(**db.person._filter_fields(form.vars))
>>>form.vars.person=id
>>>id = db.address.insert(**db.address._filter_fields(form.vars))
>>>response.flash='Form Submetido com sucesso!' 
>>>  
>>> elif form.errors:
>>>print(form.errors)
>>> else:
>>>print('please fill out the form')
>>>
>>>
>>>
>>>
>>> if it helps, this is my model, the tables and their relationships, 
>>>
>>> 

[web2py] Re: session data type changed after upgrade to 2.17.1

2018-08-21 Thread icodk
Turned out that after the upgrade  the   form.vars.end_date and 
form.vars.end_date(both 
defined as type 'date') returns a data type str instead of a 'date' type

The form definition is:

form = SQLFORM.factory(
Field('start_date', 'date', label=T('Date range: '))
,Field('end_date', 'date', label=T(''))
,Field('amount',label=T('Total'),default=def_amount, widget=lambda f, v: 
SQLFORM.widgets.string.widget(f, v, _disabled=True))
,Field('online_order','boolean',label=T('Online 
orders'),default=session.online_order)
,Field('manual_order','boolean',label=T('Manual 
orders'),default=session.manual_order)


And then later the session vars gets 'infected'  as  str by the form.vars 
that should return 'date'

if form.process().accepted:
session.start_date=*form.vars.start_date *# here the form.vars.start_date 
is of type str
session.end_date = *form.vars.end_date   *# here the form.vars.end_date is 
of type str
session.online_order=form.vars.online_order
session.manual_order = form.vars.manual_order







On Tuesday, August 21, 2018 at 12:56:34 PM UTC+2, icodk wrote:
>
> Have:
>
> session.end_date=request.now.date()
>
> and then retrieve it as:
>
> datetimeEnd=datetime.datetime.combine(session.end_date, datetime.time.max)
>
> this all worked fine in 2.14.6
>
> but after upgrade to 2.17.1 I get:
>
> datetimeEnd=datetime.datetime.combine(session.end_date, datetime.time.max)
>
> TypeError: combine() argument 1 must be datetime.date, not str
>
>
>
>

-- 
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: custom form web2py not work when i use selectpicker

2018-08-21 Thread Jim S
Ok, now that we know the problem isn't with SQLFORM.factory lets look 
closer at the generated html when using {{=form}} vs the html you typed in.

Specifically:



{{for t in address_type_list:}}
{{=t.type}}
{{pass}}


I'm curious why you're using your own custom html instead of using the 
custom form technique.  
  
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms

{{=form.custom.begin}}
{{=form.custom.widget.name}}
{{=form.custom.widget.cpf}}
{{=form.custom.widget.email}}
{{=form.custom.widget.address_type}}
{{=form.custom.widget.cities}}
{{=form.custom.widget.person}}
{{=form.custom.submit}}
{{=form.custom.end}}

Good luck

-Jim

On Tuesday, August 21, 2018 at 2:57:33 PM UTC-5, Rodrigo Gomes wrote:
>
> I just tested with {{= form}} and it really worked, so the problem is 
> between
>
>  method="post">
>
>
> {{=form.hidden_fields()}}
> 
>
>  
> 
>
>
>
>
> terça-feira, 21 de Agosto de 2018 às 13:46:55 UTC-3, Jim S escreveu:
>>
>> Have you tried just displaying the form in your view using {{=form}}.  
>> Then add a requires=IS_IN_DB to the fields in your model.  I'd do this just 
>> to make sure that SQLFORM.factory is working as expected.  Make sense?
>>
>>
>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators
>>
>> -Jim
>>
>> On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote:
>>>
>>> i really think its a bug in form.factory, i tried modify by the 
>>> controller too, like 
>>> form.element(_id=no_table_cities).update(_class="selectpicker")
>>>
>>> and no sucess.
>>>
>>> terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes 
>>> escreveu:

 @auth.requires_login()
 def students():
 form = form=SQLFORM.factory(db.person, db.address)

 cities_list = db(db.cities.id>0).select(db.cities.ALL)
 address_type_list = db(db.address_type.id>0
 ).select(db.address_type.ALL)
 person_list = db(db.person.id>0).select(db.person.ALL)


 if form.process().accepted:
 id = db.person.insert(**db.person._filter_fields(form.vars))
 form.vars.person=id
 id = db.address.insert(**db.address._filter_fields(form.vars))
 redirect(URL('default','students'))
 response.flash='Form Submetido com sucesso!' 
 elif form.errors:
 print(form.errors)
 print(form.vars)
 else:
 print('please fill out the form')
 return dict(form=form, cities_list=cities_list, 
 address_type_list=address_type_list, 
 person_list=person_list)


 terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang escreveu:
>
> How did you define your cities_list?
>
> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote:
>>
>>
>> Good evening, folks, I've come here to unveil a mystery, I'm 
>> developing an application with web2py, (framework that I use about 3 
>> years 
>> ago)
>>
>> I am using sqlform.factory, passing 2 tables, being that I do this to 
>> fill in a single form, table, person and address, for better 
>> understanding 
>> follows my controller, 
>>
>>
>> @auth.requires_login()
>> def students():
>> form = form=SQLFORM.factory(db.person, db.address)
>>  
>> if form.process().accepted:
>>id = db.person.insert(**db.person._filter_fields(form.vars))
>>form.vars.person=id
>>id = db.address.insert(**db.address._filter_fields(form.vars))
>>response.flash='Form Submetido com sucesso!' 
>>  
>> elif form.errors:
>>print(form.errors)
>> else:
>>print('please fill out the form')
>>
>>
>>
>>
>> if it helps, this is my model, the tables and their relationships, 
>>
>> db.define_table("person",
>> Field("name", "string", length=50),
>> Field("cpf", "string", length=11),
>> Field("birthday", "date", length=11),
>> Field("email","string", length=40),
>> Field("registration_date","date", length=40)
>> )
>>
>> db.define_table("cities",
>> Field("name", "string"),
>> Field("state","reference state")
>> )
>>
>> db.define_table("address_type",
>> Field("type","string",length=100),
>> )
>>
>> db.define_table("address",
>> Field("number","integer"),
>> Field("public_place","string"),
>> Field("cep","string",length=15),
>> Field("complement","string"),
>> Field("cities",'reference cities'),
>> Field("address_type",'reference address_type'),
>> Field("person",'reference person', writable=False,readable=False)
>> )
>>
>>
>>
>>
>> This is my view 
>>
>> > method="post">
>> 
>> 
>> 
>>  

[web2py] Re: custom form web2py not work when i use selectpicker

2018-08-21 Thread Rodrigo Gomes
I just tested with {{= form}} and it really worked, so the problem is 
between



{{=form.hidden_fields()}}


 





terça-feira, 21 de Agosto de 2018 às 13:46:55 UTC-3, Jim S escreveu:
>
> Have you tried just displaying the form in your view using {{=form}}.  
> Then add a requires=IS_IN_DB to the fields in your model.  I'd do this just 
> to make sure that SQLFORM.factory is working as expected.  Make sense?
>
>
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators
>
> -Jim
>
> On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote:
>>
>> i really think its a bug in form.factory, i tried modify by the 
>> controller too, like 
>> form.element(_id=no_table_cities).update(_class="selectpicker")
>>
>> and no sucess.
>>
>> terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes 
>> escreveu:
>>>
>>> @auth.requires_login()
>>> def students():
>>> form = form=SQLFORM.factory(db.person, db.address)
>>>
>>> cities_list = db(db.cities.id>0).select(db.cities.ALL)
>>> address_type_list = db(db.address_type.id>0).select(db.address_type.ALL)
>>> person_list = db(db.person.id>0).select(db.person.ALL)
>>>
>>>
>>> if form.process().accepted:
>>> id = db.person.insert(**db.person._filter_fields(form.vars))
>>> form.vars.person=id
>>> id = db.address.insert(**db.address._filter_fields(form.vars))
>>> redirect(URL('default','students'))
>>> response.flash='Form Submetido com sucesso!' 
>>> elif form.errors:
>>> print(form.errors)
>>> print(form.vars)
>>> else:
>>> print('please fill out the form')
>>> return dict(form=form, cities_list=cities_list, 
>>> address_type_list=address_type_list, 
>>> person_list=person_list)
>>>
>>>
>>> terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang escreveu:

 How did you define your cities_list?

 On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote:
>
>
> Good evening, folks, I've come here to unveil a mystery, I'm 
> developing an application with web2py, (framework that I use about 3 
> years 
> ago)
>
> I am using sqlform.factory, passing 2 tables, being that I do this to 
> fill in a single form, table, person and address, for better 
> understanding 
> follows my controller, 
>
>
> @auth.requires_login()
> def students():
> form = form=SQLFORM.factory(db.person, db.address)
>  
> if form.process().accepted:
>id = db.person.insert(**db.person._filter_fields(form.vars))
>form.vars.person=id
>id = db.address.insert(**db.address._filter_fields(form.vars))
>response.flash='Form Submetido com sucesso!' 
>  
> elif form.errors:
>print(form.errors)
> else:
>print('please fill out the form')
>
>
>
>
> if it helps, this is my model, the tables and their relationships, 
>
> db.define_table("person",
> Field("name", "string", length=50),
> Field("cpf", "string", length=11),
> Field("birthday", "date", length=11),
> Field("email","string", length=40),
> Field("registration_date","date", length=40)
> )
>
> db.define_table("cities",
> Field("name", "string"),
> Field("state","reference state")
> )
>
> db.define_table("address_type",
> Field("type","string",length=100),
> )
>
> db.define_table("address",
> Field("number","integer"),
> Field("public_place","string"),
> Field("cep","string",length=15),
> Field("complement","string"),
> Field("cities",'reference cities'),
> Field("address_type",'reference address_type'),
> Field("person",'reference person', writable=False,readable=False)
> )
>
>
>
>
> This is my view 
>
>  method="post">
> 
> 
> 
>  name="name" type="text" placeholder="nome">
> 
> 
> 
>  type="text" placeholder="cpf">
> 
> 
> 
> 
>  name="email" type="text" placeholder="email">
> 
> 
> 
> 
> 
>  id="no_table_address_type" name="address_type" data-style="btn-info 
> btn-outline-info">
> 
> {{for t in address_type_list:}}
> {{=t.type}}
> {{pass}}
> 
> 
> 
>  data-style="btn-info btn-outline-info" required>
> {{for city in 

Re: [web2py] custom form web2py not work when i use selectpicker

2018-08-21 Thread Rodrigo Gomes
thanks, but the problem is not adding the selectpicker in the selects, the 
problem is that by adding it to any select it does not recognize the input 
data

terça-feira, 21 de Agosto de 2018 às 14:17:48 UTC-3, Carlos Correia 
escreveu:
>
> Às 00:39 de 17-08-2018, Rodrigo Gomes escreveu:
>
>
> Good evening, folks, I've come here to unveil a mystery, I'm developing an 
> application with web2py, (framework that I use about 3 years ago)
>
> I am using sqlform.factory, passing 2 tables, being that I do this to fill 
> in a single form, table, person and address, for better understanding 
> follows my controller, 
>
>
> @auth.requires_login()def students():
> form = form=SQLFORM.factory(db.person, db.address)
>  
> if form.process().accepted:
>id = db.person.insert(**db.person._filter_fields(form.vars))
>form.vars.person=id
>id = db.address.insert(**db.address._filter_fields(form.vars))
>response.flash='Form Submetido com sucesso!' 
>  
> elif form.errors:
>print(form.errors)
> else:
>print('please fill out the form')
>
>
>
>
> if it helps, this is my model, the tables and their relationships, 
>
> db.define_table("person",
> Field("name", "string", length=50),
> Field("cpf", "string", length=11),
> Field("birthday", "date", length=11),
> Field("email","string", length=40),
> Field("registration_date","date", length=40)
> )
>
> db.define_table("cities",
> Field("name", "string"),
> Field("state","reference state")
> )
>
> db.define_table("address_type",
> Field("type","string",length=100),
> )
>
> db.define_table("address",
> Field("number","integer"),
> Field("public_place","string"),
> Field("cep","string",length=15),
> Field("complement","string"),
> Field("cities",'reference cities'),
> Field("address_type",'reference address_type'),
> Field("person",'reference person', writable=False,readable=False)
> )
>
>
>
>
> This is my view 
>
>  method="post">
> 
> 
> 
>  type="text" placeholder="nome">
> 
> 
> 
>  type="text" placeholder="cpf">
> 
> 
> 
> 
>  type="text" placeholder="email">
> 
> 
> 
> 
> 
>  id="no_table_address_type" name="address_type" data-style="btn-info 
> btn-outline-info">
> 
> {{for t in address_type_list:}}
> {{=t.type}}
> {{pass}}
> 
> 
> 
>  data-style="btn-info btn-outline-info" required>
> {{for city in cities_list:}}
> {{=city.name}}
> {{pass}}
> 
> 
> 
> 
> 
> {{=form.hidden_fields()}}
> 
> 
> 
> 
> 
>  data-dismiss="modal">Cancelar
> 
> 
>
>
>
>
> now the problem: this selectpicker, simply my form can not store the value 
> of select, when I add this class, I needed it, I do not need it that much, 
> but it became a mission to understand what's happening here, I gave a print 
> em form. vars.cities and she's just like None, help please
>
>  rodg...@gmail.com ', 'registration_date' public_place ':' 
> ',' '' '' '' '' '' '' '' '' '' 'cities': None, 'address_type': None, 
> 'person': 4}>
> -- 
> 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.
>
> Hi,
> I just add this piece of javascript at the end of layout.html to add the 
> selectpicker class to select elements:
>
> jQuery(function(){
> jQuery( 'select' ).selectpicker();
> jQuery('.selectpicker').selectpicker('refresh');
> } );This adds the 'select_picker' class to everey select statement.Regards,
>
> Carlos Correia
> =
> MEMÓRIA PERSISTENTE
> GSM:  917 157 146
> e-mail: ge...@memoriapersistente.pt 
> URL: http://www.memoriapersistente.pt
> XMPP (Jabber): car...@memoriapersistente.pt  (NOVO)
> GnuPG: wwwkeys.eu.pgp.net
> URL Suporte: https://t5.m16e.com/gps
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list 

Re: [web2py] custom form web2py not work when i use selectpicker

2018-08-21 Thread Carlos Correia
Às 00:39 de 17-08-2018, Rodrigo Gomes escreveu:
>
> Good evening, folks, I've come here to unveil a mystery, I'm developing an
> application with web2py, (framework that I use about 3 years ago)
>
> I am using sqlform.factory, passing 2 tables, being that I do this to fill in
> a single form, table, person and address, for better understanding follows my
> controller, 
>
>
> |
> @auth.requires_login()defstudents():    form
> =form=SQLFORM.factory(db.person,db.address)      ifform.process().accepted:   
>    id =db.person.insert(**db.person._filter_fields(form.vars))     
>  form.vars.person=id        id
> =db.address.insert(**db.address._filter_fields(form.vars))     
>  response.flash='Form Submetido com sucesso!'      elifform.errors:     
>  print(form.errors)    else:       print('please fill out the form')
> |
>
>
>
> if it helps, this is my model, the tables and their relationships, 
>
> |
> db.define_table("person",    Field("name","string",length=50),   
> Field("cpf","string",length=11),    Field("birthday","date",length=11),   
> Field("email","string",length=40),   
> Field("registration_date","date",length=40)    )db.define_table("cities",   
> Field("name","string"),    Field("state","reference state")   
> )db.define_table("address_type",    Field("type","string",length=100),   
> )db.define_table("address",    Field("number","integer"),   
> Field("public_place","string"),    Field("cep","string",length=15),   
> Field("complement","string"),    Field("cities",'reference cities'),   
> Field("address_type",'reference address_type'),    Field("person",'reference
> person',writable=False,readable=False)    )
> |
>
>
>
> This is my view
>
> |
> 
>  
>                          
>                        
> 
>  
>                                      
>                
> 
>  
>                                            
>                      
> 
>  
>                                                                        
>                                                                        selectpicker" 
> id="no_table_address_type"name="address_type"data-style="btn-info
> btn-outline-info">                                                           
>                                     {{for t in address_type_list:}}          
>           {{=t.type}}                   
> {{pass}}                                        
>                
>  btn-outline-info"required>                    {{for city in cities_list:}}    
>                 {{=city.name}}           
>         {{pass}}                                              
>                                  
> {{=form.hidden_fields()}}                                
>              btn-info"type="submit"value="Salvar">           
>  waves-effect"data-dismiss="modal">Cancelar            
> 
> |
>
>
>
> now the problem: this selectpicker, simply my form can not store the value of
> select, when I add this class, I needed it, I do not need it that much, but it
> became a mission to understand what's happening here, I gave a print em form.
> vars.cities and she's just like None, help please
>
>  'rodgom...@gmail.com', 'registration_date' public_place ':' ',' '' '' '' '' ''
> '' '' '' '' 'cities': None, 'address_type': None, 'person': 4}>
> -- 
> 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.

Hi,

I just add this piece of javascript at the end of layout.html to add the
selectpicker class to select elements:

jQuery(function(){ jQuery( 'select' ).selectpicker();
jQuery('.selectpicker').selectpicker('refresh'); } );
This adds the 'select_picker' class to everey select statement.
Regards,

Carlos Correia
=
MEMÓRIA PERSISTENTE
GSM:  917 157 146
e-mail: ge...@memoriapersistente.pt
URL: http://www.memoriapersistente.pt
XMPP (Jabber): car...@memoriapersistente.pt (NOVO)
GnuPG: wwwkeys.eu.pgp.net
URL Suporte: https://t5.m16e.com/gps

-- 
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: custom form web2py not work when i use selectpicker

2018-08-21 Thread Jim S
Have you tried just displaying the form in your view using {{=form}}.  Then 
add a requires=IS_IN_DB to the fields in your model.  I'd do this just to 
make sure that SQLFORM.factory is working as expected.  Make sense?

http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators

-Jim

On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote:
>
> i really think its a bug in form.factory, i tried modify by the controller 
> too, like 
> form.element(_id=no_table_cities).update(_class="selectpicker")
>
> and no sucess.
>
> terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes 
> escreveu:
>>
>> @auth.requires_login()
>> def students():
>> form = form=SQLFORM.factory(db.person, db.address)
>>
>> cities_list = db(db.cities.id>0).select(db.cities.ALL)
>> address_type_list = db(db.address_type.id>0).select(db.address_type.ALL)
>> person_list = db(db.person.id>0).select(db.person.ALL)
>>
>>
>> if form.process().accepted:
>> id = db.person.insert(**db.person._filter_fields(form.vars))
>> form.vars.person=id
>> id = db.address.insert(**db.address._filter_fields(form.vars))
>> redirect(URL('default','students'))
>> response.flash='Form Submetido com sucesso!' 
>> elif form.errors:
>> print(form.errors)
>> print(form.vars)
>> else:
>> print('please fill out the form')
>> return dict(form=form, cities_list=cities_list, 
>> address_type_list=address_type_list, 
>> person_list=person_list)
>>
>>
>> terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang escreveu:
>>>
>>> How did you define your cities_list?
>>>
>>> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote:


 Good evening, folks, I've come here to unveil a mystery, I'm developing 
 an application with web2py, (framework that I use about 3 years ago)

 I am using sqlform.factory, passing 2 tables, being that I do this to 
 fill in a single form, table, person and address, for better understanding 
 follows my controller, 


 @auth.requires_login()
 def students():
 form = form=SQLFORM.factory(db.person, db.address)
  
 if form.process().accepted:
id = db.person.insert(**db.person._filter_fields(form.vars))
form.vars.person=id
id = db.address.insert(**db.address._filter_fields(form.vars))
response.flash='Form Submetido com sucesso!' 
  
 elif form.errors:
print(form.errors)
 else:
print('please fill out the form')




 if it helps, this is my model, the tables and their relationships, 

 db.define_table("person",
 Field("name", "string", length=50),
 Field("cpf", "string", length=11),
 Field("birthday", "date", length=11),
 Field("email","string", length=40),
 Field("registration_date","date", length=40)
 )

 db.define_table("cities",
 Field("name", "string"),
 Field("state","reference state")
 )

 db.define_table("address_type",
 Field("type","string",length=100),
 )

 db.define_table("address",
 Field("number","integer"),
 Field("public_place","string"),
 Field("cep","string",length=15),
 Field("complement","string"),
 Field("cities",'reference cities'),
 Field("address_type",'reference address_type'),
 Field("person",'reference person', writable=False,readable=False)
 )




 This is my view 

 >>> method="post">
 
 
 
 >>> type="text" placeholder="nome">
 
 
 
 >>> type="text" placeholder="cpf">
 
 
 
 
 >>> name="email" type="text" placeholder="email">
  

 
 
 
 >>> id="no_table_address_type" name="address_type" data-style="btn-info 
 btn-outline-info"> 

 {{for t in address_type_list:}}
 {{=t.type}}
 {{pass}}
 
 
 
 >>> data-style="btn-info btn-outline-info" required>
 {{for city in cities_list:}}
 {{=city.name}}
 {{pass}}
 
 
 
 
 
 {{=form.hidden_fields()}}
 
 
 
 
 
 >>> data-dismiss="modal">Cancelar
 
 

[web2py] Cookies and redirect

2018-08-21 Thread Carlos Correia
Hi,


Is it possible to set a cookie and redirect to another page in the same 
controller?

If yes, how? I tried this simple example but the cookie is lost if I use the
redirect...

def cookies2():
cookie_name = 'name' cookie_value = 'value' response.cookies[ cookie_name ] 
= cookie_value
response.cookies[ cookie_name ][ 'expires' ] = 24 * 3600 response.cookies[ 
cookie_name ][ 'path' ] = '/' response.cookies[ cookie_name ][ 'secure' ] = 
True redirect( URL( c='test', f='cookie_result' ) )

Thanks,

Carlos Correia

=
MEMÓRIA PERSISTENTE
GSM:  917 157 146
e-mail: ge...@memoriapersistente.pt
URL: http://www.memoriapersistente.pt
XMPP (Jabber): car...@memoriapersistente.pt (NOVO)
GnuPG: wwwkeys.eu.pgp.net
URL Suporte: https://t5.m16e.com/gps

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


0x16146576.asc
Description: application/pgp-keys


[web2py] Re: custom form web2py not work when i use selectpicker

2018-08-21 Thread Rodrigo Gomes
i really think its a bug in form.factory, i tried modify by the controller 
too, like 
form.element(_id=no_table_cities).update(_class="selectpicker")

and no sucess.

terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes escreveu:
>
> @auth.requires_login()
> def students():
> form = form=SQLFORM.factory(db.person, db.address)
>
> cities_list = db(db.cities.id>0).select(db.cities.ALL)
> address_type_list = db(db.address_type.id>0).select(db.address_type.ALL)
> person_list = db(db.person.id>0).select(db.person.ALL)
>
>
> if form.process().accepted:
> id = db.person.insert(**db.person._filter_fields(form.vars))
> form.vars.person=id
> id = db.address.insert(**db.address._filter_fields(form.vars))
> redirect(URL('default','students'))
> response.flash='Form Submetido com sucesso!' 
> elif form.errors:
> print(form.errors)
> print(form.vars)
> else:
> print('please fill out the form')
> return dict(form=form, cities_list=cities_list, 
> address_type_list=address_type_list, 
> person_list=person_list)
>
>
> terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang escreveu:
>>
>> How did you define your cities_list?
>>
>> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote:
>>>
>>>
>>> Good evening, folks, I've come here to unveil a mystery, I'm developing 
>>> an application with web2py, (framework that I use about 3 years ago)
>>>
>>> I am using sqlform.factory, passing 2 tables, being that I do this to 
>>> fill in a single form, table, person and address, for better understanding 
>>> follows my controller, 
>>>
>>>
>>> @auth.requires_login()
>>> def students():
>>> form = form=SQLFORM.factory(db.person, db.address)
>>>  
>>> if form.process().accepted:
>>>id = db.person.insert(**db.person._filter_fields(form.vars))
>>>form.vars.person=id
>>>id = db.address.insert(**db.address._filter_fields(form.vars))
>>>response.flash='Form Submetido com sucesso!' 
>>>  
>>> elif form.errors:
>>>print(form.errors)
>>> else:
>>>print('please fill out the form')
>>>
>>>
>>>
>>>
>>> if it helps, this is my model, the tables and their relationships, 
>>>
>>> db.define_table("person",
>>> Field("name", "string", length=50),
>>> Field("cpf", "string", length=11),
>>> Field("birthday", "date", length=11),
>>> Field("email","string", length=40),
>>> Field("registration_date","date", length=40)
>>> )
>>>
>>> db.define_table("cities",
>>> Field("name", "string"),
>>> Field("state","reference state")
>>> )
>>>
>>> db.define_table("address_type",
>>> Field("type","string",length=100),
>>> )
>>>
>>> db.define_table("address",
>>> Field("number","integer"),
>>> Field("public_place","string"),
>>> Field("cep","string",length=15),
>>> Field("complement","string"),
>>> Field("cities",'reference cities'),
>>> Field("address_type",'reference address_type'),
>>> Field("person",'reference person', writable=False,readable=False)
>>> )
>>>
>>>
>>>
>>>
>>> This is my view 
>>>
>>> >> method="post">
>>> 
>>> 
>>> 
>>> >> type="text" placeholder="nome">
>>> 
>>> 
>>> 
>>> >> type="text" placeholder="cpf">
>>> 
>>> 
>>> 
>>> 
>>> >> name="email" type="text" placeholder="email">
>>>   
>>>   
>>> 
>>> 
>>> 
>>> >> id="no_table_address_type" name="address_type" data-style="btn-info 
>>> btn-outline-info">  
>>>   
>>> {{for t in address_type_list:}}
>>> {{=t.type}}
>>> {{pass}}
>>> 
>>> 
>>> 
>>> >> data-style="btn-info btn-outline-info" required>
>>> {{for city in cities_list:}}
>>> {{=city.name}}
>>> {{pass}}
>>> 
>>> 
>>> 
>>> 
>>> 
>>> {{=form.hidden_fields()}}
>>> 
>>> 
>>> 
>>> 
>>> 
>>> >> data-dismiss="modal">Cancelar
>>> 
>>> 
>>> 
>>>
>>>
>>>
>>>
>>> now the problem: this selectpicker, simply my form can not store the 
>>> value of select, when I add this class, I needed it, I do not need it that 
>>> much, but it became a mission to understand what's happening here, I gave a 
>>> print em form. vars.cities and she's just like None, help please
>>>
>>> >> 'rodg...@gmail.com', 'registration_date' public_place ':' ',' '' '' '' 
>>> '' '' '' '' '' '' 'cities': None, 'address_type': None, 'person': 4}>
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book 

[web2py] Re: custom form web2py not work when i use selectpicker

2018-08-21 Thread Rodrigo Gomes
@auth.requires_login()
def students():
form = form=SQLFORM.factory(db.person, db.address)

cities_list = db(db.cities.id>0).select(db.cities.ALL)
address_type_list = db(db.address_type.id>0).select(db.address_type.ALL)
person_list = db(db.person.id>0).select(db.person.ALL)


if form.process().accepted:
id = db.person.insert(**db.person._filter_fields(form.vars))
form.vars.person=id
id = db.address.insert(**db.address._filter_fields(form.vars))
redirect(URL('default','students'))
response.flash='Form Submetido com sucesso!' 
elif form.errors:
print(form.errors)
print(form.vars)
else:
print('please fill out the form')
return dict(form=form, cities_list=cities_list, 
address_type_list=address_type_list, 
person_list=person_list)


terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang escreveu:
>
> How did you define your cities_list?
>
> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote:
>>
>>
>> Good evening, folks, I've come here to unveil a mystery, I'm developing 
>> an application with web2py, (framework that I use about 3 years ago)
>>
>> I am using sqlform.factory, passing 2 tables, being that I do this to 
>> fill in a single form, table, person and address, for better understanding 
>> follows my controller, 
>>
>>
>> @auth.requires_login()
>> def students():
>> form = form=SQLFORM.factory(db.person, db.address)
>>  
>> if form.process().accepted:
>>id = db.person.insert(**db.person._filter_fields(form.vars))
>>form.vars.person=id
>>id = db.address.insert(**db.address._filter_fields(form.vars))
>>response.flash='Form Submetido com sucesso!' 
>>  
>> elif form.errors:
>>print(form.errors)
>> else:
>>print('please fill out the form')
>>
>>
>>
>>
>> if it helps, this is my model, the tables and their relationships, 
>>
>> db.define_table("person",
>> Field("name", "string", length=50),
>> Field("cpf", "string", length=11),
>> Field("birthday", "date", length=11),
>> Field("email","string", length=40),
>> Field("registration_date","date", length=40)
>> )
>>
>> db.define_table("cities",
>> Field("name", "string"),
>> Field("state","reference state")
>> )
>>
>> db.define_table("address_type",
>> Field("type","string",length=100),
>> )
>>
>> db.define_table("address",
>> Field("number","integer"),
>> Field("public_place","string"),
>> Field("cep","string",length=15),
>> Field("complement","string"),
>> Field("cities",'reference cities'),
>> Field("address_type",'reference address_type'),
>> Field("person",'reference person', writable=False,readable=False)
>> )
>>
>>
>>
>>
>> This is my view 
>>
>> > method="post">
>> 
>> 
>> 
>> > type="text" placeholder="nome">
>> 
>> 
>> 
>> > type="text" placeholder="cpf">
>> 
>> 
>> 
>> 
>> > type="text" placeholder="email">
>>
>>  
>> 
>> 
>> 
>> > id="no_table_address_type" name="address_type" data-style="btn-info 
>> btn-outline-info">   
>>  
>> {{for t in address_type_list:}}
>> {{=t.type}}
>> {{pass}}
>> 
>> 
>> 
>> > data-style="btn-info btn-outline-info" required>
>> {{for city in cities_list:}}
>> {{=city.name}}
>> {{pass}}
>> 
>> 
>> 
>> 
>> 
>> {{=form.hidden_fields()}}
>> 
>> 
>> 
>> 
>> 
>> > data-dismiss="modal">Cancelar
>> 
>> 
>> 
>>
>>
>>
>>
>> now the problem: this selectpicker, simply my form can not store the 
>> value of select, when I add this class, I needed it, I do not need it that 
>> much, but it became a mission to understand what's happening here, I gave a 
>> print em form. vars.cities and she's just like None, help please
>>
>> > rodg...@gmail.com', 'registration_date' public_place ':' ',' '' '' '' '' 
>> '' '' '' '' '' 'cities': None, 'address_type': None, 'person': 4}>
>>
>

-- 
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: custom form web2py not work when i use selectpicker

2018-08-21 Thread Rodrigo Gomes
@auth.requires_login()
def students():
   
   form = form=SQLFORM.factory(db.person, db.address)

cities_list = db(db.cities.id>0).select(db.cities.ALL)
   address_type_list = db(db.address_type.id>0).select(db.address_type.ALL)
   person_list = db(db.person.id>0).select(db.person.ALL)


if form.process().accepted:
  id = db.person.insert(**db.person._filter_fields(form.vars))
  form.vars.person=id
  id = db.address.insert(**db.address._filter_fields(form.vars))
  redirect(URL('default','students'))
  response.flash='Form Submetido com sucesso!' 
   
elif form.errors:
  print(form.errors)
  print(form.vars)
  
else:
  
   print('please fill out the form')
   
   return dict(form=form, cities_list=cities_list, address_type_list=
address_type_list, person_list=person_list)




terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang escreveu:
>
> How did you define your cities_list?
>
> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote:
>>
>>
>> Good evening, folks, I've come here to unveil a mystery, I'm developing 
>> an application with web2py, (framework that I use about 3 years ago)
>>
>> I am using sqlform.factory, passing 2 tables, being that I do this to 
>> fill in a single form, table, person and address, for better understanding 
>> follows my controller, 
>>
>>
>> @auth.requires_login()
>> def students():
>> form = form=SQLFORM.factory(db.person, db.address)
>>  
>> if form.process().accepted:
>>id = db.person.insert(**db.person._filter_fields(form.vars))
>>form.vars.person=id
>>id = db.address.insert(**db.address._filter_fields(form.vars))
>>response.flash='Form Submetido com sucesso!' 
>>  
>> elif form.errors:
>>print(form.errors)
>> else:
>>print('please fill out the form')
>>
>>
>>
>>
>> if it helps, this is my model, the tables and their relationships, 
>>
>> db.define_table("person",
>> Field("name", "string", length=50),
>> Field("cpf", "string", length=11),
>> Field("birthday", "date", length=11),
>> Field("email","string", length=40),
>> Field("registration_date","date", length=40)
>> )
>>
>> db.define_table("cities",
>> Field("name", "string"),
>> Field("state","reference state")
>> )
>>
>> db.define_table("address_type",
>> Field("type","string",length=100),
>> )
>>
>> db.define_table("address",
>> Field("number","integer"),
>> Field("public_place","string"),
>> Field("cep","string",length=15),
>> Field("complement","string"),
>> Field("cities",'reference cities'),
>> Field("address_type",'reference address_type'),
>> Field("person",'reference person', writable=False,readable=False)
>> )
>>
>>
>>
>>
>> This is my view 
>>
>> > method="post">
>> 
>> 
>> 
>> > type="text" placeholder="nome">
>> 
>> 
>> 
>> > type="text" placeholder="cpf">
>> 
>> 
>> 
>> 
>> > type="text" placeholder="email">
>>
>>  
>> 
>> 
>> 
>> > id="no_table_address_type" name="address_type" data-style="btn-info 
>> btn-outline-info">   
>>  
>> {{for t in address_type_list:}}
>> {{=t.type}}
>> {{pass}}
>> 
>> 
>> 
>> > data-style="btn-info btn-outline-info" required>
>> {{for city in cities_list:}}
>> {{=city.name}}
>> {{pass}}
>> 
>> 
>> 
>> 
>> 
>> {{=form.hidden_fields()}}
>> 
>> 
>> 
>> 
>> 
>> > data-dismiss="modal">Cancelar
>> 
>> 
>> 
>>
>>
>>
>>
>> now the problem: this selectpicker, simply my form can not store the 
>> value of select, when I add this class, I needed it, I do not need it that 
>> much, but it became a mission to understand what's happening here, I gave a 
>> print em form. vars.cities and she's just like None, help please
>>
>> > rodg...@gmail.com', 'registration_date' public_place ':' ',' '' '' '' '' 
>> '' '' '' '' '' 'cities': None, 'address_type': None, 'person': 4}>
>>
>

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

Re: [web2py] Re: DAL MySQL text type

2018-08-21 Thread Carlos Cesar Caballero Díaz

Great, Thanks!!


El 20/08/18 a las 15:49, Anthony escribió:
On Monday, August 20, 2018 at 2:41:22 PM UTC-4, Carlos Cesar Caballero 
wrote:


Thanks Anthony, LONGTEXT is exactly what I need. But in case of
necessity, how "experimental" is that feature? Should I be worried
about unnoticed API changes?.


It's not really experimental (been there for years) -- it's just that 
no one ever updated that heading in the book. I just pushed a commit 
to the book repo removing "experimental".


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


[web2py] Re: Calling a SQLFORM.grid from SQLFORM.grid return to the index page can't figure why

2018-08-21 Thread Anthony
Is this the *exact *code? I see args=[row.id], but the query involves a 
join, so I would expect row.id to throw an exception, as it should be 
row.type_article.id.

Anthony

On Tuesday, August 21, 2018 at 9:10:39 AM UTC-4, Yann Dulondel wrote:
>
> Hello, web2py world.
> I'm new to web2py and web development.
> The index page displays a list of equipment type and has a link to a list 
> of equipment of this type.
> The index works fine but using the link redirect to the index page.
> There is no error message.
> When I replace the index code by the show_flexlist code, the equipment 
> list is displayed 
> I use MSSQL server and use the profiler to see what is the SQL command 
> pass to it, but there is none.
> I'm log in when I make a test. 
> I'm sure stupid but want to understand how to be cured.
> Best regards
> Yann
>
>
> default control
>
>
> @auth.requires_login()
> def index():
> db.type_article.articlename.writable=False
> db.type_article.id_narval.writable=False
> db.type_article.writable=False
> response.flash = T("Bonjour ")+auth.user.username
> myquery=(db.type_article.id==db.articles.condi_id)&(db.articles.
> depot_id==auth.user.id_depot)
> myfields={db.type_article.articlename,db.type_article.id}
> myheaders={'type_article.articlename':T('Type article'),'Type_article'
> :'ID'}
> default_sort_order=[db.type_article.articlename]
>
>
> type_articles=SQLFORM.grid(query=myquery
>,orderby=default_sort_order
>, deletable=False
>,editable=False
>,details=False
>, maxtextlength=64
>, paginate=25
>,create=False
>,fields=myfields
>,headers=myheaders
>,field_id=db.type_article.id
>,groupby=db.type_article.articlename|db.
> type_article.id
>,links = [lambda row: A('View flexi list',
> _href=URL("default","show_flexlist",args=[row.id]))])
> #,fields=fields,headers=headers
> return dict(message=T('Welcome to Web Braid stock!'),type_articles=
> type_articles)
> @auth.requires_login()
> def show_flexlist():
> response.flash = T("valeur ")+request.args[0]+' /' +str(auth.user.
> id_depot)
> myquery=((db.articles.condi_id==request.args(0, cast=int))&(db.
> articles.depot_id==auth.user.id_depot))
> myfields={db.articles.cod_ref,db.articles.conteneur,db.articles.
> dossier,db.articles.id}
> myheaders={'articles.cod_ref':T('Flexi Number'),'articles.conteneur':T
> ('Conteneur Number'),'articles.dossier':T('Braid reference'),'articles.id'
> :'ID'}
> default_sort_order=[db.articles.cod_ref]
>
>
> flexlist=SQLFORM.grid(query=myquery
>,orderby=default_sort_order
>, deletable=False
>,editable=False
>,details=False
>, maxtextlength=64
>, paginate=25
>,create=False
>,fields=myfields
>,headers=myheaders)
>
>
>
>
> #,fields=fields,headers=headers
> return dict(message=('test'),flexlist=flexlist)
>
>
> default/show_flexlist.html
>
>
> {{extend 'layout.html'}}
> {{block header}}
> 
>   /{{=request.application}}
> 
> {{end}}
>
>
>
>
> {{if 'message' in globals():}}
> {{=message}}
> {{pass}}
> {{=flexlist}}
>
>
> default index
> {{extend 'layout.html'}}
> {{block header}}
> 
>   /{{=request.application}}
> 
> {{end}}
> {{=A('View flexi list',_href=URL("default","show_flexlist",args=15))}}
>
>
> {{if 'message' in globals():}}
> {{=message}}
> {{pass}}
> {{=type_articles}}
>
>

-- 
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] Calling a SQLFORM.grid from SQLFORM.grid return to the index page can't figure why

2018-08-21 Thread Yann Dulondel
Hello, web2py world.
I'm new to web2py and web development.
The index page displays a list of equipment type and has a link to a list 
of equipment of this type.
The index works fine but using the link redirect to the index page.
There is no error message.
When I replace the index code by the show_flexlist code, the equipment list 
is displayed 
I use MSSQL server and use the profiler to see what is the SQL command pass 
to it, but there is none.
I'm log in when I make a test. 
I'm sure stupid but want to understand how to be cured.
Best regards
Yann


default control


@auth.requires_login()
def index():
db.type_article.articlename.writable=False
db.type_article.id_narval.writable=False
db.type_article.writable=False
response.flash = T("Bonjour ")+auth.user.username
myquery=(db.type_article.id==db.articles.condi_id)&(db.articles.depot_id
==auth.user.id_depot)
myfields={db.type_article.articlename,db.type_article.id}
myheaders={'type_article.articlename':T('Type article'),'Type_article':
'ID'}
default_sort_order=[db.type_article.articlename]


type_articles=SQLFORM.grid(query=myquery
   ,orderby=default_sort_order
   , deletable=False
   ,editable=False
   ,details=False
   , maxtextlength=64
   , paginate=25
   ,create=False
   ,fields=myfields
   ,headers=myheaders
   ,field_id=db.type_article.id
   ,groupby=db.type_article.articlename|db.
type_article.id
   ,links = [lambda row: A('View flexi list',
_href=URL("default","show_flexlist",args=[row.id]))])
#,fields=fields,headers=headers
return dict(message=T('Welcome to Web Braid stock!'),type_articles=
type_articles)
@auth.requires_login()
def show_flexlist():
response.flash = T("valeur ")+request.args[0]+' /' +str(auth.user.
id_depot)
myquery=((db.articles.condi_id==request.args(0, cast=int))&(db.articles.
depot_id==auth.user.id_depot))
myfields={db.articles.cod_ref,db.articles.conteneur,db.articles.dossier,
db.articles.id}
myheaders={'articles.cod_ref':T('Flexi 
Number'),'articles.conteneur':T('Conteneur 
Number'),'articles.dossier':T('Braid reference'),'articles.id':'ID'}
default_sort_order=[db.articles.cod_ref]


flexlist=SQLFORM.grid(query=myquery
   ,orderby=default_sort_order
   , deletable=False
   ,editable=False
   ,details=False
   , maxtextlength=64
   , paginate=25
   ,create=False
   ,fields=myfields
   ,headers=myheaders)




#,fields=fields,headers=headers
return dict(message=('test'),flexlist=flexlist)


default/show_flexlist.html


{{extend 'layout.html'}}
{{block header}}

  /{{=request.application}}

{{end}}




{{if 'message' in globals():}}
{{=message}}
{{pass}}
{{=flexlist}}


default index
{{extend 'layout.html'}}
{{block header}}

  /{{=request.application}}

{{end}}
{{=A('View flexi list',_href=URL("default","show_flexlist",args=15))}}


{{if 'message' in globals():}}
{{=message}}
{{pass}}
{{=type_articles}}

-- 
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: custom form web2py not work when i use selectpicker

2018-08-21 Thread Peng Wang
How did you define your cities_list?

On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote:
>
>
> Good evening, folks, I've come here to unveil a mystery, I'm developing an 
> application with web2py, (framework that I use about 3 years ago)
>
> I am using sqlform.factory, passing 2 tables, being that I do this to fill 
> in a single form, table, person and address, for better understanding 
> follows my controller, 
>
>
> @auth.requires_login()
> def students():
> form = form=SQLFORM.factory(db.person, db.address)
>  
> if form.process().accepted:
>id = db.person.insert(**db.person._filter_fields(form.vars))
>form.vars.person=id
>id = db.address.insert(**db.address._filter_fields(form.vars))
>response.flash='Form Submetido com sucesso!' 
>  
> elif form.errors:
>print(form.errors)
> else:
>print('please fill out the form')
>
>
>
>
> if it helps, this is my model, the tables and their relationships, 
>
> db.define_table("person",
> Field("name", "string", length=50),
> Field("cpf", "string", length=11),
> Field("birthday", "date", length=11),
> Field("email","string", length=40),
> Field("registration_date","date", length=40)
> )
>
> db.define_table("cities",
> Field("name", "string"),
> Field("state","reference state")
> )
>
> db.define_table("address_type",
> Field("type","string",length=100),
> )
>
> db.define_table("address",
> Field("number","integer"),
> Field("public_place","string"),
> Field("cep","string",length=15),
> Field("complement","string"),
> Field("cities",'reference cities'),
> Field("address_type",'reference address_type'),
> Field("person",'reference person', writable=False,readable=False)
> )
>
>
>
>
> This is my view 
>
>  method="post">
> 
> 
> 
>  type="text" placeholder="nome">
> 
> 
> 
>  type="text" placeholder="cpf">
> 
> 
> 
> 
>  type="text" placeholder="email">
> 
> 
> 
> 
> 
>  id="no_table_address_type" name="address_type" data-style="btn-info 
> btn-outline-info">
> 
> {{for t in address_type_list:}}
> {{=t.type}}
> {{pass}}
> 
> 
> 
>  data-style="btn-info btn-outline-info" required>
> {{for city in cities_list:}}
> {{=city.name}}
> {{pass}}
> 
> 
> 
> 
> 
> {{=form.hidden_fields()}}
> 
> 
> 
> 
> 
>  data-dismiss="modal">Cancelar
> 
> 
> 
>
>
>
>
> now the problem: this selectpicker, simply my form can not store the value 
> of select, when I add this class, I needed it, I do not need it that much, 
> but it became a mission to understand what's happening here, I gave a print 
> em form. vars.cities and she's just like None, help please
>
>  rodg...@gmail.com ', 'registration_date' public_place ':' 
> ',' '' '' '' '' '' '' '' '' '' 'cities': None, 'address_type': None, 
> 'person': 4}>
>

-- 
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] session data type changed after upgrade to 2.17.1

2018-08-21 Thread icodk


Have:

session.end_date=request.now.date()

and then retrieve it as:

datetimeEnd=datetime.datetime.combine(session.end_date, datetime.time.max)

this all worked fine in 2.14.6

but after upgrade to 2.17.1 I get:

datetimeEnd=datetime.datetime.combine(session.end_date, datetime.time.max)

TypeError: combine() argument 1 must be datetime.date, not str



-- 
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: response.menu links alt attribute and target="blank"

2018-08-21 Thread lyn2py
I see! Thanks Anthony

On Monday, August 20, 2018 at 8:33:15 PM UTC+8, Anthony wrote:
>
> Are you using the default layout.html in the welcome app? If so, it no 
> longer uses the MENU() helper, so the solutions you reference do not work. 
> Instead, you will have to edit the code in layout.html to do what you want.
>
> Anthony
>
> On Monday, August 20, 2018 at 4:46:22 AM UTC-4, lyn2py wrote:
>>
>> Hello,
>>
>> I am using the latest pulled version from GitHub and I am not able to use 
>> either of the solution listed by Anthony
>>
>> Version 2.17.1-stable+timestamp.2018.08.05.17.57.00
>>
>> Solution 1: 
>> ('Label', False, dict(_href=URL(...), _target='blank'))
>>
>> gave this link: http://
>> 127.0.0.1:8000/app/ctrl/index/%7B'_href':%20'/app/ctrl/func
>> ',%20'_target':%20'blank'%7D
>>
>>
>> and
>>
>> Solution 2:
>> ('', False, A('Label', _href=URL(...), _target='blank'))
>>
>> gave this link: http://127.0.0.1:8000/app/ctrl/index/%3Ca%20href= 
>>
>> But if I used the A(...) code in a controller, it prints to console and 
>> screen with correct HTML.
>>
>> Has there been a change in code? Please assist... Thanks!
>>
>>
>>
>>
>> On Monday, April 15, 2013 at 9:50:29 AM UTC+8, Anthony wrote:
>>>
>>> A menu item can be specified like this:
>>>
>>> ('Label', False, dict(_href=URL(...), _target='blank'))
>>>
>>> or this:
>>>
>>> ('', False, A('Label', _href=URL(...), _target='blank'))
>>>
>>> Note, in the second case, the third element can be any HTML helper 
>>> object (including nested helpers).
>>>
>>> Anthony
>>>
>>> On Sunday, April 14, 2013 6:09:56 PM UTC-4, BlueShadow wrote:

 Hi,
 I like to be able to set some link attributes in my response menu:
 I want some links to open in a new tab: target="blank"
 and I would love to set some alt atributes for the links in the 
 response menu.
 Is that even possible?
 thanks 

>>>

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