Exemple #1
0
def render_cachekey(fun, self):
    """
    Generates a key based on:

    * Portal URL
    * Negotiated language
    * Anonymous user flag
    * Portlet manager
    * Assignment
    * URL of collection used (instead of using _data)
    
    """
    context = Acquisition.aq_inner(self.context)

    fingerprint = self.collection_url()
    anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()

    key= "".join((
        getToolByName(Acquisition.aq_inner(self.context), 'portal_url')(),
        get_language(Acquisition.aq_inner(self.context), self.request),
        str(anonymous),
        self.manager.__name__,
        self.data.__name__,
        fingerprint))
    return key
Exemple #2
0
def _render_cachekey(fun, self):
    context = aq_inner(self.context)
    if not self.updated:
        self.update()

    if self.calendar.getUseSession():
        raise ram.DontCache()
    else:
        portal_state = getMultiAdapter((context, self.request), name=u'plone_portal_state')
        key = StringIO()
        print >> key, self.data.kw
        print >> key, portal_state.navigation_root_url()
        print >> key, cache.get_language(context, self.request)
        print >> key, self.calendar.getFirstWeekDay()

        year, month = self.getYearAndMonthToDisplay()
        print >> key, year
        print >> key, month
        navigation_root_path = self.root()
        start = DateTime('%s/%s/1' % (year, month))
        end = DateTime('%s/%s/1 23:59:59' % self.getNextMonth(year, month)) - 1

        def add(brain):
            key.write(brain.getPath())
            key.write('\n')
            key.write(brain.modified)
            key.write('\n\n')

        catalog = getToolByName(context, 'portal_catalog')
        path = navigation_root_path
        review_state = self.data.review_state or self.calendar.getCalendarStates()

        options = {}
        if navigation_root_path:
            root_content = self.context.restrictedTraverse(navigation_root_path)
            if IATTopic.providedBy(root_content):
                options = root_content.buildQuery()

        if options:
            # Topic
            options['start'] = {'query': end, 'range': 'max'}
            options['end'] = {'query': start, 'range': 'min'}
            if not options.get('review_state'):
                options['review_state'] = ''
            brains = catalog(**options)
        else:
            # Folder or site root
            brains = catalog(
                portal_type=self.calendar.getCalendarTypes(),
                start={'query': end, 'range': 'max'},
                end={'query': start, 'range': 'min'},
                review_state=review_state,
                path=path)

        for brain in brains:
            add(brain)

        return key.getvalue()
def _render_cachekey(fun, self):    
    if self.anonymous:
        raise ram.DontCache()
    
    key = StringIO()
    print >> key, self.request.URL.decode('ascii','replace')
    print >> key, get_language(aq_inner(self.context), self.request)
    if self.is_site_home:
        print >> key, self.portal.modified()
    else:
        print >> key, self.context.modified()
    return key.getvalue()
def _render_cachekey(fun, self):
    if self.anonymous:
        raise ram.DontCache()

    key = StringIO()
    print >> key, self.request.URL.decode('ascii', 'replace')
    print >> key, get_language(aq_inner(self.context), self.request)
    if self.is_site_home:
        print >> key, self.portal.modified()
    else:
        print >> key, self.context.modified()
    return key.getvalue()
def _render_cachekey(fun, self):
    context = aq_inner(self.context)
    if not self.updated:
        self.update()

    if self.calendar.getUseSession():
        raise ram.DontCache()
    else:
        portal_state = getMultiAdapter((context, self.request),
                                       name=u'plone_portal_state')
        key = StringIO()
        print >> key, [k.encode('utf-8') for k in self.data.kw]
        print >> key, self.data.review_state
        print >> key, self.data.name
        print >> key, portal_state.navigation_root_url()
        print >> key, cache.get_language(context, self.request)
        print >> key, self.calendar.getFirstWeekDay()

        year, month = self.getYearAndMonthToDisplay()
        print >> key, year
        print >> key, month
        navigation_root_path = self.root()
        start = DateTime('%s/%s/1' % (year, month))
        end = DateTime('%s/%s/1 23:59:59' % self.getNextMonth(year, month)) - 1

        catalog = getToolByName(context, 'portal_catalog')

        self.options = {}
        if navigation_root_path:
            root_content = self.context.restrictedTraverse(
                navigation_root_path)
            if IATTopic.providedBy(root_content):
                self.options = root_content.buildQuery()
            elif ICollection.providedBy(root_content):
                self.options = parseFormquery(
                    root_content,
                    root_content.getField('query').getRaw(root_content))
            print >> key, root_content.modified()

        self.options['start'] = {'query': end, 'range': 'max'}
        self.options['end'] = {'query': start, 'range': 'min'}

        _define_search_options(self, self.options)
        brains = catalog(**self.options)

        for brain in brains:
            add_cachekey(key, brain)

        return key.getvalue()
