BG,

Welcome to the club.  I don't use T2/T3 for anything so you might keep that in mind when considering my advice.

For processing something that will happen for absolutely every request in an application, put the code you need to run in a model file.  I have a "setttings.py" model file for each of my applications that checks if the person is logged in, has a valid session and has the menu object built in their session.  If either of the first two fails, it kicks back to a login page.  In the case of the third one, it builds the menu from a database.

One note on this approach, all model code is run before controller code so if you redirect a person to the login page and the login page is in the same application, you have an infinite loop.  I solved this by putting my login page in a different application, but perhaps a cleaner solution would be to detect if you're at the login page before redirecting there.

Let me know if this is too vague.

-tim

BG wrote:
I already posted this once, but it didn't seem to appear. I apologize
if my post is just delayed and will now somehow appear twice.

I intended to use Django for a project but found it too time consuming
to learn.
With Web2py I seem to be able to "get to the code" much faster, which
is great.

I have a few questions.

What is the best approach to do repetitive stuff.
In particular I mean code you want to run no matter what controller
have been invoked.
I want to create my own account system and on every "page" I need to
check:
- Has a user has logged in?
- What permissions does the logged in user have?

Do I really have to create a module which I need to import in every
controller
which then creates an instance of my Account class and passes the
session object to
that instance?

It would be great if there was a non-controller module which would be
automatically loaded
when a controller is used. I know global variables should be used
sparingly, but this approach
would make it easier to create globals for an application if you want
them.

Normally I write PHP code, which often has globals, so maybe I just
have the wrong ideas of
how to do things. So, any advice on this would be welcome.

=== Plugins ==
I just discovered the T2/T3 plugins.
Since T2 is not an application, it was a little confusing (at first)
how to use it.
I think it would be good if there could be a separate directory and
importer for plugins. This
way you could also show them in a different list than the
applications.

It would also be great if a plugin could include some documentation
that can be seen through
its design page.

Anyways, thanks for a great framework.


  

-- 
Timothy Farrell <[email protected]>
Computer Guy
Statewide General Insurance Agency (www.swgen.com)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to