> Do you use any CherryPy filters? (standard or homegrown?) If so, what for?
>
> This is an important question for planning the next major release of
> TurboGears (post-1.0).
>From the standard ones, I use the baseurl filter, session filter,
sessionauthenticate filter, encoding/decoding filter and nsgmls filter
(in dev mode) all the time.
I also use a lot of homegrown filters. Basically, whenever I want a
functionality applied to a lot of my pages and don't want to specify a
decorator for each page, I write a small filter that takes care of it.
I love it and if you're going to remove filters you have to make sure
that there is some other way to a achieve the same functionality as
elegantly.
Here are a few cases where I use my own homegrown filters...
For DB access, I usually want each request to happen within a DB
transaction, so I use the following idiom for all my handlers:
try:
<start transaction>
.... code ....
db.commit()
finally:
db.rollback()
This way I make sure that even if my code fails, the transaction will
be rolled back and it will never stay in a inconsistent state.
Well, instead of writing this in all my handlers I wrote a 5-line
filter to do that for me !
Another example is my "notify filter" (that's what rails calls the
"flash"). Basically, a handler can say "notify('this message')" and
then issue a redirect and the message will appear on the following
page. I implemented this using a simple filter that stores the message
in the session. The next page checks the session, gets the message if
there is one in there and removes it.
Another example is this: I have a blogging tool that's designed to host
multiple blogs, and each of these blogs can run on its own domain name.
I have a filter that checks the domain and determines which blogs the
request is for, before calling the request handler.
Remi.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---