Exemple #6
0
def new_render_cachekey(fun, self):
    context = aq_inner(self.context)

    def add(brain):
        path = brain.getPath().decode('ascii', 'replace')
        return "%s\n%s\n\n" % (path, brain.modified)

    fingerprint = "".join(map(add, self._data()))

    anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()
    return "".join(
        (getToolByName(aq_inner(self.context), 'portal_url')(),
         get_language(aq_inner(self.context),
                      self.request), str(anonymous), self.manager.__name__,
         self.data.__name__, self.data.portlet_style or "", fingerprint))
def _render_cachekey(fun, self):
    context = aq_inner(self.context)
    if not self.updated:
        self.update()

    if self.calendar.getUseSession():
        raise ram.DontCache()
    else:
        portal_state = getMultiAdapter(
            (context, self.request), name=u'plone_portal_state')
        key = StringIO()
        print >> key, [k.encode('utf-8') for k in self.data.kw]
        print >> key, self.data.review_state
        print >> key, self.data.name
        print >> key, portal_state.navigation_root_url()
        print >> key, cache.get_language(context, self.request)
        print >> key, self.calendar.getFirstWeekDay()

        year, month = self.getYearAndMonthToDisplay()
        print >> key, year
        print >> key, month
        navigation_root_path = self.root()
        start = DateTime('%s/%s/1' % (year, month))
        end = DateTime('%s/%s/1 23:59:59' % self.getNextMonth(year, month)) - 1

        catalog = getToolByName(context, 'portal_catalog')

        self.options = {}
        if navigation_root_path:
            root_content = self.context.restrictedTraverse(navigation_root_path)
            if IATTopic.providedBy(root_content):
                self.options = root_content.buildQuery()
            elif ICollection.providedBy(root_content):
                self.options = parseFormquery(root_content,
                                              root_content.getField('query').getRaw(root_content))
            print >> key, root_content.modified()

        self.options['start'] = {'query': end, 'range': 'max'}
        self.options['end'] = {'query': start, 'range': 'min'}

        _define_search_options(self, self.options)
        brains = catalog(**self.options)

        for brain in brains:
            add_cachekey(key, brain)

        return key.getvalue()
def new_render_cachekey(fun, self):
    context = aq_inner(self.context)

    def add(brain):
        path = brain.getPath().decode('ascii', 'replace')
        return "%s\n%s\n\n" % (path, brain.modified)
    fingerprint = "".join(map(add, self._data()))

    anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()
    return "".join((
        getToolByName(aq_inner(self.context), 'portal_url')(),
        get_language(aq_inner(self.context), self.request),
        str(anonymous),
        self.manager.__name__,
        self.data.__name__,
        self.data.portlet_style or "",
        fingerprint))
Exemple #9
0
def _render_cachekey(fun, self):
    if self.anonymous:
        raise ram.DontCache()

    context = aq_inner(self.context)

    def add(object):
        brain = object[1]
        path = brain.getPath().decode('ascii', 'replace')
        return "%s\n%s\n%s\n\n" % (path, object[0], brain.modified)

    fingerprint = "".join(map(add, self._data()))
    anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()

    return "".join((getToolByName(aq_inner(self.context), 'portal_url')(),
                    get_language(aq_inner(self.context),
                                 self.request), str(anonymous),
                    self.manager.__name__, self.data.__name__, fingerprint))
Exemple #10
0
    def _footer_render_details_cachekey(fun, self):
        """
        Generates a key based on:

        * Current URL
        * Negotiated language
        * Anonymous user flag

        """
        context = aq_inner(self.context)

        anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()

        key= "".join((
            '/'.join(aq_inner(self.context).getPhysicalPath()),
            get_language(aq_inner(self.context), self.request),
            str(anonymous),
            ))
        return key
Exemple #11
0
def render_cachekey(fun, self):
    """
    Based on render_cachekey from plone.app.portlets.cache, without the
    fingerprint based on the portlet's catalog brains.

    Generates a key based on:

    * Portal URL
    * Negotiated language
    * Anonymous user flag
    * Portlet manager
    * Assignment

    """
    context = aq_inner(self.context)
    return "".join(
        (api.portal.get().absolute_url(), get_language(context, self.request),
         str(api.user.is_anonymous()), self.manager.__name__,
         self.data.__name__))
