source: products/qLocalSkin/trunk/adapters/requestannotator.py @ 1

Last change on this file since 1 was 1, checked in by myroslav, 19 years ago

Building directory structure

  • Property svn:eol-style set to native
File size: 1.0 KB
Line 
1from zope.interface import implements
2from zope.component import adapts
3from zope.publisher.interfaces.browser import IBrowserRequest
4from zope.annotation.interfaces import IAnnotations
5
6from Products.qLocalSkin.config import ANNOTATION_KEY
7from interfaces import IRequestPortalUrlAnnotator
8
9class RequestPortalUrlAnnotator(object):
10    """ Adapter for working with portal_url suffix in request's annotation. """
11
12    implements(IRequestPortalUrlAnnotator)
13    adapts(IBrowserRequest)
14
15    key = ANNOTATION_KEY
16
17    def __init__(self, request):
18        self.request = request
19        self.annotations = IAnnotations(self.request, None)
20
21    def annotate(self, value):
22        if self.annotations is not None:
23            self.annotations[self.key] = value
24            # print "################## Setted annotation on request from qLocalSkin: " + str(value)
25            return True
26        return False
27
28    def getPortalUrlSuffix(self):
29        if self.annotations is not None:
30            return self.annotations.get(self.key, '')
31        return ''
Note: See TracBrowser for help on using the repository browser.