示例#1
0
 def constructQuery(self, context):
     users = super(MembershipUserSource, self).constructQuery(context)
     trusted = removeSecurityProxy(context)
     exclude_ids = set()
     if IContainer.providedBy(trusted):
         for member in trusted.values():
             exclude_ids.add(member.user_id)
         users = users.filter(
             sql.not_(domain.User.user_id.in_(list(exclude_ids))))
     return users
    def publishTraverse(self, request, name):
        try:
            content = getUtility(IIntIds).queryObject(int(name))
        except:
            raise NotFound(self.context, name, request)
        while not IContainer.providedBy(content) and content is not None:
            content = content.__parent__

        if content is not None:
            return content
            
        raise NotFound(self.context, name, request)
示例#3
0
 def constructQuery(self, context):
     users = super(MembershipUserSource, self).constructQuery(
         context
     )
     trusted = removeSecurityProxy(context)
     exclude_ids = set()
     if IContainer.providedBy(trusted):
         for member in trusted.values():
             exclude_ids.add(member.user_id)
         users = users.filter(
             sql.not_(domain.User.user_id.in_(list(exclude_ids)))
         )
     return users
示例#4
0
def recursiveCronSubscriber(obj):
    """distibution of cron event
    """

    if ISite.providedBy(obj):
        sitem = obj.getSiteManager()
        smList = list(sitem.getAllUtilitiesRegisteredFor(IAdmUtilCron))
        for utilObj in smList:
            if IAdmUtilCron.providedBy(utilObj) :
                globalCronUtility.subscribeToCron(utilObj)
    if IContainer.providedBy(obj):
        for (dummy_name, subObject) in obj.items():
            recursiveCronSubscriber(subObject)
示例#5
0
 def constructQuery(self, context):
     mp_query = super(MemberOfParliamentSignatorySource,
                      self).constructQuery(context)
     trusted = removeSecurityProxy(context)
     if ISignatory.providedBy(context):
         trusted = removeSecurityProxy(trusted.__parent__)
     if IContainer.providedBy(trusted):
         exclude_ids = set([member.user_id for member in trusted.values()])
         if trusted.__parent__ is not None:
             trusted_parent = removeSecurityProxy(trusted.__parent__)
             exclude_ids.add(trusted_parent.owner_id)
         return mp_query.filter(
             sql.not_(
                 domain.MemberOfParliament.user_id.in_(list(exclude_ids))))
     return mp_query
示例#6
0
def recursiveEventCrossbarSubscriber(obj):
    """distibution of eventcrossbar event
    """

    if ISite.providedBy(obj):
        sitem = obj.getSiteManager()
        smList = list(
            sitem.getAllUtilitiesRegisteredFor(IAdmUtilEventCrossbar))
        for utilObj in smList:
            if IAdmUtilEventCrossbar.providedBy(utilObj):
                globalEventCrossbarUtility.subscribeToEventCrossbar(utilObj)
    if IContainer.providedBy(obj):
        try:
            for (dummy_name, subObject) in obj.items():
                recursiveEventCrossbarSubscriber(subObject)
        except AttributeError:
            pass
示例#7
0
 def constructQuery(self, context):
     mp_query = super(MemberOfParliamentSignatorySource, 
             self).constructQuery(context)
     trusted = removeSecurityProxy(context)
     if ISignatory.providedBy(context):
         trusted = removeSecurityProxy(trusted.__parent__)
     if IContainer.providedBy(trusted):
         exclude_ids = set(
             [ member.user_id for member in trusted.values() ]
         )
         if trusted.__parent__ is not None:
             trusted_parent = removeSecurityProxy(trusted.__parent__)
             exclude_ids.add(trusted_parent.owner_id)
         return mp_query.filter(
             sql.not_(domain.MemberOfParliament.user_id.in_(
                     list(exclude_ids)
                 )
             )
         )
     return mp_query
示例#8
0
    def _buildTree(self, node):
        children = []
        for child in node.values():
            subentries = False
            if IContainer.providedBy(child):
                subentries = bool(len(child))
           
            url = absoluteURL(child, self.request)
            expanded = self.current.startswith(url)
            name = getattr(child, 'title', child.__name__)
            
            entry = {
                "text": "<a href='%s'>%s</a>" % (url, name),
                "id": self.intid.queryId(child),
                "expanded": expanded,
                }

            if expanded and subentries:
                entry['children'] = self._buildTree(child)
            else:
                entry['hasChildren'] = subentries
            children.append(entry)
        return children
示例#9
0
    def move(self):
        if not IContainer.providedBy(self.context):
            return self.update()
        # update contained children paths when the container moves
        peer = schema.fromUID(self.context.UID())
        contained = Session().query(schema.Content).filter(
            rdb.and_(schema.Content.path.startswith(peer.path),
                     schema.Content.content_id != peer.content_id))

        # get old and new paths to update contained
        old_containment_path = peer.path
        old_relative_path = peer.relative_path
        interfaces.ISerializer(self.context).update()
        new_containment_path = peer.path
        new_relative_path = peer.relative_path

        # for large trees this might be more efficient sans the
        # peer.
        for content in contained:
            content.path = content.path.replace(
                old_containment_path, new_containment_path)
            content.relative_path = content.relative_path.replace(
                old_relative_path, new_relative_path)
        Session().flush()