def _render_calendar_cachekey(fun, self):
    # Create a cachekey for calendar template
    context = aq_inner(self.context)
    if not self.updated:
        self.update()
    
    if self.calendar.getUseSession():
        raise ram.DontCache()
    else:
        key = StringIO()
        print >> key, 'AdvancedSearch'
        print >> key, self.navigation_root_url
        print >> key, cache.get_language(context, self.request)
        print >> key, self.calendar.getFirstWeekDay()
        year, month = self.getYearAndMonthToDisplay()
        print >> key, year
        print >> key, month
                
        return key.getvalue()
Exemple #13
0
def _render_cachekey(fun, self):
    context = aq_inner(self.context)
    if not self.updated:
        self.update()

    if self.calendar.getUseSession():
        raise ram.DontCache()
    else:
        portal_state = getMultiAdapter(
            (context, self.request), name='plone_portal_state')
        key = StringIO()
        print >> key, portal_state.navigation_root_url()
        print >> key, cache.get_language(context, self.request)
        print >> key, self.calendar.getFirstWeekDay()

        year, month = self.getYearAndMonthToDisplay()
        print >> key, year
        print >> key, month

        navigation_root_path = portal_state.navigation_root_path()
        start = DateTime('%s/%s/1' % (year, month))
        end = DateTime('%s/%s/1 23:59:59' % self.getNextMonth(year, month)) - 1

        def add(brain):
            key.write(brain.getPath())
            key.write('\n')
            key.write(brain.modified)
            key.write('\n\n')

        catalog = getToolByName(context, 'portal_catalog')
        path = navigation_root_path
        brains = catalog(
            portal_type=self.calendar.getCalendarTypes(),
            review_state=self.calendar.getCalendarStates(),
            start={'query': end, 'range': 'max'},
            end={'query': start, 'range': 'min'},
            path=path)

        for brain in brains:
            add(brain)

        return key.getvalue()
def _render_portlet_cachekey(fun, self):
    # Create a cachekey for calendar template
    context = aq_inner(self.context)
    if not self.updated:
        self.update()
    key = StringIO()
    year, month = self.getYearAndMonthToDisplay()
    print >> key, 'AdvancedSearch'
    print >> key, self.title
    print >> key, self.navigation_root_url
    print >> key, cache.get_language(context, self.request)
    print >> key, self.root
    print >> key, self.use_calendar
    print >> key, self.use_daterange
    print >> key, self.use_portal_types
    print >> key, self.use_keyword    
    print >> key, year
    print >> key, month
            
    return key.getvalue()
Exemple #15
0
    def _footer_render_details_cachekey(fun, self):
        """
        Generates a key based on:

        * Current URL
        * Negotiated language
        * Anonymous user flag

        """
        context = aq_inner(self.context)

        anonymous = getToolByName(context,
                                  'portal_membership').isAnonymousUser()

        key = "".join((
            '/'.join(aq_inner(self.context).getPhysicalPath()),
            get_language(aq_inner(self.context), self.request),
            str(anonymous),
        ))
        return key
Exemple #16
0
def _render_cachekey(fun, self):    
    if self.anonymous:
        raise ram.DontCache()
    
    context = aq_inner(self.context)
    
    def add(brain):    
        path = self.request.URL.decode('ascii','replace')
        return "%s\n%s\n\n" % (path,brain.has_key('lastchangedate') and brain['lastchangedate'])
    fingerprint = "".join(map(add, self._data()))

    anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()

    return "".join((
        getToolByName(aq_inner(self.context), 'portal_url')(),
        get_language(aq_inner(self.context), self.request),
        str(anonymous),
        self.manager.__name__,
        self.data.__name__,
        fingerprint))
def render_cachekey(fun, self):
    """
    Based on render_cachekey from plone.app.portlets.cache, without the
    fingerprint based on the portlet's catalog brains.

    Generates a key based on:

    * Portal URL
    * Negotiated language
    * Anonymous user flag
    * Portlet manager
    * Assignment

    """
    context = aq_inner(self.context)
    return "".join((
        api.portal.get().absolute_url(),
        get_language(context, self.request),
        str(api.user.is_anonymous()),
        self.manager.__name__,
        self.data.__name__))
Exemple #18
0
def _render_cachekey(fun, self):
    if self.anonymous:
        raise ram.DontCache()

    context = aq_inner(self.context)

    def add(brain):
        path = brain.getPath().decode('ascii', 'replace')
        return "%s\n%s\n\n" % (path, brain.modified)

    objdata = self._data()
    objalldata = [objdata.extend(self._data(k)) for k in self.typesToShow]

    fingerprint = "".join(map(add, objdata)) + "\n" + "\n".join(
        [str(k) for k in self.data.resultscount.values()])

    anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()

    return "".join((getToolByName(aq_inner(self.context), 'portal_url')(),
                    get_language(aq_inner(self.context),
                                 self.request), str(anonymous),
                    self.manager.__name__, self.data.__name__, fingerprint))
