Ejemplo n.º 1
0
def moved_handler(obj, event):
    """Remove object from uid_catalog and add it back"""
    # Not sure if this is the proper way to handle it.
    # it is needed because of what happens in Products.ZCatalog.Catalog.py
    # line 317.
    # When path has changed, the object cannot be found, and we end up with
    # old and invalid uids.
    uid_catalog, ref_catalog = _get_catalogs(obj)
    uid = IUUID(obj.aq_base, None)

    if uid:
        results = uid_catalog(UID=uid)

        if len(results) > 0:
            old_obj = results[0]
            uid_catalog.uncatalog_object(old_obj.getPath())
            path = '/'.join(obj.getPhysicalPath())
            uid_catalog.catalog_object(obj, path)

    #  AT API
    annotations = IATReferenceable(obj)._getReferenceAnnotations()
    if not annotations:
        return

    for ref in annotations.objectValues():
        url = getRelURL(ref_catalog, ref.getPhysicalPath())
        if event.oldName and event.newName:
            url = event.oldName + url[len(event.newName):]
        uid_catalog_rid = uid_catalog.getrid(url)
        ref_catalog_rid = ref_catalog.getrid(url)
        if uid_catalog_rid is not None:
            uid_catalog.uncatalog_object(url)
        if ref_catalog_rid is not None:
            ref_catalog.uncatalog_object(url)
Ejemplo n.º 2
0
 def _afterRename(self, context):
     """We have been renamed -> set relationship attributes on refs."""
     ref_ctl = getToolByName(context, REFERENCE_CATALOG)
     refs = self.__of__(context).getRefs(RELATIONSHIP_RULESETTOREF)
     for ref in refs:
         ref.relationship = self.getId()
         url = getRelURL(aq_parent(aq_inner(ref)), ref.getPhysicalPath())
         ref_ctl.catalog_object(ref, url, idxs=['relationship'])
Ejemplo n.º 3
0
 def _afterRename(self, context):
     """We have been renamed -> set relationship attributes on refs."""
     ref_ctl = getToolByName(context, REFERENCE_CATALOG)
     refs = self.__of__(context).getRefs(RELATIONSHIP_RULESETTOREF)
     for ref in refs:
         ref.relationship = self.getId()
         url = getRelURL(aq_parent(aq_inner(ref)), ref.getPhysicalPath())
         ref_ctl.catalog_object(ref, url, idxs=['relationship'])
Ejemplo n.º 4
0
    def manage_afterAdd(self, item, container):
        Referenceable.manage_afterAdd(self, item, container)

        # when copying a full site containe is the container of the plone site
        # and item is the plone site (at least for objects in portal root)
        base = container
        rc = getToolByName(container, REFERENCE_CATALOG)
        url = getRelURL(base, self.getPhysicalPath())
        rc.catalog_object(self, url)
Ejemplo n.º 5
0
 def manage_afterAdd(self, item, container):
     ct = getToolByName(container, config.REFERENCE_CATALOG, None)
     self._register(reference_manager=ct)
     self._updateCatalog(container)
     self._referenceApply('manage_afterAdd', item, container)
     base = container
     rc = getToolByName(container, config.REFERENCE_CATALOG)
     url = getRelURL(base, self.getPhysicalPath())
     rc.catalog_object(self, url)
Ejemplo n.º 6
0
 def manage_afterAdd(self, item, container):
     ct = getToolByName(container, config.REFERENCE_CATALOG, None)
     self._register(reference_manager=ct)
     self._updateCatalog(container)
     self._referenceApply('manage_afterAdd', item, container)
     base = container
     rc = getToolByName(container, config.REFERENCE_CATALOG)
     url = getRelURL(base, self.getPhysicalPath())
     rc.catalog_object(self, url)
Ejemplo n.º 7
0
def modified_handler(obj, event):
    """Reindex object in uid_catalog"""
    uid_catalog, ref_catalog = _get_catalogs(obj)
    path = '/'.join(obj.getPhysicalPath())
    uid_catalog.catalog_object(obj, path)

    #  AT API
    annotations = IATReferenceable(obj)._getReferenceAnnotations()
    if not annotations:
        return

    for ref in annotations.objectValues():
        url = getRelURL(ref_catalog, ref.getPhysicalPath())
        uid_catalog.catalog_object(ref, url)
        ref_catalog.catalog_object(ref, url)
        ref._catalogRefs(uid_catalog, uid_catalog, ref_catalog)
