Esempio n. 1
0
def getArchetypesObjectKey(context):
    """Get a key for an Archetypes object. This will be a string
    representation of its intid, unless it is in the portal_factory, in
    which case it'll be the a string like
    "${parent_intid}:portal_factory/${portal_type}"
    """
    
    portal_factory = getToolByName(context, 'portal_factory', None)
    if portal_factory is None or not portal_factory.isTemporary(context):
        return getDefaultKey(context)
    
    tempFolder = aq_parent(context)
    folder = aq_parent(aq_parent(tempFolder))
    
    defaultKey = getDefaultKey(folder)
    if defaultKey is None:
        # probably the portal root
        defaultKey = '0'
    
    return "%s:%s" % (defaultKey, tempFolder.getId(),)
 def _get_adapted_request(self):
     # returns the adapted request for the draft stuff
     adapted_request = ICurrentDraftManagement(self.request, None)
     adapted_request.userId = getCurrentUserId()
     adapted_request.targetKey = getDefaultKey(self.context)
     return adapted_request
Esempio n. 3
0
 def test_getDefaultKey(self):
     uuid = IUUID(self.folder)
     self.assertEquals(str(uuid), getDefaultKey(self.folder))
Esempio n. 4
0
 def test_getDefaultKey(self):
     uuid = IUUID(self.folder)
     self.assertEqual(str(uuid), getDefaultKey(self.folder))
Esempio n. 5
0
 def test_getDefaultKey(self):
     intids = getUtility(IIntIds)
     intid = intids.getId(self.folder)
     self.assertEquals(str(intid), getDefaultKey(self.folder))