Author: jmorliaguet Date: Wed Jun 28 14:56:40 2006 New Revision: 3539 Modified: cpsskins/branches/paris-sprint-2006/locations/interfaces.py cpsskins/branches/paris-sprint-2006/schema.py cpsskins/branches/paris-sprint-2006/storage/interfaces.py cpsskins/branches/paris-sprint-2006/storage/locations.py cpsskins/branches/paris-sprint-2006/storage/storage.py cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py
Log: - added a delete() method to storage to delete objects Modified: cpsskins/branches/paris-sprint-2006/locations/interfaces.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/locations/interfaces.py (original) +++ cpsskins/branches/paris-sprint-2006/locations/interfaces.py Wed Jun 28 14:56:40 2006 @@ -31,7 +31,9 @@ class ILocation(Interface): """Location""" - _path_tuple = Attribute("representation of the path as a tuple") + _path_tuple = Attribute("Representation of the path as a tuple") + + _method = Attribute("Path's method name.") root = Attribute("Location root") Modified: cpsskins/branches/paris-sprint-2006/schema.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/schema.py (original) +++ cpsskins/branches/paris-sprint-2006/schema.py Wed Jun 28 14:56:40 2006 @@ -33,5 +33,6 @@ return (a, b) def validate(self, value): + # FIXME return True Modified: cpsskins/branches/paris-sprint-2006/storage/interfaces.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/storage/interfaces.py (original) +++ cpsskins/branches/paris-sprint-2006/storage/interfaces.py Wed Jun 28 14:56:40 2006 @@ -24,6 +24,9 @@ def add(object, name): """Add an object to the storage. Return the added object.""" + def delete(object): + """Delete an object""" + def remove(ids): """Remove objects from the storage.""" Modified: cpsskins/branches/paris-sprint-2006/storage/locations.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/storage/locations.py (original) +++ cpsskins/branches/paris-sprint-2006/storage/locations.py Wed Jun 28 14:56:40 2006 @@ -73,13 +73,17 @@ locate(object=location, parent=self, name=u'-'.join(key)) notify(ObjectAddedEvent(location)) - def remove(self, locations): - if not isinstance(locations, (list, tuple)): - locations = [locations] - for location in locations: - if location not in list(self): + def delete(self, location): + key = (location.root, location._method) + location._path_tuple + self.remove(key) + + def remove(self, ids): + if not isinstance(ids, (list, tuple)): + ids = [ids] + for id in ids: + if id not in list(self): continue - del self[location] + del self[id] def find(self, path, root=u''): if isinstance(path, basestring): Modified: cpsskins/branches/paris-sprint-2006/storage/storage.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/storage/storage.py (original) +++ cpsskins/branches/paris-sprint-2006/storage/storage.py Wed Jun 28 14:56:40 2006 @@ -60,6 +60,9 @@ notify(ObjectAddedEvent(object)) return self[name] + def delete(self, object): + raise NotImplementedError + def remove(self, ids): """Remove objects from the storage. """ Modified: cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py (original) +++ cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py Wed Jun 28 14:56:40 2006 @@ -182,7 +182,7 @@ if action == u'delete': location = locations.getLocation(root, path) - locations.remove(location) + locations.delete(location) elif action == u'add': location = Location(path=path, root=root) -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins