jvanasco wrote:
> 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.
> ...
> 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
>
> I needed to know the current filter phase, as TG
> internally makes calls to the controller class
> and cherrypy already does as well.
I think I understand. There's certainly a design flaw in
CherryPy 2, in that you cannot raise InternalRedirect from
anywhere other than a before_main filter method (or a
controller method/page handler). And although I think your
specific case can be addressed in another fashion (see next
para), CherryPy might benefit from something like
mod_perl's "current_callback" function. Thanks
for the idea (and especially the use case ;)!
However, I'm a bit confused about the above code...it seems
that, if the "current phase" is not
"before_main", then you go ahead and grant
access anyway. If you're going to do that, then you might
as well write:
class LoginFilter:
def before_main(self):
if not get_request_logged_in():
raise
SecuredControllerFailure("/login/login_required"
)
class SecuredController(tg.controllers.Controller):
_cp_filters = [LoginFilter()]
...right? That is, rather than test for authorization 100
times and ignore the first 99 failures, just test once at
the right time. That's probably a naive recommendation,
because I missed some requirement. But perhaps the different
approach will inspire you toward a simpler solution. ;)
Robert Brewer
System Architect
Amor Ministries
fumanchu amor.org
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
|