1.  I often look at the code.  You might like to use this resource...

http://www.web2py.com/examples/static/epydoc/index.html

For example look in:  gluon/tools.py  / Class Auth  
you will see the code to create the forms.

2.  Depends on how many tables and functions you have.  Unless you really 
feel that you will definitely have performance issues,  I would recommend 
keeping them all initially in the same directory   yourapp/models.   Later 
when you need to optimize for performance,  it is not so difficult to 
re-factor

Regards, David

On Wednesday, June 27, 2012 1:52:11 PM UTC+1, cyan wrote:
>
>
> Hi,
>
> 1. In the web2py book, there is an example for Auth settings, which 
> presumably resides at top-level inside a model:
>
> auth.settings.register_onaccept.append(lambda form: mail.send(to='
> [email protected]', subject='new user', message="new user email is %s' % 
> form.vars.email))
>
> and I wonder where exactly do these 'form' and 'form.vars.email' variables 
> come from and how do we know which specific variables are available for 
> which functions in web2py, such information seems to be poorly documented 
> in the manual.
>
> 2. Is it advisable to organize models into different folders named by 
> their related controllers? For example, for all account-related 
> functionalities, I create a model called 'account.py' and put it at 
> 'my_app/models/account/account.py', so that only this model will be 
> executed for all account-related requests. Similarly, a model named 
> 'content.py' is created in 'my_app/models/content/content.py', so that only 
> this model will be executed for all the requests relating to user-generated 
> content. By doing this (as opposed to put all the models in 
> 'my_app/models/'), we can avoid executing models we don't need for certain 
> requests, but we may need to duplicate some code (e.g. create db 
> connections) for different models. Is this a good practice in web2py?
>

On Wednesday, June 27, 2012 1:52:11 PM UTC+1, cyan wrote:
>
>
> Hi,
>
> 1. In the web2py book, there is an example for Auth settings, which 
> presumably resides at top-level inside a model:
>
> auth.settings.register_onaccept.append(lambda form: mail.send(to='
> [email protected]', subject='new user', message="new user email is %s' % 
> form.vars.email))
>
> and I wonder where exactly do these 'form' and 'form.vars.email' variables 
> come from and how do we know which specific variables are available for 
> which functions in web2py, such information seems to be poorly documented 
> in the manual.
>
> 2. Is it advisable to organize models into different folders named by 
> their related controllers? For example, for all account-related 
> functionalities, I create a model called 'account.py' and put it at 
> 'my_app/models/account/account.py', so that only this model will be 
> executed for all account-related requests. Similarly, a model named 
> 'content.py' is created in 'my_app/models/content/content.py', so that only 
> this model will be executed for all the requests relating to user-generated 
> content. By doing this (as opposed to put all the models in 
> 'my_app/models/'), we can avoid executing models we don't need for certain 
> requests, but we may need to duplicate some code (e.g. create db 
> connections) for different models. Is this a good practice in web2py?
>

-- 



Reply via email to