On Tue, Feb 7, 2012 at 7:08 AM, amiroff <amir...@gmail.com> wrote: > Hello crowd! > > I'm relatively new to web2py and being impressed with its feature set > to build our intranet apps I am currently through my way into reading > docs. However some major questions to common functionality we > currently use popped up which I could not find answers to in > documentation, it would be really nice to get those here: > > 1. How do we configure common settings (mail, auth, sessions, db > connection) and share theme across all apps as per DRY principle? > Basically I want to use the same mail, db, auth (active directory) and > session (not mandatory though) across all apps. >
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) Although it is a bit different, see how web2conf for an example on how to store settings in a separate file (it is not imported, but it could be): http://code.google.com/p/web2conf/source/browse/models/0.py > 2. How do we use one common layout file for all apps? Is it possible > to define a custom placeholder for templates? This is very important > as we should not repeat ourselves with copying basic common layout, > css and images into all apps. That would result in maintenance > nightmare. I read somewhere it was suggested to use symlinks, but it > kinda breaks the point of compiled templates. > 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) > 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. > 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. > 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. > 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 You can search this list for further information. Best regards, Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com