Пример #1
0
 def __contains__(self, value):
     if isinstance(value, basestring):
         uid = value
     else:
         uid = IUUID(value)
     if uid[0] == '/':
         # it is a path query
         site = getSite()
         site_path = '/'.join(site.getPhysicalPath())
         path = os.path.join(site_path, uid.lstrip('/'))
         if self.search_catalog({'path': {'query': path, 'depth': 0}}):
             return True
     else:
         if self.search_catalog({'UID': uid}):
             return True
Пример #2
0
 def __contains__(self, value):
     if isinstance(value, basestring):
         uid = value
     else:
         uid = IUUID(value)
     if uid[0] == '/':
         # it is a path query
         site = getSite()
         site_path = '/'.join(site.getPhysicalPath())
         path = os.path.join(site_path, uid.lstrip('/'))
         if self.search_catalog({'path': {'query': path, 'depth': 0}}):
             return True
     else:
         if self.search_catalog({'UID': uid}):
             return True
Пример #3
0
    def __contains__(self, value):
        """used during validation to make sure the selected item is found with
        the specified query.

        value can be either a string (hex value of uuid or path) or a plone
        content object.
        """
        if not isinstance(value, basestring):
            # here we have a content and fetch the uuid as hex value
            value = IUUID(value)
        # else we have uuid hex value or path

        if value.startswith('/'):
            # it is a path query
            site = getSite()
            site_path = '/'.join(site.getPhysicalPath())
            path = os.path.join(site_path, value.lstrip('/'))
            query = {'path': {'query': path, 'depth': 0}}
        else:
            # its a uuid
            query = {'UID': value}
        return bool(self.search_catalog(query))
Пример #4
0
    def __contains__(self, value):
        """used during validation to make sure the selected item is found with
        the specified query.

        value can be either a string (hex value of uuid or path) or a plone
        content object.
        """
        if not isinstance(value, basestring):
            # here we have a content and fetch the uuid as hex value
            value = IUUID(value)
        # else we have uuid hex value or path

        if value.startswith('/'):
            # it is a path query
            site = getSite()
            site_path = '/'.join(site.getPhysicalPath())
            path = os.path.join(site_path, value.lstrip('/'))
            query = {'path': {'query': path, 'depth': 0}}
        else:
            # its a uuid
            query = {'UID': value}
        return bool(self.search_catalog(query))