On Apr 26, 9:41 pm, Simon King <[EMAIL PROTECTED]> wrote:
>
> class ContainerController(object):
> """
> This is a base class for controllers which act as containers for
> resources.
> It makes it easy to have URLs of the form /container/resourcename/
> action
> Subclasses should override the get_controller_for_resource method.
> """
> def __getattr__(self, name):
> if name.startswith('_cp'):
> raise AttributeError(name)
> cache = getattr(cp.request, '_rest_cache', None)
> if not cache:
> cache = cp.request._rest_cache = {}
> controller = cache.get((self, name), None)
> if not controller:
> controller = self.get_controller_for_resource(name)
> cache[self, name] = controller
> if controller is None:
> raise AttributeError(name)
> return controller
>
> def get_controller_for_resource(self, name):
> """
> Subclasses should override this method to return an
> appropriate
> controller for the named resource. If the resource doesn't
> exist,
> the method should return None.
> """
> raise NotImplemented()
>
I should have mentioned that the above requires 'import cherrypy as cp'
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---