Thanks Mariano for answers,

On Feb 7, 2:11 pm, Mariano Reingart <[email protected]> wrote:
>
> You can have your shared settings in a common python module, and then
> import it in your model:
>
> from shared_settings import DB_URI
> db=DAL(DBURI)

This is obvious, what I was looking for was a web2py way of doing
this, ie without imports, using autoload or exec. Isn't a constant
defined in one of my apps' models available to other apps' models
thanks to auto execution of models?

> There is not direct support for shared views now, mainly because I think
> you may be confused about terminology.
> web2py "applications" are the similar to django "projects", so it would be
> not required to share views across applications in web2py.
>
> Anyway, a more flexible view rendering system should be possible
> (response.render already receives the template filename, extending this to
> include a path should not be a major issue, see compileapp.run_view_in)

I'm sure Massimo will take on this one because I've counted many other
users requesting or asking for project-wide layouts/views. So for now,
I guess it's not ready yet.

>
> > 3. What is the best way to create something like front controller? It
> > should include common functions for all other controllers in all apps.
>
> According the "wikipedia" definition of  front controllers, web2py
> models/controllers implement that pattern, as they "provides a centralized
> entry point for handling requests"
> You can put common application-wide functions in the models, and specific
> function in the controllers, including caching, redirecting, security, etc.

Umm, no. I am not talking about common app-wide setting, what I meant
was project wide common controller functions, like requiring login on
all (but some) controllers. It would consolidate all request handling
by channeling requests through a single handler which in turn would
carry out common behavior, which can be modified at runtime.

>
> > 4. What are the alternatives to scopes (Rails) or custom model
> > managers (Django) and model callbacks/observers (Rails) or signals
> > (Django)?
>
> I do not remember any, but there are some discussions on the developer list
> to implement some features like signals for data updates.
> Also, there are some workaround depending in your needs.

These are very essential, I am sure there must be some undocumented
features for this.

>
> > 5. What is the best place to define view helpers and how to pass them
> > to views?
>
> View helpers aren't mandatory in web2py (as a python template language is
> used).
> But, if you want to have functions to use in the views, you can put then in
> the models or in modules.

Well, putting view logic in models is a no-no but helper modules would
be of use. Thanks for the tip!

>
> > And last, is Py3k compatible version under works or planned?
>
> Yes, there are two py3k "unnoficial" versions under development:
>
> a proof of concept running under python 
> 3.2:http://code.google.com/r/reingart-web2py/source/browse/?name=py3k
>
> a manual attempt to make a python 3 alternative 
> codebase:https://github.com/cannatag/web2py-python3

Great to hear that, keep it up please.

Cheers,
Metin.

Reply via email to