def render_cachekey(fun, self):
    """
    Based on render_cachekey from plone.app.portlets.cache, without the
    fingerprint based on the portlet's catalog brains.

    Generates a key based on:

    * Portal URL
    * Negotiated language
    * Anonymous user flag
    * Portlet manager
    * Assignment

    """
    context = aq_inner(self.context)
    anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()

    return "".join((
        getToolByName(aq_inner(self.context), 'portal_url')(),
        get_language(aq_inner(self.context), self.request),
        str(anonymous),
        self.manager.__name__,
        self.data.__name__))
Exemple #20
0
def render_cachekey(fun, self):
    """
    Generates a key based on:

    * Portal URL
    * Negotiated language
    * Anonymous user flag
    * Portlet manager
    * Assignment
    * URL of collection used (instead of using _data)
    
    """
    context = Acquisition.aq_inner(self.context)

    fingerprint = self.collection_url()
    anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()

    key = "".join(
        (getToolByName(Acquisition.aq_inner(self.context), 'portal_url')(),
         get_language(Acquisition.aq_inner(self.context),
                      self.request), str(anonymous), self.manager.__name__,
         self.data.__name__, fingerprint))
    return key
def _render_cachekey(fun, self):
    if self.anonymous:
        raise ram.DontCache()

    context = aq_inner(self.context)

    def add(object):
        brain = object[1]
        path = brain.getPath().decode("ascii", "replace")
        return "%s\n%s\n%s\n\n" % (path, object[0], brain.modified)

    fingerprint = "".join(map(add, self._data()))
    anonymous = getToolByName(context, "portal_membership").isAnonymousUser()

    return "".join(
        (
            getToolByName(aq_inner(self.context), "portal_url")(),
            get_language(aq_inner(self.context), self.request),
            str(anonymous),
            self.manager.__name__,
            self.data.__name__,
            fingerprint,
        )
    )
def _render_cachekey(fun, self):    
    if self.anonymous:
        raise ram.DontCache()
    
    context = aq_inner(self.context)
    
    def add(object):
        tname = object['tagname'].decode('ascii','ignore')
        return "%s\n%s\n\n" % (tname,object['count'])
    
    path = "/".join(self.context.getPhysicalPath()).decode('ascii', 'ignore')
    if self.is_site_home:
        path = "/".join(self.portal.getPhysicalPath()).decode('ascii', 'ignore')
    fingerprint = "".join(map(add,self._data())) + "\n" + path + "\n\n"
    
    anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()

    return "".join((
        getToolByName(aq_inner(self.context), 'portal_url')(),
        get_language(aq_inner(self.context), self.request),
        str(anonymous),
        self.manager.__name__,
        self.data.__name__,
        fingerprint))
Exemple #23
0
def _render_cachekey(fun, self):    
    if self.anonymous:
        raise ram.DontCache()
    
    context = aq_inner(self.context)
    
    def add(object):
        name = object['id'].decode('ascii','replace')
        return "%s\n%s\n\n" % (name,object['count'])
    
    path = "/".join(self.context.getPhysicalPath()).decode('ascii', 'replace')
    if self.is_site_home:
        path = "/".join(self.portal.getPhysicalPath()).decode('ascii', 'replace')
    fingerprint = "".join(map(add,self._data())) + "\n" + path + "\n\n"
    
    anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()

    return "".join((
        getToolByName(aq_inner(self.context), 'portal_url')(),
        get_language(aq_inner(self.context), self.request),
        str(anonymous),
        self.manager.__name__,
        self.data.__name__,
        fingerprint))
def _render_cachekey(fun, self):    
    if self.anonymous:
        raise ram.DontCache()
    
    context = aq_inner(self.context)
    
    def add(brain):        
        path = brain.getPath().decode('ascii', 'replace')        
        return "%s\n%s\n\n" % (path, brain.modified)
    
    objdata = self._data()
    objalldata = [objdata.extend(self._data(k)) for k in self.typesToShow]
    
    fingerprint = "".join(map(add,objdata)) + "\n" + "\n".join([str(k) for k in self.data.resultscount.values()])
    
    anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()

    return "".join((
        getToolByName(aq_inner(self.context), 'portal_url')(),
        get_language(aq_inner(self.context), self.request),
        str(anonymous),
        self.manager.__name__,
        self.data.__name__,
        fingerprint))