Commit 9c2a6928 authored by 's avatar

Added a DefaultPropertySheets class for use by objects that are currently

PropertyManagers. Also added automagic assignment of the 'Owner' role as
a local role to a user upon creating an object.
parent e3264d79
...@@ -84,15 +84,16 @@ ...@@ -84,15 +84,16 @@
############################################################################## ##############################################################################
__doc__="""Object Manager __doc__="""Object Manager
$Id: ObjectManager.py,v 1.67 1999/04/19 22:30:29 jim Exp $""" $Id: ObjectManager.py,v 1.68 1999/04/22 15:55:39 brian Exp $"""
__version__='$Revision: 1.67 $'[11:-2] __version__='$Revision: 1.68 $'[11:-2]
import App.Management, Acquisition, App.Undo, Globals, CopySupport import App.Management, Acquisition, App.Undo, Globals, CopySupport
import os, App.FactoryDispatcher, ts_regex, Products import os, App.FactoryDispatcher, ts_regex, Products
from Globals import HTMLFile, HTMLFile, Persistent from Globals import HTMLFile, HTMLFile, Persistent
from Globals import MessageDialog, default__class_init__ from Globals import MessageDialog, default__class_init__
from webdav.NullResource import NullResource from webdav.NullResource import NullResource
from webdav.Collection import Collection
from urllib import quote from urllib import quote
from cStringIO import StringIO from cStringIO import StringIO
import marshal import marshal
...@@ -107,6 +108,7 @@ class ObjectManager( ...@@ -107,6 +108,7 @@ class ObjectManager(
Acquisition.Implicit, Acquisition.Implicit,
Persistent, Persistent,
App.Undo.UndoSupport, App.Undo.UndoSupport,
Collection,
): ):
"""Generic object manager """Generic object manager
...@@ -199,11 +201,16 @@ class ObjectManager( ...@@ -199,11 +201,16 @@ class ObjectManager(
def _setObject(self,id,object,roles=None,user=None): def _setObject(self,id,object,roles=None,user=None):
v=self._checkId(id) v=self._checkId(id)
if v is not None: id=v if v is not None: id=v
try: t=object.meta_type try: t=object.meta_type
except: t=None except: t=None
self._objects=self._objects+({'id':id,'meta_type':t},) self._objects=self._objects+({'id':id,'meta_type':t},)
self._setOb(id,object) self._setOb(id,object)
# Try to give user the local role "Owner".
if hasattr(self, 'REQUEST') and hasattr(object, '__ac_local_roles__'):
user=self.REQUEST['AUTHENTICATED_USER']
name=user.getUserName()
if name != 'Anonymous':
object.manage_setLocalRoles(name, ['Owner'])
return id return id
def _delObject(self,id): def _delObject(self,id):
......
...@@ -84,9 +84,10 @@ ...@@ -84,9 +84,10 @@
############################################################################## ##############################################################################
"""Property management""" """Property management"""
__version__='$Revision: 1.13 $'[11:-2] __version__='$Revision: 1.14 $'[11:-2]
import ExtensionClass import ExtensionClass
from PropertySheets import DefaultPropertySheets, vps
from ZPublisher.Converters import type_converters from ZPublisher.Converters import type_converters
from Globals import HTMLFile, MessageDialog from Globals import HTMLFile, MessageDialog
from string import find,join,lower,split from string import find,join,lower,split
...@@ -95,7 +96,7 @@ from Acquisition import Implicit ...@@ -95,7 +96,7 @@ from Acquisition import Implicit
from Globals import Persistent from Globals import Persistent
from DateTime import DateTime from DateTime import DateTime
from PropertySheets import vps
class PropertyManager(ExtensionClass.Base): class PropertyManager(ExtensionClass.Base):
""" """
...@@ -173,7 +174,7 @@ class PropertyManager(ExtensionClass.Base): ...@@ -173,7 +174,7 @@ class PropertyManager(ExtensionClass.Base):
) )
__propsets__=() __propsets__=()
propertysheets=vps() propertysheets=vps(DefaultPropertySheets)
def valid_property_id(self, id): def valid_property_id(self, id):
if not id or id[:1]=='_' or (' ' in id) \ if not id or id[:1]=='_' or (' ' in id) \
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Property sheets""" """Property sheets"""
__version__='$Revision: 1.38 $'[11:-2] __version__='$Revision: 1.39 $'[11:-2]
import time, string, App.Management, Globals import time, string, App.Management, Globals
from ZPublisher.Converters import type_converters from ZPublisher.Converters import type_converters
...@@ -276,10 +276,13 @@ class PropertySheet(Persistent, Implicit): ...@@ -276,10 +276,13 @@ class PropertySheet(Persistent, Implicit):
def propertyMap(self): def propertyMap(self):
# Return a tuple of mappings, giving meta-data for properties. # Return a tuple of mappings, giving meta-data for properties.
__traceback_info__=(`self`, `self.p_self()`, `self.id`, `self.xml_namespace()`, `hasattr(self.p_self(), '__propsets__')`) # Some ZClass instances dont seem to have an _properties, so
# we have to fake it...
return self.p_self()._properties return self.p_self()._properties
def _propdict(self): def _propdict(self):
dict={} dict={}
for p in self.propertyMap(): for p in self.propertyMap():
...@@ -537,13 +540,14 @@ class PropertySheets(Implicit, App.Management.Tabs): ...@@ -537,13 +540,14 @@ class PropertySheets(Implicit, App.Management.Tabs):
id='propertysheets' id='propertysheets'
default=DefaultProperties()
webdav =DAVProperties() webdav =DAVProperties()
def _get_defaults(self):
return (self.webdav,)
def __propsets__(self): def __propsets__(self):
propsets=self.aq_parent.__propsets__ propsets=self.aq_parent.__propsets__
__traceback_info__= propsets, type(propsets) __traceback_info__= propsets, type(propsets)
return (self.default, self.webdav) + propsets return self._get_defaults() + propsets
def __bobo_traverse__(self, REQUEST, name=None): def __bobo_traverse__(self, REQUEST, name=None):
for propset in self.__propsets__(): for propset in self.__propsets__():
...@@ -631,6 +635,15 @@ class PropertySheets(Implicit, App.Management.Tabs): ...@@ -631,6 +635,15 @@ class PropertySheets(Implicit, App.Management.Tabs):
self, script, path) self, script, path)
class DefaultPropertySheets(PropertySheets):
"""A PropertySheets container that contains a default property
sheet for compatibility with the arbitrary property mgmt
design of Zope PropertyManagers."""
default=DefaultProperties()
webdav =DAVProperties()
def _get_defaults(self):
return (self.default, self.webdav)
class FixedSchema(PropertySheet): class FixedSchema(PropertySheet):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment