• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 33. Writing New ZCML Directives > Step 2: Implementing the Directive Ha...

Step 2: Implementing the Directive Handler

You need to add the following handler to metaconfigure.py:

01 from zope.app.publisher.browser.viewmeta import page
02
03 class Redirect(object):
04    """Redirects to a specified URL."""
05    url = None
06
07    def __call__(self):
08        self.request.response.redirect(self.url)
09
10 def redirect(_context, name, url, for_=None, layer='default'):
11    # define the class that performs the redirect
12    redirectClass = type(str("Redirect %s for %s to '%s'" %(name, for_, url)),
13        (Redirect,), {'url' : url})
14
15    page(_context, name, 'zope.Public', for_, layer, class_=redirectClass)


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint