Changeset 1373

Show
Ignore:
Timestamp:
08/25/08 14:15:12 (3 months ago)
Author:
sgillies
Message:

Make attach/detach methods of the workspace, not resource

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pleiades.workspace/trunk/pleiades/workspace/browser/configure.zcml

    r1313 r1373  
    6060    /> 
    6161 
     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 
    6276</configure> 
  • pleiades.workspace/trunk/pleiades/workspace/browser/kml.py

    r1359 r1373  
    5656 
    5757                # 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
    6262                 
    6363        except: 
  • pleiades.workspace/trunk/pleiades/workspace/browser/xml.py

    r1359 r1373  
    3030                result = load_place(portal, xml) 
    3131                for nid in result['name_ids']: 
    32                     IResource(names[nid]).attach(self.context
     32                    self.context.attach(names[nid]
    3333                for lid in result['location_ids']: 
    34                     IResource(locations[lid]).attach(self.context
     34                    self.context.attach(locations[lid]
    3535                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']]
    3838                count += 1 
    3939            except Exception, e: 
  • pleiades.workspace/trunk/pleiades/workspace/content/workspace.py

    r1361 r1373  
    11from zope.interface import implements 
    22from zope.component import adapter, getMultiAdapter, getUtility 
     3from zope.event import notify 
    34 
    45from zope.app.container.interfaces import INameChooser 
     
    1516from Products.ATContentTypes.content.schemata import finalizeATCTSchema 
    1617 
    17 from pleiades.workspace.interfaces import IWorkspace 
    1818from pleiades.workspace.config import PROJECTNAME 
    1919from pleiades.workspace.i18n import WorkspaceMessageFactory as _ 
     
    2121from Products.PleiadesEntity.content.PlaceContainer import PlaceContainer 
    2222from Products.PleiadesEntity.content.LocationContainer import LocationContainer 
     23 
     24from pleiades.workspace.interfaces import IResource, IWorkspace 
     25from pleiades.workspace.event import ResourceModifiedEvent 
    2326 
    2427# This is the Archetypes schema, defining fields and widgets. We extend 
     
    100103        self.initTopic(tid, 'Place') 
    101104 
     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 
    102114# This line tells Archetypes about the content type 
    103115atapi.registerType(Workspace, PROJECTNAME) 
  • pleiades.workspace/trunk/pleiades/workspace/interfaces.py

    r1361 r1373  
    88class IResource(Interface): 
    99     
    10     def attach(workspace): 
    11         """Attach object to a workspace.""" 
    12  
    13     def detach(workspace): 
    14         """Detach object from a workspace.""" 
    15  
    1610    wsuids = Attribute("List of workspace UIDs") 
    1711 
     
    3428                ) 
    3529 
     30    def attach(ob): 
     31        """Attach object to a workspace.""" 
     32 
     33    def detach(ob): 
     34        """Detach object from a workspace.""" 
     35 
    3636 
    3737class IWorkspaceFolder(Interface): 
  • pleiades.workspace/trunk/pleiades/workspace/resource.py

    r1361 r1373  
    33from zope.annotation.interfaces import IAnnotations 
    44from zope.component.interfaces import ComponentLookupError 
    5 from zope.event import notify 
    65from persistent.dict import PersistentDict 
    76from pleiades.workspace.interfaces import IResource 
    8 from pleiades.workspace.event import ResourceModifiedEvent 
    97 
    108logger = logging.getLogger('pleiades.workspace.resource') 
     
    2624            self.anno['wsuids'] = [] 
    2725 
    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'] 
    3128 
    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 
    3531 
    36     @property 
    37     def wsuids(self): 
    38         return self.anno['wsuids'] 
     32    wsuids = property(_get_wsuids, _set_wsuids) 
    3933 
    4034 
  • pleiades.workspace/trunk/pleiades/workspace/tests/test_portlet_workspaces.py

    r1368 r1373  
    6363        self.place = self.portal['places'][pid] 
    6464        self.workspace = self.portal['workspaces']['ws1'] 
    65         IResource(self.place).attach(self.workspace) 
     65        self.workspace.attach(self.place) 
    6666 
    6767    def renderer(self, context=None, request=None, view=None, manager=None, assignment=None): 
  • pleiades.workspace/trunk/pleiades/workspace/tests/workspaces.txt

    r1361 r1373  
    2828 
    2929    >>> 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]
    3434    >>> wsuid = ws.UID() 
    3535    >>> IResource(names[nid]).wsuids == [wsuid] 
     
    5656Detach 
    5757 
    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]
    6262    >>> IResource(names[nid]).wsuids == [] 
    6363    True