Ejemplo n.º 8
0
    def _pfFixup(self, obj):

        # the creation of contained objects in initializeArchetypes
        # leaves catalog orphans for the portal_factory objects.
        #
        # this solves the problem by removing them from the
        # portal_catalog and uid_catalog,
        # hopefully not causing other problems in the process.

        if 'portal_factory' in obj.getPhysicalPath():
            # remove from portal_catalog
            obj.unindexObject()

            # remove from uid_catalog
            uid_catalog = getToolByName(self, 'uid_catalog', None)
            uid_catalog.uncatalog_object(getRelURL(self, obj.getPhysicalPath()))

        else:
            obj.reindexObject()
Ejemplo n.º 9
0
    def _pfFixup(self, obj):

        # the creation of contained objects in initializeArchetypes
        # leaves catalog orphans for the portal_factory objects.
        #
        # this solves the problem by removing them from the
        # portal_catalog and uid_catalog,
        # hopefully not causing other problems in the process.

        if 'portal_factory' in obj.getPhysicalPath():
            # remove from portal_catalog
            obj.unindexObject()

            # remove from uid_catalog
            uid_catalog = getToolByName(self, 'uid_catalog', None)
            uid_catalog.uncatalog_object(getRelURL(self, obj.getPhysicalPath()))

        else:
            obj.reindexObject()
Ejemplo n.º 10
0
    def _catalogRefs(self, aq, uc=None, rc=None):
        ruleset.RLMWithBrains._catalogRefs(self,aq,uc,rc)
        
        for name in inf_range():
            if not shasattr(self, name):
                break

            obj=getattr(self,name)
            if obj:
                #import pdb;pdb.set_trace()
                if not uc:
                    uc = getToolByName(aq, config.UID_CATALOG)
                if not rc:
                    rc = getToolByName(aq, config.REFERENCE_CATALOG)
    
                url = getRelURL(uc, obj.getPhysicalPath())
                uc.catalog_object(obj, url)
                #rc.catalog_object(obj, url)
                
                obj._catalogRefs(uc, uc, rc)
Ejemplo n.º 11
0
    def _catalogRefs(self, aq, uc=None, rc=None):
        ruleset.RLMWithBrains._catalogRefs(self, aq, uc, rc)

        for name in inf_range():
            if not shasattr(self, name):
                break

            obj = getattr(self, name)
            if obj:
                #import pdb;pdb.set_trace()
                if not uc:
                    uc = getToolByName(aq, config.UID_CATALOG)
                if not rc:
                    rc = getToolByName(aq, config.REFERENCE_CATALOG)

                url = getRelURL(uc, obj.getPhysicalPath())
                uc.catalog_object(obj, url)
                #rc.catalog_object(obj, url)

                obj._catalogRefs(uc, uc, rc)
Ejemplo n.º 12
0
    def _catalogRefs(self, aq, uc=None, rc=None):
        ruleset.RLMWithBrains._catalogRefs(self,aq,uc,rc)
        
        # Use the PortalFolderBase implementation to avoid the false
        # result from a bogus inheritence of SimpleItem
        names = PortalFolderBase.objectIds(self)
        
        for name in names:
            if not shasattr(self, name):
                break

            obj=getattr(self,name)
            if obj:
                #import pdb;pdb.set_trace()
                if not uc:
                    uc = getToolByName(aq, config.UID_CATALOG)
                if not rc:
                    rc = getToolByName(aq, config.REFERENCE_CATALOG)
    
                url = getRelURL(uc, obj.getPhysicalPath())
                uc.catalog_object(obj, url)
                #rc.catalog_object(obj, url)
                
                obj._catalogRefs(uc, uc, rc)
Ejemplo n.º 13
0
 def manage_beforeDelete(self, item, container):
     Referenceable.manage_beforeDelete(self, item, container)
     rc = getToolByName(container, REFERENCE_CATALOG)
     url = getRelURL(container, self.getPhysicalPath())
     rc.uncatalog_object(url)
Ejemplo n.º 14
0
 def _catalogObject(self, obj, path):
     """Catalog the object. The object will be cataloged with the absolute
        path in case we don't pass the relative url.
     """
     url = getRelURL(self, obj.getPhysicalPath())
     self.catalog_object(obj, url)
Ejemplo n.º 15
0
 def _catalogObject(self, obj, path):
     """Catalog the object. The object will be cataloged with the absolute
        path in case we don't pass the relative url.
     """
     url = getRelURL(self, obj.getPhysicalPath())
     self.catalog_object(obj, url)