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

2018-08-16 Thread Rodrigo Gomes

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 















  
  



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




{{for city in cities_list:}}
{{=city.name}}
{{pass}}





{{=form.hidden_fields()}}





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



-- 
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: how to get request.vars.value to controller

2018-08-16 Thread Dave S


On Thursday, August 16, 2018 at 1:53:18 AM UTC-7, Lovedie JC wrote:
>
> Sorry am trying to understand this statement: "If you're trying to look at 
> the the row you just inserted, db.post.insert() returns the id of the new 
> tuple, and that should allow your select() to be done by id."
> regards
>

I'm guessing that you want something like

def progress_view():
form = SQLFORM(Post, formstyle='table3cols').process()
if form.errors or "name" not in request.vars:
response.flash = "please enter a name"
return dict(form = form, name = "", r_id = None)
r_id = db.post.insert(name=request.vars.name)
row = db.post(r_id)
return dict(form = form, name = row.name, id = r_id)

I just noticed that you have Post in the SQLFORM() and post in the separate 
insert.  If these are both supposed to be Post (or both post), then you 
don't need the separate insert, and the new row is

 r_id = form.vars.id


You might want to review chapters 6 and 7 of the book, because I think 
you've made things more complicated than they should be.

/dps





> On Thu, 16 Aug 2018 at 01:05, Dave S > 
> wrote:
>
>>
>>
>> On Wednesday, August 15, 2018 at 8:12:37 AM UTC-7, lbjc...@gmail.com 
>> wrote:
>>>
>>> Am puzzled by this, that I cant post text from request.vars value to 
>>> database and when refreshing, the text is there but I cant access this 
>>> value to controller functions.
>>> This is my code:
>>> def progress_view():
>>> form = SQLFORM(Post, formstyle='table3cols').process()
>>> if request.vars:
>>> r = [request.vars.name]
>>> codes.append(r[0])
>>> db.post.insert(name=codes[0])
>>> #db(db.post.id > 11).update(message=codes[0])
>>> row = db(db.post.author== auth.user.id).select(db.post.id, 
>>> db.post.name, orderby=~db.post.id, limitby=(0,1)).first()
>>> code = row.name if row else None
>>> return dict(code=code)
>>> Is there a way of accessing the CURRENT value from request.vars to 
>>> controller ? like append to a list without refreshing the page
>>> Is there a javascript/jquery function that can do DAL refresh?
>>>
>>
>> I think there may be some confusion, because you *are* accessing the 
>> current value of request.vars.name in the controller,
>> which you put in a list and assign to r.  Perhaps you want to show it in 
>> the *view*, but you aren't returning anything but code to the view.  code 
>> is set to row.name, where you take the first tuple of the select() 
>> results (which are in reverse order).
>>
>> If you're trying to look at the the row you just inserted, 
>> db.post.insert() returns the id of the new tuple, and that should allow 
>> your select() to be done by id.
>>
>> If I misunderstood what you're trying to do, try explaining again what 
>> your workflow is and what you want to happen.
>>
>> Dave
>> /dps
>>
>>
>>
>>
>> -- 
>> 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] DAL MySQL text type

2018-08-16 Thread Carlos Cesar Caballero Díaz
Hi guys, what kind of data type uses pydal in MySQL for "text" type?, if 
it is TEXT, is possible to set it for using MEDIUMTEXT or LONGTEXT?



Greetings.


--
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: how to get request.vars.value to controller

2018-08-16 Thread Lovedie JC
Sorry am trying to understand this statement: "If you're trying to look at
the the row you just inserted, db.post.insert() returns the id of the new
tuple, and that should allow your select() to be done by id."
regards

On Thu, 16 Aug 2018 at 01:05, Dave S  wrote:

>
>
> On Wednesday, August 15, 2018 at 8:12:37 AM UTC-7, lbjc...@gmail.com
> wrote:
>>
>> Am puzzled by this, that I cant post text from request.vars value to
>> database and when refreshing, the text is there but I cant access this
>> value to controller functions.
>> This is my code:
>> def progress_view():
>> form = SQLFORM(Post, formstyle='table3cols').process()
>> if request.vars:
>> r = [request.vars.name]
>> codes.append(r[0])
>> db.post.insert(name=codes[0])
>> #db(db.post.id > 11).update(message=codes[0])
>> row = db(db.post.author== auth.user.id).select(db.post.id,
>> db.post.name, orderby=~db.post.id, limitby=(0,1)).first()
>> code = row.name if row else None
>> return dict(code=code)
>> Is there a way of accessing the CURRENT value from request.vars to
>> controller ? like append to a list without refreshing the page
>> Is there a javascript/jquery function that can do DAL refresh?
>>
>
> I think there may be some confusion, because you *are* accessing the
> current value of request.vars.name in the controller,
> which you put in a list and assign to r.  Perhaps you want to show it in
> the *view*, but you aren't returning anything but code to the view.  code
> is set to row.name, where you take the first tuple of the select()
> results (which are in reverse order).
>
> If you're trying to look at the the row you just inserted,
> db.post.insert() returns the id of the new tuple, and that should allow
> your select() to be done by id.
>
> If I misunderstood what you're trying to do, try explaining again what
> your workflow is and what you want to happen.
>
> Dave
> /dps
>
>
>
>
> --
> 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.