[web2py] set form value from a session object

2014-11-28 Thread Terry Toy
Hello (and Happy Thanksgiving)


I've walked through the tutorials about creating a simple model (db table) 
then using the controller and view to automatically generate forms with 
validation.  They are GREAT!

My problem is when I tried to modify the form.

For example, I created a simple model that stores timecard related data.


db.define_table(
'time_record',
Field('firstName',requires=IS_NOT_EMPTY() ),
Field('lastName',requires=IS_NOT_EMPTY() ),
Field('userId',requires=IS_NOT_EMPTY() ),
Field('clientCode', requires = IS_INT_IN_RANGE(10,20) ),
Field('dateOfWork', type='date', requires = IS_DATE() ),
Field('hours', requires = IS_FLOAT_IN_RANGE(0.1,16.0) )
)

Next, I build the controller:

def create_time_record():
return dict(form=crud.update(db.time_record,request.args(0)))

Next, I have the view:

{{extend 'layout.html'}}
{{ = form }}

Instead of the user entering the data in the form, I want to set one of the 
form fields to be invisible (or disabled) and automatically get its values 
from the session object from the log in, for 
example, session.auth.user.first_name.  I can easily display auth data (id, 
first_name, last_name) but I cannot set this data into the form.

{{ = form }} is so simple and powerful, yet how to I access a specific form 
element, set its value, and not affect the overall form validation process.

Thank You All!
Terry



-- 
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: GAE only issue extra status info as text on top of page

2011-02-01 Thread Terry
I had left a print statement in the code that I was using to debug an
issue.  When I removed the print statement, the application ran fine
on GAE.  I do not know if this was the root cause, or if there was
something about the deployment (used GAE SDK tool in both cases)

Can anyone share why (as I do not fully trust that I have found the
issue versus merely seeing coincidence)




On Feb 1, 11:26 am, Terry  wrote:
> I am complete newbie to web based application design, and new to
> web2py, so apologies if the answer is obvious.  I am doing a simple to
> do list application as a learning exercise, and so far has been the
> right balance between enough complexity to force learning a few things
> without being overwhelming.
>
> However, I have hit a small item and don't know how to address.  When
> I run the app using the web2py server, all pages render fine.  When I
> run the GAE development environment locally, all pages render fine.
> When I upload to GAE, some of the pages include the following text at
> the start of the page (rest of page renders fine) and some pages
> render the same as they do in the other two environments.
>
> The rendered page code (when a problem) looks like this:
>
> Status: 200 OK
> Set-Cookie:  session_id_todo="2001:ceba2b23-a490-44f2-86d0-
> aa1c1c93b8e4"; Path=/
> Expires: Tue, 01 Feb 2011 16:05:32 GMT
> Content-Type: text/html; charset=utf-8
> Pragma: no-cache
> Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
> check=0
>
> 
> "http://www.w3.org/TR/html4/frameset.dtd";>
> ..
>
> Could someone kindly point me in the right direction?


[web2py] GAE only issue extra status info as text on top of page

2011-02-01 Thread Terry
I am complete newbie to web based application design, and new to
web2py, so apologies if the answer is obvious.  I am doing a simple to
do list application as a learning exercise, and so far has been the
right balance between enough complexity to force learning a few things
without being overwhelming.

However, I have hit a small item and don't know how to address.  When
I run the app using the web2py server, all pages render fine.  When I
run the GAE development environment locally, all pages render fine.
When I upload to GAE, some of the pages include the following text at
the start of the page (rest of page renders fine) and some pages
render the same as they do in the other two environments.

The rendered page code (when a problem) looks like this:


Status: 200 OK
Set-Cookie:  session_id_todo="2001:ceba2b23-a490-44f2-86d0-
aa1c1c93b8e4"; Path=/
Expires: Tue, 01 Feb 2011 16:05:32 GMT
Content-Type: text/html; charset=utf-8
Pragma: no-cache
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0

http://www.w3.org/TR/html4/frameset.dtd";>
..


Could someone kindly point me in the right direction?