It certainly communicates that you are slightly struggling and your
questions are puzzling but let me try and answer some anyway.

1) The GET/POST variables arrive at your method as parameters (no
decorator involved for the most part). You may want to employ a
varargs strategy in some places.

2) The username of a logged in user is directly available as a
variable within TG.

3) The last time I put the same call in to every method; I was trying
to construct a bread crumb trail and I since discovered a much better
way of doing that which is covered here:
http://www.nabble.com/-n00b--headers-footers-t3935734.html

4) It puzzles me that you appear to "setup" each transaction when you
have a long running server process to hand.

You might find it helpful to work through a small application from the
cogbin.

Regards
  A

On Jun 30, 2:55 pm, "Daniel Fetchinson" <[EMAIL PROTECTED]>
wrote:
> Hi all, sorry for all these n00b questions but I still haven't got the
> 'right' way of using tg I guess.
>
> I have a mod_python application that I would like to port to tg. I
> wrote the mod_python app in such a way that (roughly) every page is a
> separate class and it gets instantiated upon every request. And there
> is some amount of setup code that gets triggered by every request and
> is the same for every request (opening log files, connecting to db,
> checking identity, etc). This common setup code I put into the
> __init__ of a 'main' class and every class corresponding to a page
> subclasses this 'main' class. In this way I only needed to write the
> setup code of a request once and it gets executed for every request
> (because every request instantiates a page class).
>
> Now with tg things are different because exposed objects are methods
> and not classes so I don't quite know what is the best idiom to write
> setup code only once and have it executed for every request.
> Decorators are cool but I can't pass anything to it that is specific
> to a request (like usernames and GET/POST variables). This was also
> different with mod_python because there every function/method/class
> that is exposed has access to the request object and can get stuff
> from there.
>
> Right now I put all setup code this into a function and copy the
> function call to the beginning of each and every method. This seems
> very redundant. What do others do?
>
> Cheers,
> Daniel


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to