Commit 07dc4664 authored by Shane Hathaway's avatar Shane Hathaway

Applied changes from Hotfix_2001_02_23.

parent 3b4b2216
...@@ -84,9 +84,9 @@ ...@@ -84,9 +84,9 @@
############################################################################## ##############################################################################
__doc__="""Object Manager __doc__="""Object Manager
$Id: ObjectManager.py,v 1.126 2001/02/13 20:26:09 brian Exp $""" $Id: ObjectManager.py,v 1.127 2001/02/28 19:31:56 shane Exp $"""
__version__='$Revision: 1.126 $'[11:-2] __version__='$Revision: 1.127 $'[11:-2]
import App.Management, Acquisition, Globals, CopySupport, Products import App.Management, Acquisition, Globals, CopySupport, Products
import os, App.FactoryDispatcher, ts_regex, Products import os, App.FactoryDispatcher, ts_regex, Products
...@@ -384,7 +384,7 @@ class ObjectManager( ...@@ -384,7 +384,7 @@ class ObjectManager(
def objectMap(self): def objectMap(self):
# Return a tuple of mappings containing subobject meta-data # Return a tuple of mappings containing subobject meta-data
return self._objects return map(lambda dict: dict.copy(), self._objects)
def objectIds_d(self,t=None): def objectIds_d(self,t=None):
if hasattr(self, '_reserved_names'): n=self._reserved_names if hasattr(self, '_reserved_names'): n=self._reserved_names
...@@ -413,7 +413,7 @@ class ObjectManager( ...@@ -413,7 +413,7 @@ class ObjectManager(
r=[] r=[]
a=r.append a=r.append
for d in self._objects: for d in self._objects:
if d['id'] not in n: a(d) if d['id'] not in n: a(d.copy())
return r return r
def superValues(self,t): def superValues(self,t):
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Property management""" """Property management"""
__version__='$Revision: 1.35 $'[11:-2] __version__='$Revision: 1.36 $'[11:-2]
import ExtensionClass, Globals import ExtensionClass, Globals
import ZDOM import ZDOM
...@@ -288,10 +288,17 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes): ...@@ -288,10 +288,17 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
"""Return a list of (id,property) tuples """ """Return a list of (id,property) tuples """
return map(lambda i,s=self: (i['id'],getattr(s,i['id'])), return map(lambda i,s=self: (i['id'],getattr(s,i['id'])),
self._properties) self._properties)
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 """
return self._properties return self._properties
def propertyMap(self):
"""
Return a tuple of mappings, giving meta-data for properties.
Return copies of the real definitions for security.
"""
return map(lambda dict: dict.copy(), self._propertyMap())
def propertyLabel(self, id): def propertyLabel(self, id):
"""Return a label for the given property id """Return a label for the given property id
""" """
...@@ -322,7 +329,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes): ...@@ -322,7 +329,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
get turned off will be ignored. Use manage_changeProperties() get turned off will be ignored. Use manage_changeProperties()
instead for most situations. instead for most situations.
""" """
for prop in self.propertyMap(): for prop in self._propertyMap():
name=prop['id'] name=prop['id']
if 'w' in prop.get('mode', 'wd'): if 'w' in prop.get('mode', 'wd'):
value=REQUEST.get(name, '') value=REQUEST.get(name, '')
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Property sheets""" """Property sheets"""
__version__='$Revision: 1.65 $'[11:-2] __version__='$Revision: 1.66 $'[11:-2]
import time, string, App.Management, Globals import time, string, App.Management, Globals
from webdav.WriteLockInterface import WriteLockInterface from webdav.WriteLockInterface import WriteLockInterface
...@@ -213,7 +213,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -213,7 +213,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
def hasProperty(self, id): def hasProperty(self, id):
# Return a true value if a property exists with the given id. # Return a true value if a property exists with the given id.
for prop in self.propertyMap(): for prop in self._propertyMap():
if id==prop['id']: if id==prop['id']:
return 1 return 1
return 0 return 0
...@@ -312,36 +312,37 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -312,36 +312,37 @@ class PropertySheet(Traversable, Persistent, Implicit):
def propertyIds(self): def propertyIds(self):
# Return a list of property ids. # Return a list of property ids.
return map(lambda i: i['id'], self.propertyMap()) return map(lambda i: i['id'], self._propertyMap())
def propertyValues(self): def propertyValues(self):
# Return a list of property values. # Return a list of property values.
return map(lambda i, s=self: s.getProperty(i['id']), return map(lambda i, s=self: s.getProperty(i['id']),
self.propertyMap()) self._propertyMap())
def propertyItems(self): def propertyItems(self):
# Return a list of (id, property) tuples. # Return a list of (id, property) tuples.
return map(lambda i, s=self: (i['id'], s.getProperty(i['id'])), return map(lambda i, s=self: (i['id'], s.getProperty(i['id'])),
self.propertyMap()) self._propertyMap())
def propertyInfo(self, id): def propertyInfo(self, id):
# Return a mapping containing property meta-data # Return a mapping containing property meta-data
for p in self.propertyMap(): for p in self._propertyMap():
if p['id']==id: return p if p['id']==id: return p
raise ValueError, 'The property %s does not exist.' % id raise ValueError, 'The property %s does not exist.' % id
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.
# Some ZClass instances dont seem to have an _properties, so # Some ZClass instances dont seem to have an _properties, so
# we have to fake it... # we have to fake it...
return self.p_self()._properties return self.p_self()._properties
def propertyMap(self):
# Returns a secure copy of the property definitions.
return map(lambda dict: dict.copy(), self._propertyMap())
def _propdict(self): def _propdict(self):
dict={} dict={}
for p in self.propertyMap(): for p in self._propertyMap():
dict[p['id']]=p dict[p['id']]=p
return dict return dict
...@@ -360,7 +361,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -360,7 +361,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
# DAV helper method - return one or more propstat elements # DAV helper method - return one or more propstat elements
# indicating property names and values for all properties. # indicating property names and values for all properties.
result=[] result=[]
for item in self.propertyMap(): for item in self._propertyMap():
name, type=item['id'], item.get('type','string') name, type=item['id'], item.get('type','string')
value=self.getProperty(name) value=self.getProperty(name)
if type=='tokens': if type=='tokens':
...@@ -453,7 +454,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -453,7 +454,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
def manage_editProperties(self, REQUEST): def manage_editProperties(self, REQUEST):
"""Edit object properties via the web.""" """Edit object properties via the web."""
for prop in self.propertyMap(): for prop in self._propertyMap():
name=prop['id'] name=prop['id']
if 'w' in prop.get('mode', 'wd'): if 'w' in prop.get('mode', 'wd'):
value=REQUEST.get(name, '') value=REQUEST.get(name, '')
...@@ -551,9 +552,12 @@ class DAVProperties(Virtual, PropertySheet, View): ...@@ -551,9 +552,12 @@ class DAVProperties(Virtual, PropertySheet, View):
def _delProperty(self, id): def _delProperty(self, id):
raise ValueError, '%s cannot be deleted.' % id raise ValueError, '%s cannot be deleted.' % id
def propertyMap(self): def _propertyMap(self):
return self.pm return self.pm
def propertyMap(self):
return map(lambda dict: dict.copy(), self._propertyMap())
def dav__creationdate(self): def dav__creationdate(self):
return iso8601_date(43200.0) return iso8601_date(43200.0)
...@@ -759,20 +763,20 @@ class FixedSchema(PropertySheet): ...@@ -759,20 +763,20 @@ class FixedSchema(PropertySheet):
FixedSchema.inheritedAttribute('__init__')(self, id, md) FixedSchema.inheritedAttribute('__init__')(self, id, md)
self._base=base self._base=base
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.
r=[] r = []
for d in self._base.propertyMap(): for d in self._base._propertyMap():
mode=d.get('mode', 'wd') d = d.copy()
mode = d.get('mode', 'wd')
if 'd' in mode: if 'd' in mode:
dd={}
dd.update(d)
d=dd
d['mode']=filter(lambda c: c != 'd', mode) d['mode']=filter(lambda c: c != 'd', mode)
r.append(d) r.append(d)
return tuple(r) return tuple(r)
propertyMap = _propertyMap
def property_extensible_schema__(self): def property_extensible_schema__(self):
return 0 return 0
return self._base._extensible return self._base._extensible
......
...@@ -407,6 +407,7 @@ class ZClass( Base ...@@ -407,6 +407,7 @@ class ZClass( Base
return '*'+id return '*'+id
changeClassId__roles__ = () # Private
def changeClassId(self, newid=None): def changeClassId(self, newid=None):
if not dbVersionEquals('3'): if not dbVersionEquals('3'):
return return
...@@ -572,6 +573,7 @@ class ZClass( Base ...@@ -572,6 +573,7 @@ class ZClass( Base
r.sort() r.sort()
return r return r
getClassAttr__roles__ = () # Private
def getClassAttr(self, name, default=_marker, inherit=0): def getClassAttr(self, name, default=_marker, inherit=0):
if default is _marker: if default is _marker:
if inherit: return getattr(self._zclass_, name) if inherit: return getattr(self._zclass_, name)
...@@ -581,6 +583,7 @@ class ZClass( Base ...@@ -581,6 +583,7 @@ class ZClass( Base
else: return self._zclass_.__dict__[name] else: return self._zclass_.__dict__[name]
except: return default except: return default
setClassAttr__roles__ = () # Private
def setClassAttr(self, name, value): def setClassAttr(self, name, value):
c=self._zclass_ c=self._zclass_
setattr(c, name, value) setattr(c, name, value)
...@@ -588,6 +591,7 @@ class ZClass( Base ...@@ -588,6 +591,7 @@ class ZClass( Base
get_transaction().register(c) get_transaction().register(c)
c._p_changed=1 c._p_changed=1
delClassAttr__roles__ = () # Private
def delClassAttr(self, name): def delClassAttr(self, name):
c=self._zclass_ c=self._zclass_
delattr(c, name) delattr(c, name)
......
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