Changeset 1373
- Timestamp:
- 08/25/08 14:15:12 (3 months ago)
- Files:
-
- pleiades.workspace/trunk/pleiades/workspace/browser/configure.zcml (modified) (1 diff)
- pleiades.workspace/trunk/pleiades/workspace/browser/kml.py (modified) (1 diff)
- pleiades.workspace/trunk/pleiades/workspace/browser/xml.py (modified) (1 diff)
- pleiades.workspace/trunk/pleiades/workspace/content/workspace.py (modified) (4 diffs)
- pleiades.workspace/trunk/pleiades/workspace/interfaces.py (modified) (2 diffs)
- pleiades.workspace/trunk/pleiades/workspace/resource.py (modified) (2 diffs)
- pleiades.workspace/trunk/pleiades/workspace/tests/test_portlet_workspaces.py (modified) (1 diff)
- pleiades.workspace/trunk/pleiades/workspace/tests/workspaces.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pleiades.workspace/trunk/pleiades/workspace/browser/configure.zcml
r1313 r1373 60 60 /> 61 61 62 <!--browser:page 63 for="..interfaces.IWorkspace" 64 name="import-xml-form" 65 class=".xml.XMLImportForm" 66 permission="zope2.View" 67 /--> 68 69 <browser:page 70 for="Products.PleiadesEntity.content.interfaces.IName" 71 name="manage-workspaces" 72 class=".manage.ManageWorkspaces" 73 permission="cmf.AddPortalContent" 74 /> 75 62 76 </configure> pleiades.workspace/trunk/pleiades/workspace/browser/kml.py
r1359 r1373 56 56 57 57 # Attach to workspace 58 IResource(names[nid]).attach(self.context)59 IResource(locations[lid]).attach(self.context)60 IResource(f).attach(self.context)61 IResource(p).attach(self.context)58 self.context.attach(names[nid]) 59 self.context.attach(locations[lid]) 60 self.context.attach(f) 61 self.context.attach(p) 62 62 63 63 except: pleiades.workspace/trunk/pleiades/workspace/browser/xml.py
r1359 r1373 30 30 result = load_place(portal, xml) 31 31 for nid in result['name_ids']: 32 IResource(names[nid]).attach(self.context)32 self.context.attach(names[nid]) 33 33 for lid in result['location_ids']: 34 IResource(locations[lid]).attach(self.context)34 self.context.attach(locations[lid]) 35 35 for fid in result['feature_ids']: 36 IResource(features[fid]).attach(self.context)37 IResource(places[result['place_id']]).attach(self.context)36 self.context.attach(features[fid]) 37 self.context.attach(places[result['place_id']]) 38 38 count += 1 39 39 except Exception, e: pleiades.workspace/trunk/pleiades/workspace/content/workspace.py
r1361 r1373 1 1 from zope.interface import implements 2 2 from zope.component import adapter, getMultiAdapter, getUtility 3 from zope.event import notify 3 4 4 5 from zope.app.container.interfaces import INameChooser … … 15 16 from Products.ATContentTypes.content.schemata import finalizeATCTSchema 16 17 17 from pleiades.workspace.interfaces import IWorkspace18 18 from pleiades.workspace.config import PROJECTNAME 19 19 from pleiades.workspace.i18n import WorkspaceMessageFactory as _ … … 21 21 from Products.PleiadesEntity.content.PlaceContainer import PlaceContainer 22 22 from Products.PleiadesEntity.content.LocationContainer import LocationContainer 23 24 from pleiades.workspace.interfaces import IResource, IWorkspace 25 from pleiades.workspace.event import ResourceModifiedEvent 23 26 24 27 # This is the Archetypes schema, defining fields and widgets. We extend … … 100 103 self.initTopic(tid, 'Place') 101 104 105 def attach(self, ob): 106 IResource(ob).wsuids = [self.UID()] 107 notify(ResourceModifiedEvent(ob)) 108 109 def detach(self, ob): 110 IResource(ob).wsuids = [] 111 notify(ResourceModifiedEvent(ob)) 112 113 102 114 # This line tells Archetypes about the content type 103 115 atapi.registerType(Workspace, PROJECTNAME) pleiades.workspace/trunk/pleiades/workspace/interfaces.py
r1361 r1373 8 8 class IResource(Interface): 9 9 10 def attach(workspace):11 """Attach object to a workspace."""12 13 def detach(workspace):14 """Detach object from a workspace."""15 16 10 wsuids = Attribute("List of workspace UIDs") 17 11 … … 34 28 ) 35 29 30 def attach(ob): 31 """Attach object to a workspace.""" 32 33 def detach(ob): 34 """Detach object from a workspace.""" 35 36 36 37 37 class IWorkspaceFolder(Interface): pleiades.workspace/trunk/pleiades/workspace/resource.py
r1361 r1373 3 3 from zope.annotation.interfaces import IAnnotations 4 4 from zope.component.interfaces import ComponentLookupError 5 from zope.event import notify6 5 from persistent.dict import PersistentDict 7 6 from pleiades.workspace.interfaces import IResource 8 from pleiades.workspace.event import ResourceModifiedEvent9 7 10 8 logger = logging.getLogger('pleiades.workspace.resource') … … 26 24 self.anno['wsuids'] = [] 27 25 28 def attach(self, workspace): 29 self.anno['wsuids'].append(workspace.UID()) 30 notify(ResourceModifiedEvent(self.context)) 26 def _get_wsuids(self): 27 return self.anno['wsuids'] 31 28 32 def detach(self, workspace): 33 self.anno['wsuids'].remove(workspace.UID()) 34 notify(ResourceModifiedEvent(self.context)) 29 def _set_wsuids(self, value): 30 self.anno['wsuids'] = value 35 31 36 @property 37 def wsuids(self): 38 return self.anno['wsuids'] 32 wsuids = property(_get_wsuids, _set_wsuids) 39 33 40 34 pleiades.workspace/trunk/pleiades/workspace/tests/test_portlet_workspaces.py
r1368 r1373 63 63 self.place = self.portal['places'][pid] 64 64 self.workspace = self.portal['workspaces']['ws1'] 65 IResource(self.place).attach(self.workspace)65 self.workspace.attach(self.place) 66 66 67 67 def renderer(self, context=None, request=None, view=None, manager=None, assignment=None): pleiades.workspace/trunk/pleiades/workspace/tests/workspaces.txt
r1361 r1373 28 28 29 29 >>> from pleiades.workspace.interfaces import IResource 30 >>> IResource(names[nid]).attach(ws)31 >>> IResource(locations[lid]).attach(ws)32 >>> IResource(features[fid]).attach(ws)33 >>> IResource(places[pid]).attach(ws)30 >>> ws.attach(names[nid]) 31 >>> ws.attach(locations[lid]) 32 >>> ws.attach(features[fid]) 33 >>> ws.attach(places[pid]) 34 34 >>> wsuid = ws.UID() 35 35 >>> IResource(names[nid]).wsuids == [wsuid] … … 56 56 Detach 57 57 58 >>> IResource(names[nid]).detach(ws)59 >>> IResource(locations[lid]).detach(ws)60 >>> IResource(features[fid]).detach(ws)61 >>> IResource(places[pid]).detach(ws)58 >>> ws.detach(names[nid]) 59 >>> ws.detach(locations[lid]) 60 >>> ws.detach(features[fid]) 61 >>> ws.detach(places[pid]) 62 62 >>> IResource(names[nid]).wsuids == [] 63 63 True
