First, to answer your question about the use:
I'm implementing my own 'identity' system in a
Turbogears
application, as their current system was incompatible with
my
application and design requirements. Its doing the same
stuff that TG
does already, but just integrated in a different way to
match some
existing database design and connection requirements
To do so, I've done 2 things
a- create a PageView filter that does this:
class FmoFilter(object):
def on_start_resource(self):
sqlalchemy.objectstore.clear()
def before_request_body(self):
set_current_pageview( FmoPageview() )
def on_end_resource( self ):
get_current_pageview().cleanup()
class FmoPageview():
def __init__():
set_request_logged_in( False )
handle_session_info()
def cleanup():
handle_user_tracking()
b- subclassed the turbogears controller to create a
'login' required.
I'm not too familiary with plain cherrypy, but TG
controllers are
basically just the root directory mapping for a cherrypy
tree.
What I have is essentially a condensed version of what TG
already does
(the first 3 and last 2 lines are the same, i just cut out a
bunch of
its dynamic predicate checking and replaced with a boolcheck
function )
class SecuredController(tg.controllers.Controller):
def __getattribute__( self, name ):
if name[:3]=="_cp":
return
tg.controllers.Controller.__getattribute__(self,name)
if get_current_filter_phase() ==
'before_main':
if not get_request_logged_in():
raise
SecuredControllerFailure("/login/login_required"
)
value= object.__getattribute__(self,name)
return value
class
SecuredControllerFailure(cherrypy.InternalRedirect):
def __init__(self,url):
if callable(url):
url= url()
cherrypy.InternalRedirect.__init__(self, url)
to get part b working, i needed to know the current filter
phase, as TG
internally makes calls to the controller class and cherrypy
already
does as well.
since the bool information is set during on_start_resource,
it would
always raise a redirect. and since redirects aren't
processed until
before_main, it would just log a bunch of errors until then
so in this case, the way to handle this for me, was to just
log what
the current filter stage is, and create a dict of 'seen'
filter stages
that I can just check against.
its not perfect solution - and it is complicated by the
ordering of
filters within an application. But it solved my dilemma.
That said... Secondly, I do a lot of work with mod_perl
which aside
from dynamic generation lets me script the entire apache
filtering/brigade process through hooks. It's awesome and
has probably
spoiled me with script/server interaction. I like being
able to find
out where the server is at.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|