def __init__(self, id): """ Initialization """ CMFBTreeFolder.__init__(self, id) self.id = id self.items = PersistentDict() self.plomino_modification_time = DateTime().toZone(TIMEZONE)
def __init__(self, id): """ Initialization """ CMFBTreeFolder.__init__(self, id) self.id = id self.items = PersistentDict() self.plomino_modification_time = DateTime().toZone('UTC')
def test_getSyndicatableContent(self): # http://www.zope.org/Collectors/CMF/369 # Make sure we use a suitable base class call when determining # syndicatable content from Products.CMFCore.PortalFolder import PortalFolder from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder from Products.CMFCore.TypesTool import TypesTool PERIOD = 'hourly' FREQUENCY = 4 NOW = datetime.now() MAX_ITEMS = 42 getSiteManager().registerUtility(TypesTool(), ITypesTool) self.app._setObject('pf', PortalFolder('pf')) self.app._setObject('bf', CMFBTreeFolder('bf')) tool = self._makeOne() tool.period = PERIOD tool.frequency = FREQUENCY tool.base = NOW tool.enable() tool.max_items = MAX_ITEMS self.assertEqual(len(tool.getSyndicatableContent(self.app.pf)), 0) self.assertEqual(len(tool.getSyndicatableContent(self.app.bf)), 0)
def __getitem__(self, key): """ Override BTreeFolder __getitem__ """ if key in self.Schema().keys() and key[:1] != "_": # XXX 2.2 accessor = self.Schema()[key].getAccessor(self) if accessor is not None: return accessor() return CMFBTreeFolder.__getitem__(self, key)
def test_getSyndicatableContent(self): # http://www.zope.org/Collectors/CMF/369 # Make sure we use a suitable base class call when determining # syndicatable content from Products.CMFCore.PortalFolder import PortalFolder from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder from Products.CMFCore.TypesTool import TypesTool PERIOD = 'hourly' FREQUENCY = 4 NOW = DateTime() MAX_ITEMS = 42 self.root._setObject('portal_types', TypesTool()) self.root._setObject('pf', PortalFolder('pf')) self.root._setObject('bf', CMFBTreeFolder('bf')) self.root._setObject('portal_syndication', self._makeOne()) tool = self.root.portal_syndication tool.editProperties( updatePeriod=PERIOD, updateFrequency=FREQUENCY, updateBase=NOW, isAllowed=True, max_items=MAX_ITEMS, ) self.assertEqual(len(tool.getSyndicatableContent(self.root.pf)), 0) self.assertEqual(len(tool.getSyndicatableContent(self.root.bf)), 0)
def test_createMemberAreaCMFBTreeFolder(self): # Test member area creation if the toplevel "Members" folder is # a CMFBTreeFolder (http://www.zope.org/Collectors/CMF/441 site = self._makeSite() mtool = site.portal_membership members = site._setObject( 'Members', CMFBTreeFolder('Members') ) acl_users = site._setObject( 'acl_users', DummyUserFolder() ) wtool = site._setObject( 'portal_workflow', DummyTool() ) # permission mtool.createMemberArea('user_foo') self.failIf( hasattr(members.aq_self, 'user_foo') ) newSecurityManager(None, acl_users.user_bar) mtool.createMemberArea('user_foo') self.failIf( hasattr(members.aq_self, 'user_foo') ) newSecurityManager(None, acl_users.user_foo) mtool.setMemberareaCreationFlag() mtool.createMemberArea('user_foo') self.failIf( hasattr(members.aq_self, 'user_foo') ) newSecurityManager(None, acl_users.all_powerful_Oz) mtool.setMemberareaCreationFlag() mtool.createMemberArea('user_foo') self.failUnless( hasattr(members.aq_self, 'user_foo') ) # default content f = members.user_foo ownership = acl_users.user_foo localroles = ( ( 'user_foo', ('Owner',) ), ) self.assertEqual( f.getOwner(), ownership ) self.assertEqual( f.get_local_roles(), localroles, 'CMF Collector issue #162 (LocalRoles broken): %s' % str( f.get_local_roles() ) )
def __getattr__(self, name): """ Overloads `getattr` to return item values as attributes. """ if name in self.items: return self.items[name] else: if name in ['__parent__', '__conform__', '__annotations__', '_v_at_subobjects', '__getnewargs__', 'aq_inner', 'im_self']: raise AttributeError(name) else: try: return CMFBTreeFolder.__getattr__(self, name) except Exception: raise AttributeError(name)
def __getattr__(self, name): """ Overloads `getattr` to return item values as attributes. """ if self.items.has_key(name): return self.items[name] else: if name in [ '__parent__', '__conform__', '__annotations__', '_v_at_subobjects', '__getnewargs__', 'aq_inner', 'im_self' ]: raise AttributeError, name else: try: return CMFBTreeFolder.__getattr__(self, name) except Exception, e: raise AttributeError, name
def test_createMemberAreaCMFBTreeFolder(self): # Test member area creation if the toplevel "Members" folder is # a CMFBTreeFolder (https://bugs.launchpad.net/zope-cmf/+bug/161668) site = self._makeSite() mtool = site.portal_membership members = site._setObject('Members', CMFBTreeFolder('Members')) acl_users = site._setObject('acl_users', DummyUserFolder()) # permission mtool.createMemberArea('user_foo') self.assertFalse(hasattr(members.aq_self, 'user_foo')) newSecurityManager(None, acl_users.user_bar) mtool.createMemberArea('user_foo') self.assertFalse(hasattr(members.aq_self, 'user_foo')) newSecurityManager(None, acl_users.user_foo) mtool.setMemberareaCreationFlag() mtool.createMemberArea('user_foo') self.assertFalse(hasattr(members.aq_self, 'user_foo')) newSecurityManager(None, acl_users.all_powerful_Oz) mtool.setMemberareaCreationFlag() mtool.createMemberArea('user_foo') self.assertTrue(hasattr(members.aq_self, 'user_foo')) # default content f = members.user_foo ownership = acl_users.user_foo localroles = (('user_foo', ('Owner', )), ) self.assertEqual(f.Title(), "user_foo's Home") self.assertEqual(f.getPortalTypeName(), 'Folder') self.assertEqual(f.getOwner(), ownership) self.assertEqual( f.get_local_roles(), localroles, 'CMF Collector issue #162 (LocalRoles broken): %s' % str(f.get_local_roles())) for p in (View, AccessContentsInformation): roles = [ r['name'] for r in f.rolesOfPermission(p) if r['selected'] ] self.assertEqual(roles, ['Manager', 'Owner', 'Reviewer']) self.assertEqual(bool(f.acquiredRolesAreUsedBy(p)), False)
def __init__(self, oid, **kwargs): CMFBTreeFolder.__init__(self, oid) BaseFolder.__init__(self, oid, **kwargs)