Пример #1
0
def manage_beforeDelete(self, item, container):
    if ICanBeUndeleted.providedBy(item):
        try:
            undelete_container = IUndeleteSupport(container)
        except (ComponentLookupError, TypeError):
            undelete_container = None
        if undelete_container is not None:
            undelete_container.saveObjectInfo(item)
    ATDocument.manage_beforeDelete(self, item, container)
Пример #2
0
    def initializeArchetype(self, **kwargs):
        """called by the generated add* factory in types tool

        Overwritten to call the 'right' initializeArchetype and set PA version
        number at creation time.
        """
        ATDocument.initializeArchetype(self, **kwargs)

        self.__pa_version = CURRENT_ARTICLE_VERSION
Пример #3
0
    def initializeArchetype(self, **kwargs):
        """called by the generated add* factory in types tool

        Overwritten to call the 'right' initializeArchetype and set PA version
        number at creation time.
        """
        ATDocument.initializeArchetype(self, **kwargs)

        self.__pa_version = CURRENT_ARTICLE_VERSION
Пример #4
0
 def test_manual_aq_setting(self):
     '''
     Test __of__ operator on an object that is not connected
     to an acquisition scheme
     '''
     temp_document = ATDocument('temp_document')
     chain = aq_chain(temp_document)
     self.assertEquals(len(chain), 1)
     chain1 = aq_chain(temp_document.__of__(self.portal))
     self.assertEquals(len(chain1), 4)
Пример #5
0
    def processForm(self, data=1, metadata=0, REQUEST=None, values=None):
        ATDocument.processForm(self, data=data, metadata=metadata,
               REQUEST=REQUEST, values=values)

        request = REQUEST or self.REQUEST
        if values:
            form = values
        else:
            form = request.form

        if "attachmentFile" in form and form["attachmentFile"]:
            self.widget_attachmentsmanager_upload(state=None)
        if "imageFile" in form and form["imageFile"]:
            self.widget_imagesmanager_upload(state=None)
Пример #6
0
    def test_dictBehavior(self):
        # this test currently fails intentionally (see
        # http://dev.plone.org/collective/changeset/53298).
        # debugging it for a while shows that BTreeFolders don't
        # work as iterators for some strange reason.  while
        # "list(folder.__iter__())" works just fine, "list(folder)"
        # doesn't.  python doesn't seem to recognize the `__iter__`
        # method and instead falls back to its standard iterator
        # cycling the list via `__len__` and `__getitem__`.  however,
        # the interesting bit here is, that "list(folder.aq_base)"
        # does work, so apparently it's acquisition biting us here...
        #
        # meanwhile this bug has been fixed upstream in Zope (see
        # http://svn.zope.org/?rev=94907&view=rev), so the next release
        # should make this test pass
        #
        # update: using zope 2.10.8 makes this test pass indeed...
        self.setRoles(('Manager',))
        self.portal.invokeFactory('Folder', 'f1')
        f1 = self.portal['f1']

        from Products.ATContentTypes.content.document import ATDocument
        new_doc = ATDocument('d1')
        f1['d1'] = new_doc
        new_doc = f1['d1']  # aq-wrap

        self.assertEqual(['d1'], list(f1.keys()))  # keys
        self.assertEqual(['d1'], list(f1.iterkeys()))  # iterkeys
        try:
            self.assertEqual(['d1'], list(f1))  # iter
        except (KeyError, AttributeError):
            print('\nKnown failure: please see comments in '
                  '`test_dictBehavior`!')
        self.assertEqual(['d1'], list(f1.aq_base))  # iter (this works, weird!)
        self.assertTrue(f1.values()[0].aq_base is new_doc.aq_base)  # values
        self.assertTrue(f1.get('d1').aq_base is new_doc.aq_base)  # get
        self.assertTrue('d1' in f1)  # contains