Commit 9b1c5b1b authored by Tres Seaver's avatar Tres Seaver

Merged 'tseaver-no_globals_imports' branch:

o Replaced  imports from the 'Globals' module throughout the tree with
  imports from the actual modules;  the 'Globals' module was always intended
  to be an area for shared data, rather than a "facade" for imports.

o Added 'zope.deferredimport.deprecation' entries to 'Globals/__init__.py'
  for all previously imported symbols / modules.

o Moved 'ApplicationdefaultPermissions' from 'App/class_init.py' to
  'AccessCoontrol/Permission.py', to avoid possible import cycle in
  third-party code.

o Moved canonical location of UNIQUE / REPLACEABLE / NOT_REPLACEABLE
  constants from 'Globals' to 'OFS.ObjectManager'.

o Removed 'stuffGlobals' hack in favor of the deferred / deprecation
  imports.
parent e133164e
...@@ -9,6 +9,12 @@ Zope Changes ...@@ -9,6 +9,12 @@ Zope Changes
Restructuring Restructuring
- Replaced imports from the 'Globals' module throughout the
tree with imports from the actual modules; the 'Globals' module
was always intended to be an area for shared data, rather than
a "facade" for imports. Added zope.deferred.deprecation entries
to 'Globals' for all symbols / modules previously imported directly.
- Updated 'pytz' from '2007f' to '2008i'. - Updated 'pytz' from '2007f' to '2008i'.
- Moved svn:externals for 'mechanize', 'ClientPath', and 'pytz' to - Moved svn:externals for 'mechanize', 'ClientPath', and 'pytz' to
......
...@@ -13,15 +13,19 @@ ...@@ -13,15 +13,19 @@
"""C implementation of the access control machinery.""" """C implementation of the access control machinery."""
try: try:
from AccessControl.cAccessControl import rolesForPermissionOn, \ from AccessControl.cAccessControl import rolesForPermissionOn
PermissionRole, imPermissionRole, _what_not_even_god_should_do, \ from AccessControl.cAccessControl import PermissionRole
RestrictedDTMLMixin, aq_validate, guarded_getattr, \ from AccessControl.cAccessControl import imPermissionRole
setDefaultBehaviors from AccessControl.cAccessControl import _what_not_even_god_should_do
from AccessControl.cAccessControl import RestrictedDTMLMixin
from AccessControl.cAccessControl import aq_validate
from AccessControl.cAccessControl import guarded_getattr
from AccessControl.cAccessControl import setDefaultBehaviors
from AccessControl.cAccessControl import ZopeSecurityPolicy \ from AccessControl.cAccessControl import ZopeSecurityPolicy \
as cZopeSecurityPolicy as cZopeSecurityPolicy
from AccessControl.cAccessControl import SecurityManager as cSecurityManager from AccessControl.cAccessControl import SecurityManager \
as cSecurityManager
except ImportError: except ImportError:
import sys import sys
# make sure a partial import doesn't pollute sys.modules # make sure a partial import doesn't pollute sys.modules
...@@ -29,7 +33,8 @@ except ImportError: ...@@ -29,7 +33,8 @@ except ImportError:
raise raise
from AccessControl.ImplPython import RestrictedDTML from AccessControl.ImplPython import RestrictedDTML
from AccessControl.ImplPython import SecurityManager, ZopeSecurityPolicy from AccessControl.ImplPython import SecurityManager
from AccessControl.ImplPython import ZopeSecurityPolicy
class RestrictedDTML(RestrictedDTMLMixin, RestrictedDTML): class RestrictedDTML(RestrictedDTMLMixin, RestrictedDTML):
......
...@@ -17,8 +17,11 @@ import os ...@@ -17,8 +17,11 @@ import os
import string import string
from logging import getLogger from logging import getLogger
from Acquisition import aq_base, aq_parent, aq_inner, aq_acquire from Acquisition import aq_acquire
from Acquisition import aq_base
from Acquisition import aq_inner
from Acquisition import aq_inContextOf from Acquisition import aq_inContextOf
from Acquisition import aq_parent
from ExtensionClass import Base from ExtensionClass import Base
from zope.interface import implements from zope.interface import implements
...@@ -31,10 +34,11 @@ except ImportError: ...@@ -31,10 +34,11 @@ except ImportError:
_what_not_even_god_should_do = [] _what_not_even_god_should_do = []
from AccessControl.SecurityManagement import getSecurityManager from AccessControl.SecurityManagement import getSecurityManager
from AccessControl import Unauthorized from AccessControl.unauthorized import Unauthorized
from AccessControl.interfaces import ISecurityPolicy from AccessControl.interfaces import ISecurityPolicy
from AccessControl.interfaces import ISecurityManager from AccessControl.interfaces import ISecurityManager
from AccessControl.SimpleObjectPolicies import Containers, _noroles from AccessControl.SimpleObjectPolicies import Containers
from AccessControl.SimpleObjectPolicies import _noroles
from AccessControl.ZopeGuards import guarded_getitem from AccessControl.ZopeGuards import guarded_getitem
LOG = getLogger('ImplPython') LOG = getLogger('ImplPython')
......
...@@ -14,19 +14,26 @@ ...@@ -14,19 +14,26 @@
$Id$ $Id$
""" """
import urlparse
from Acquisition import aq_base
from Acquisition import aq_get
from Acquisition import aq_inner
from Acquisition import aq_parent
from App.special_dtml import DTMLFile
from App.class_init import InitializeClass
from ExtensionClass import Base
from zope.interface import implements
import Globals, urlparse, SpecialUsers, ExtensionClass from AccessControl.interfaces import IOwned
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from AccessControl import getSecurityManager, Unauthorized
from AccessControl.Permissions import view_management_screens from AccessControl.Permissions import view_management_screens
from AccessControl.Permissions import take_ownership from AccessControl.Permissions import take_ownership
from Acquisition import aq_get, aq_parent, aq_base, aq_inner from AccessControl.requestmethod import requestmethod
from requestmethod import requestmethod from AccessControl.SecurityInfo import ClassSecurityInfo
from zope.interface import implements from AccessControl.SecurityManagement import getSecurityManager
# avoid importing 'emergency_user' / 'nobody' before set
from interfaces import IOwned from AccessControl import SpecialUsers as SU
from AccessControl.unauthorized import Unauthorized
UnownableOwner=[] UnownableOwner=[]
def ownableFilter(self): def ownableFilter(self):
...@@ -36,7 +43,7 @@ def ownableFilter(self): ...@@ -36,7 +43,7 @@ def ownableFilter(self):
# Marker to use as a getattr default. # Marker to use as a getattr default.
_mark=ownableFilter _mark=ownableFilter
class Owned(ExtensionClass.Base): class Owned(Base):
implements(IOwned) implements(IOwned)
...@@ -51,7 +58,7 @@ class Owned(ExtensionClass.Base): ...@@ -51,7 +58,7 @@ class Owned(ExtensionClass.Base):
) )
security.declareProtected(view_management_screens, 'manage_owner') security.declareProtected(view_management_screens, 'manage_owner')
manage_owner=Globals.DTMLFile('dtml/owner', globals()) manage_owner = DTMLFile('dtml/owner', globals())
security.declareProtected(view_management_screens, 'owner_info') security.declareProtected(view_management_screens, 'owner_info')
def owner_info(self): def owner_info(self):
...@@ -97,10 +104,10 @@ class Owned(ExtensionClass.Base): ...@@ -97,10 +104,10 @@ class Owned(ExtensionClass.Base):
root=self.getPhysicalRoot() root=self.getPhysicalRoot()
udb=root.unrestrictedTraverse(udb, None) udb=root.unrestrictedTraverse(udb, None)
if udb is None: if udb is None:
user = SpecialUsers.nobody user = SU.nobody
else: else:
user = udb.getUserById(oid, None) user = udb.getUserById(oid, None)
if user is None: user = SpecialUsers.nobody if user is None: user = SU.nobody
return user return user
security.declarePrivate('getOwnerTuple') security.declarePrivate('getOwnerTuple')
...@@ -134,12 +141,12 @@ class Owned(ExtensionClass.Base): ...@@ -134,12 +141,12 @@ class Owned(ExtensionClass.Base):
udb = root.unrestrictedTraverse(udb_path, None) udb = root.unrestrictedTraverse(udb_path, None)
if udb is None: if udb is None:
return SpecialUsers.nobody return SU.nobody
user = udb.getUserById(oid, None) user = udb.getUserById(oid, None)
if user is None: if user is None:
return SpecialUsers.nobody return SU.nobody
return user.__of__(udb) return user.__of__(udb)
...@@ -258,8 +265,7 @@ class Owned(ExtensionClass.Base): ...@@ -258,8 +265,7 @@ class Owned(ExtensionClass.Base):
else: else:
# Otherwise change the ownership # Otherwise change the ownership
user=getSecurityManager().getUser() user=getSecurityManager().getUser()
if (SpecialUsers.emergency_user and if (SU.emergency_user and aq_base(user) is SU.emergency_user):
aq_base(user) is SpecialUsers.emergency_user):
__creatable_by_emergency_user__=getattr( __creatable_by_emergency_user__=getattr(
self,'__creatable_by_emergency_user__', None) self,'__creatable_by_emergency_user__', None)
if (__creatable_by_emergency_user__ is None or if (__creatable_by_emergency_user__ is None or
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
$Id$ $Id$
""" """
import string, Products, Globals import string
from Acquisition import aq_base from Acquisition import aq_base
...@@ -121,6 +121,8 @@ _registerdPermission=_registeredPermissions.has_key ...@@ -121,6 +121,8 @@ _registerdPermission=_registeredPermissions.has_key
def registerPermissions(permissions, defaultDefault=('Manager',)): def registerPermissions(permissions, defaultDefault=('Manager',)):
"""Register an __ac_permissions__ sequence. """Register an __ac_permissions__ sequence.
""" """
from App.class_init import ApplicationDefaultPermissions
import Products
for setting in permissions: for setting in permissions:
if _registerdPermission(setting[0]): continue if _registerdPermission(setting[0]): continue
if len(setting)==2: if len(setting)==2:
...@@ -133,6 +135,10 @@ def registerPermissions(permissions, defaultDefault=('Manager',)): ...@@ -133,6 +135,10 @@ def registerPermissions(permissions, defaultDefault=('Manager',)):
Products.__ac_permissions__=( Products.__ac_permissions__=(
Products_permissions + ((perm, (), default),)) Products_permissions + ((perm, (), default),))
mangled=pname(perm) # get mangled permission name mangled=pname(perm) # get mangled permission name
if not hasattr(Globals.ApplicationDefaultPermissions, mangled): if not hasattr(ApplicationDefaultPermissions, mangled):
setattr(Globals.ApplicationDefaultPermissions, setattr(ApplicationDefaultPermissions,
mangled, default) mangled, default)
class ApplicationDefaultPermissions:
_View_Permission='Manager', 'Anonymous'
_Access_contents_information_Permission='Manager', 'Anonymous'
...@@ -21,15 +21,15 @@ $Id$ ...@@ -21,15 +21,15 @@ $Id$
from cgi import escape from cgi import escape
import ExtensionClass, Acquisition from Acquisition import ImplicitAcquisitionWrapper
from Globals import InitializeClass from App.class_init import InitializeClass
from ExtensionClass import Base
from zope.interface import implements from zope.interface import implements
from interfaces import IPermissionMappingSupport from AccessControl.interfaces import IPermissionMappingSupport
from Owned import UnownableOwner from AccessControl.Owned import UnownableOwner
from Permission import pname from AccessControl.Permission import pname
from requestmethod import requestmethod from AccessControl.requestmethod import requestmethod
class RoleManager: class RoleManager:
...@@ -125,7 +125,7 @@ def setPermissionMapping(name, obj, v): ...@@ -125,7 +125,7 @@ def setPermissionMapping(name, obj, v):
if v: setattr(obj, name, pname(v)) if v: setattr(obj, name, pname(v))
elif obj.__dict__.has_key(name): delattr(obj, name) elif obj.__dict__.has_key(name): delattr(obj, name)
class PM(ExtensionClass.Base): class PM(Base):
_owner=UnownableOwner _owner=UnownableOwner
_View_Permission='_View_Permission' _View_Permission='_View_Permission'
...@@ -144,23 +144,23 @@ def aqwrap(object, wrapper, parent): ...@@ -144,23 +144,23 @@ def aqwrap(object, wrapper, parent):
r._ugh=wrapper, object, parent r._ugh=wrapper, object, parent
return r return r
class Rewrapper(ExtensionClass.Base): class Rewrapper(Base):
def __of__(self, parent): def __of__(self, parent):
w, m, p = self._ugh w, m, p = self._ugh
return m.__of__( return m.__of__(
Acquisition.ImplicitAcquisitionWrapper( ImplicitAcquisitionWrapper(
w, parent)) w, parent))
def __getattr__(self, name): def __getattr__(self, name):
w, m, parent = self._ugh w, m, parent = self._ugh
self=m.__of__( self=m.__of__(
Acquisition.ImplicitAcquisitionWrapper( ImplicitAcquisitionWrapper(
w, parent)) w, parent))
return getattr(self, name) return getattr(self, name)
def __call__(self, *args, **kw): def __call__(self, *args, **kw):
w, m, parent = self._ugh w, m, parent = self._ugh
self=m.__of__( self=m.__of__(
Acquisition.ImplicitAcquisitionWrapper( ImplicitAcquisitionWrapper(
w, parent)) w, parent))
return apply(self, args, kw) return apply(self, args, kw)
...@@ -16,20 +16,23 @@ $Id$ ...@@ -16,20 +16,23 @@ $Id$
""" """
from cgi import escape from cgi import escape
from Globals import DTMLFile, MessageDialog, Dictionary from Acquisition import Acquired
from Acquisition import Implicit, Acquired, aq_get from Acquisition import aq_get
from Globals import InitializeClass from Acquisition import aq_base
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.Permissions import change_permissions from AccessControl.Permissions import change_permissions
import ExtensionClass, PermissionMapping, Products from App.class_init import InitializeClass
from App.Common import aq_base from App.Dialogs import MessageDialog
from App.special_dtml import DTMLFile
from ExtensionClass import Base
from PermissionMapping import RoleManager
from zope.interface import implements from zope.interface import implements
from interfaces import IRoleManager from AccessControl.interfaces import IRoleManager
from Permission import Permission from AccessControl.Permission import Permission
from requestmethod import requestmethod from AccessControl.requestmethod import requestmethod
DEFAULTMAXLISTUSERS=250 DEFAULTMAXLISTUSERS=250
...@@ -40,7 +43,7 @@ def _isNotBeingUsedAsAMethod(self): ...@@ -40,7 +43,7 @@ def _isNotBeingUsedAsAMethod(self):
return not aq_get(self, '_isBeingUsedAsAMethod_', 0) return not aq_get(self, '_isBeingUsedAsAMethod_', 0)
class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager): class RoleManager(Base, RoleManager):
"""An object that has configurable permissions""" """An object that has configurable permissions"""
...@@ -602,6 +605,7 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager): ...@@ -602,6 +605,7 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager):
pass pass
def possible_permissions(self): def possible_permissions(self):
import Products
d={} d={}
Products_permissions = getattr(Products, '__ac_permissions__', ()) Products_permissions = getattr(Products, '__ac_permissions__', ())
for p in Products_permissions: for p in Products_permissions:
......
...@@ -41,9 +41,8 @@ ...@@ -41,9 +41,8 @@
import sys import sys
from logging import getLogger from logging import getLogger
import Acquisition
from AccessControl.ImplPython import _what_not_even_god_should_do from AccessControl.ImplPython import _what_not_even_god_should_do
from Acquisition import Implicit
LOG = getLogger('SecurityInfo') LOG = getLogger('SecurityInfo')
...@@ -57,7 +56,7 @@ ACCESS_PUBLIC = None ...@@ -57,7 +56,7 @@ ACCESS_PUBLIC = None
_marker = [] _marker = []
class SecurityInfo(Acquisition.Implicit): class SecurityInfo(Implicit):
"""Encapsulate security information.""" """Encapsulate security information."""
__security_info__ = 1 __security_info__ = 1
...@@ -312,5 +311,5 @@ def allow_class(Class): ...@@ -312,5 +311,5 @@ def allow_class(Class):
sec.declareObjectPublic() sec.declareObjectPublic()
sec.setDefaultAccess(1) sec.setDefaultAccess(1)
sec.apply(Class) sec.apply(Class)
from Globals import InitializeClass from App.class_init import InitializeClass
InitializeClass(Class) InitializeClass(Class)
...@@ -24,12 +24,16 @@ from Acquisition import aq_base ...@@ -24,12 +24,16 @@ from Acquisition import aq_base
from Acquisition import aq_parent from Acquisition import aq_parent
from Acquisition import aq_inContextOf from Acquisition import aq_inContextOf
from Acquisition import Implicit from Acquisition import Implicit
from App.Management import Navigation, Tabs from App.class_init import InitializeClass
from Globals import DTMLFile, MessageDialog, Persistent, PersistentMapping from App.Management import Navigation
from Globals import InitializeClass from App.Management import Tabs
from App.special_dtml import DTMLFile
from App.Dialogs import MessageDialog
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import manage_users as ManageUsers from AccessControl.Permissions import manage_users as ManageUsers
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from Persistence import Persistent
from Persistence import PersistentMapping
from zExceptions import Unauthorized, BadRequest from zExceptions import Unauthorized, BadRequest
from zope.interface import implements from zope.interface import implements
......
...@@ -11,21 +11,26 @@ ...@@ -11,21 +11,26 @@
# #
############################################################################## ##############################################################################
from unauthorized import Unauthorized
# This has to happen early so things get initialized properly # This has to happen early so things get initialized properly
from AccessControl.Implementation import setImplementation from AccessControl.Implementation import setImplementation
from AccessControl.SecurityManagement import getSecurityManager, setSecurityPolicy from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.SecurityInfo import ClassSecurityInfo, ModuleSecurityInfo from AccessControl.SecurityManagement import setSecurityPolicy
from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.SecurityInfo import ModuleSecurityInfo
from AccessControl.SecurityInfo import ACCESS_PRIVATE from AccessControl.SecurityInfo import ACCESS_PRIVATE
from AccessControl.SecurityInfo import ACCESS_PUBLIC from AccessControl.SecurityInfo import ACCESS_PUBLIC
from AccessControl.SecurityInfo import ACCESS_NONE from AccessControl.SecurityInfo import ACCESS_NONE
from AccessControl.SecurityInfo import secureModule, allow_module, allow_class from AccessControl.SecurityInfo import secureModule
from AccessControl.SecurityInfo import allow_module
from AccessControl.SecurityInfo import allow_class
from AccessControl.SimpleObjectPolicies import allow_type from AccessControl.SimpleObjectPolicies import allow_type
from AccessControl.ZopeGuards import full_write_guard, safe_builtins from AccessControl.unauthorized import Unauthorized # XXX
from AccessControl.ZopeGuards import full_write_guard
from AccessControl.ZopeGuards import safe_builtins
ModuleSecurityInfo('AccessControl').declarePublic('getSecurityManager') ModuleSecurityInfo('AccessControl').declarePublic('getSecurityManager')
from AccessControl import DTML from AccessControl import DTML # XXX side effects?
del DTML del DTML
...@@ -15,15 +15,15 @@ ...@@ -15,15 +15,15 @@
# $Id$ # $Id$
import os, sys, unittest import unittest
import ZODB from AccessControl.SecurityInfo import ClassSecurityInfo
import SecurityBase from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.User import nobody
from AccessControl.securitySuite import SecurityBase
from OFS.Folder import Folder from OFS.Folder import Folder
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from AccessControl import ClassSecurityInfo,getSecurityManager from App.class_init import InitializeClass
from AccessControl.User import nobody
import Globals
# let's define some permissions first # let's define some permissions first
...@@ -79,7 +79,7 @@ class TestObject(SimpleItem): ...@@ -79,7 +79,7 @@ class TestObject(SimpleItem):
security.setPermissionDefault(MAGIC_PERMISSION1, ("Manager","Owner")) security.setPermissionDefault(MAGIC_PERMISSION1, ("Manager","Owner"))
security.setPermissionDefault(MAGIC_PERMISSION2, ("TestRole",)) security.setPermissionDefault(MAGIC_PERMISSION2, ("TestRole",))
Globals.InitializeClass(TestObject) InitializeClass(TestObject)
############################################################################## ##############################################################################
...@@ -99,7 +99,7 @@ class TestFolder(Folder): ...@@ -99,7 +99,7 @@ class TestFolder(Folder):
security = ClassSecurityInfo() security = ClassSecurityInfo()
Globals.InitializeClass(TestFolder) InitializeClass(TestFolder)
############################################################################## ##############################################################################
......
...@@ -25,7 +25,7 @@ import Zope2 ...@@ -25,7 +25,7 @@ import Zope2
Zope2.startup() Zope2.startup()
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from Globals import InitializeClass from App.class_init import InitializeClass
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager from AccessControl.SecurityManagement import noSecurityManager
......
...@@ -21,7 +21,7 @@ import ZODB ...@@ -21,7 +21,7 @@ import ZODB
import transaction import transaction
from Acquisition import Implicit from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from App.class_init import InitializeClass
from OFS.ObjectManager import ObjectManager from OFS.ObjectManager import ObjectManager
from OFS.Folder import Folder from OFS.Folder import Folder
......
...@@ -28,8 +28,7 @@ class ClassSecurityInfoTests(unittest.TestCase): ...@@ -28,8 +28,7 @@ class ClassSecurityInfoTests(unittest.TestCase):
# Test setting default roles for permissions. # Test setting default roles for permissions.
import Globals # XXX: avoiding import cycle from App.class_init import InitializeClass
from App.class_init import default__class_init__
from ExtensionClass import Base from ExtensionClass import Base
ClassSecurityInfo = self._getTargetClass() ClassSecurityInfo = self._getTargetClass()
...@@ -57,7 +56,7 @@ class ClassSecurityInfoTests(unittest.TestCase): ...@@ -57,7 +56,7 @@ class ClassSecurityInfoTests(unittest.TestCase):
pass pass
# Do class initialization. # Do class initialization.
default__class_init__(Test) InitializeClass(Test)
# Now check the resulting class to see if the mapping was made # Now check the resulting class to see if the mapping was made
# correctly. Note that this uses carnal knowledge of the internal # correctly. Note that this uses carnal knowledge of the internal
......
...@@ -585,7 +585,7 @@ class TestActualPython(GuardTestCase): ...@@ -585,7 +585,7 @@ class TestActualPython(GuardTestCase):
from AccessControl.SecurityInfo import ClassSecurityInfo from AccessControl.SecurityInfo import ClassSecurityInfo
from ExtensionClass import Base from ExtensionClass import Base
from Globals import InitializeClass from App.class_init import InitializeClass
global _ProtectedBase global _ProtectedBase
if _ProtectedBase is None: if _ProtectedBase is None:
......
...@@ -14,27 +14,33 @@ __doc__="""System management components""" ...@@ -14,27 +14,33 @@ __doc__="""System management components"""
__version__='$Revision: 1.94 $'[11:-2] __version__='$Revision: 1.94 $'[11:-2]
import sys,os,time,Globals, Acquisition, os, Undo from cgi import escape
from cStringIO import StringIO
from logging import getLogger from logging import getLogger
from Globals import InitializeClass import os
from Globals import DTMLFile import sys
from OFS.ObjectManager import ObjectManager import time
from OFS.Folder import Folder
from CacheManager import CacheManager from AccessControl.requestmethod import requestmethod
from DavLockManager import DavLockManager from AccessControl.SecurityManagement import getSecurityManager
from DateTime.DateTime import DateTime from Acquisition import Implicit
from OFS import SimpleItem from App.CacheManager import CacheManager
from App.class_init import InitializeClass
from App.config import getConfiguration from App.config import getConfiguration
from App.DavLockManager import DavLockManager
from App.Dialogs import MessageDialog from App.Dialogs import MessageDialog
from App.special_dtml import DTMLFile
from App.Undo import UndoSupport
from App.version_txt import version_txt
from DateTime.DateTime import DateTime
from Lifetime import shutdown
from OFS.Folder import Folder
from OFS.ObjectManager import ObjectManager
from OFS.SimpleItem import Item
from OFS.SimpleItem import SimpleItem
from Product import ProductFolder from Product import ProductFolder
from version_txt import version_txt
from cStringIO import StringIO
from AccessControl import getSecurityManager
from AccessControl.requestmethod import requestmethod
from zExceptions import Redirect
from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from cgi import escape from zExceptions import Redirect
import Lifetime
LOG = getLogger('ApplicationManager') LOG = getLogger('ApplicationManager')
...@@ -45,9 +51,9 @@ else: get_ident=thread.get_ident ...@@ -45,9 +51,9 @@ else: get_ident=thread.get_ident
class Fake: class Fake:
def locked_in_version(self): return 0 def locked_in_version(self): return 0
class DatabaseManager(Fake, SimpleItem.Item, Acquisition.Implicit): class DatabaseManager(Fake, Item, Implicit):
"""Database management (legacy) """ """Database management (legacy) """
manage=manage_main=DTMLFile('dtml/dbMain', globals()) manage = manage_main = DTMLFile('dtml/dbMain', globals())
manage_main._setName('manage_main') manage_main._setName('manage_main')
id ='DatabaseManagement' id ='DatabaseManagement'
name=title='Database Management' name=title='Database Management'
...@@ -69,9 +75,9 @@ class DatabaseManager(Fake, SimpleItem.Item, Acquisition.Implicit): ...@@ -69,9 +75,9 @@ class DatabaseManager(Fake, SimpleItem.Item, Acquisition.Implicit):
# These need to be here rather to make tabs work correctly. This # These need to be here rather to make tabs work correctly. This
# needs to be revisited. # needs to be revisited.
manage_activity=Globals.DTMLFile('dtml/activity', globals()) manage_activity = DTMLFile('dtml/activity', globals())
manage_cacheParameters=Globals.DTMLFile('dtml/cacheParameters', globals()) manage_cacheParameters = DTMLFile('dtml/cacheParameters', globals())
manage_cacheGC=Globals.DTMLFile('dtml/cacheGC', globals()) manage_cacheGC = DTMLFile('dtml/cacheGC', globals())
InitializeClass(DatabaseManager) InitializeClass(DatabaseManager)
...@@ -89,7 +95,7 @@ class FakeConnection: ...@@ -89,7 +95,7 @@ class FakeConnection:
def getVersion(self): def getVersion(self):
return self.version return self.version
class DatabaseChooser (SimpleItem.SimpleItem): class DatabaseChooser(SimpleItem):
"""Lets you choose which database to view """Lets you choose which database to view
""" """
meta_type = 'Database Management' meta_type = 'Database Management'
...@@ -140,9 +146,9 @@ class DatabaseChooser (SimpleItem.SimpleItem): ...@@ -140,9 +146,9 @@ class DatabaseChooser (SimpleItem.SimpleItem):
InitializeClass(DatabaseChooser) InitializeClass(DatabaseChooser)
class VersionManager(Fake, SimpleItem.Item, Acquisition.Implicit): class VersionManager(Fake, Item, Implicit):
"""Version management""" """Version management"""
manage=manage_main=DTMLFile('dtml/versionManager', globals()) manage=manage_main = DTMLFile('dtml/versionManager', globals())
manage_main._setName('manage_main') manage_main._setName('manage_main')
id ='Versions' id ='Versions'
name=title='Version Management' name=title='Version Management'
...@@ -165,9 +171,9 @@ InitializeClass(VersionManager) ...@@ -165,9 +171,9 @@ InitializeClass(VersionManager)
_v_rcs=None _v_rcs=None
_v_rst=None _v_rst=None
class DebugManager(Fake, SimpleItem.Item, Acquisition.Implicit): class DebugManager(Fake, Item, Implicit):
"""Debug and profiling information""" """Debug and profiling information"""
manage=manage_main=DTMLFile('dtml/debug', globals()) manage=manage_main = DTMLFile('dtml/debug', globals())
manage_main._setName('manage_main') manage_main._setName('manage_main')
id ='DebugInfo' id ='DebugInfo'
name=title='Debug Information' name=title='Debug Information'
...@@ -182,9 +188,9 @@ class DebugManager(Fake, SimpleItem.Item, Acquisition.Implicit): ...@@ -182,9 +188,9 @@ class DebugManager(Fake, SimpleItem.Item, Acquisition.Implicit):
) )
) )
manage_debug=DTMLFile('dtml/debug', globals()) manage_debug = DTMLFile('dtml/debug', globals())
def refcount(self, n=None, t=(type(Fake), type(Acquisition.Implicit))): def refcount(self, n=None, t=(type(Fake), type(Implicit))):
# return class reference info # return class reference info
dict={} dict={}
for m in sys.modules.values(): for m in sys.modules.values():
...@@ -241,12 +247,13 @@ class DebugManager(Fake, SimpleItem.Item, Acquisition.Implicit): ...@@ -241,12 +247,13 @@ class DebugManager(Fake, SimpleItem.Item, Acquisition.Implicit):
'rc': n[1][0]}, rd) 'rc': n[1][0]}, rd)
def dbconnections(self): def dbconnections(self):
import Globals # for data
return Globals.DB.connectionDebugInfo() return Globals.DB.connectionDebugInfo()
# Profiling support # Profiling support
manage_profile=DTMLFile('dtml/profile', globals()) manage_profile = DTMLFile('dtml/profile', globals())
def manage_profile_stats(self, sort='time', limit=200, stripDirs=1, mode='stats'): def manage_profile_stats(self, sort='time', limit=200, stripDirs=1, mode='stats'):
"""Return profile data if available""" """Return profile data if available"""
...@@ -283,7 +290,7 @@ class ApplicationManager(Folder,CacheManager): ...@@ -283,7 +290,7 @@ class ApplicationManager(Folder,CacheManager):
DebugInfo=DebugManager() DebugInfo=DebugManager()
DavLocks = DavLockManager() DavLocks = DavLockManager()
manage=manage_main=DTMLFile('dtml/cpContents', globals()) manage=manage_main = DTMLFile('dtml/cpContents', globals())
manage_main._setName('manage_main') manage_main._setName('manage_main')
def version_txt(self): def version_txt(self):
...@@ -309,11 +316,9 @@ class ApplicationManager(Folder,CacheManager): ...@@ -309,11 +316,9 @@ class ApplicationManager(Folder,CacheManager):
) )
manage_options=( manage_options=(
( ({'label':'Contents', 'action':'manage_main',
{'label':'Contents', 'action':'manage_main', 'help':('OFSP','Control-Panel_Contents.stx')},
'help':('OFSP','Control-Panel_Contents.stx')}, ) + UndoSupport.manage_options
)
+Undo.UndoSupport.manage_options
) )
id ='Control_Panel' id ='Control_Panel'
...@@ -397,8 +402,7 @@ class ApplicationManager(Folder,CacheManager): ...@@ -397,8 +402,7 @@ class ApplicationManager(Folder,CacheManager):
except: except:
user = 'unknown user' user = 'unknown user'
LOG.info("Restart requested by %s" % user) LOG.info("Restart requested by %s" % user)
#for db in Globals.opened: db.close() shutdown(1)
Lifetime.shutdown(1)
return """<html> return """<html>
<head><meta HTTP-EQUIV=REFRESH CONTENT="10; URL=%s/manage_main"> <head><meta HTTP-EQUIV=REFRESH CONTENT="10; URL=%s/manage_main">
</head> </head>
...@@ -413,8 +417,7 @@ class ApplicationManager(Folder,CacheManager): ...@@ -413,8 +417,7 @@ class ApplicationManager(Folder,CacheManager):
except: except:
user = 'unknown user' user = 'unknown user'
LOG.info("Shutdown requested by %s" % user) LOG.info("Shutdown requested by %s" % user)
#for db in Globals.opened: db.close() shutdown(0)
Lifetime.shutdown(0)
return """<html> return """<html>
<head> <head>
</head> </head>
......
...@@ -19,9 +19,10 @@ __version__='$Revision: 1.31 $'[11:-2] ...@@ -19,9 +19,10 @@ __version__='$Revision: 1.31 $'[11:-2]
import time import time
import Globals from App.class_init import InitializeClass
from Globals import InitializeClass from App.special_dtml import DTMLFile
from DateTime import DateTime from App.ImageFile import ImageFile
from DateTime.DateTime import DateTime
class CacheManager: class CacheManager:
"""Cache management mix-in """Cache management mix-in
...@@ -30,13 +31,12 @@ class CacheManager: ...@@ -30,13 +31,12 @@ class CacheManager:
_vcache_age = 60 _vcache_age = 60
_history_length = 3600 # Seconds _history_length = 3600 # Seconds
manage_cacheParameters = Globals.DTMLFile('dtml/cacheParameters', manage_cacheParameters = DTMLFile('dtml/cacheParameters', globals())
globals()) manage_cacheGC = DTMLFile('dtml/cacheGC', globals())
manage_cacheGC = Globals.DTMLFile('dtml/cacheGC', globals())
transparent_bar = Globals.ImageFile('www/transparent_bar.gif', globals()) transparent_bar = ImageFile('www/transparent_bar.gif', globals())
store_bar = Globals.ImageFile('www/store_bar.gif', globals()) store_bar = ImageFile('www/store_bar.gif', globals())
load_bar = Globals.ImageFile('www/load_bar.gif', globals()) load_bar = ImageFile('www/load_bar.gif', globals())
def _getDB(self): def _getDB(self):
return self._p_jar.db() return self._p_jar.db()
...@@ -95,19 +95,23 @@ class CacheManager: ...@@ -95,19 +95,23 @@ class CacheManager:
# BoboPOS 2 # BoboPOS 2
def cache_mean_age(self): def cache_mean_age(self):
import Globals # for data
return Globals.Bobobase._jar.cache.cache_mean_age/60.0 return Globals.Bobobase._jar.cache.cache_mean_age/60.0
# BoboPOS 2 # BoboPOS 2
def cache_mean_deal(self): def cache_mean_deal(self):
import Globals # for data
return Globals.Bobobase._jar.cache.cache_mean_deal*60 return Globals.Bobobase._jar.cache.cache_mean_deal*60
# BoboPOS 2 # BoboPOS 2
def cache_mean_deac(self): def cache_mean_deac(self):
import Globals # for data
return Globals.Bobobase._jar.cache.cache_mean_deac*60 return Globals.Bobobase._jar.cache.cache_mean_deac*60
# BoboPOS 2 # BoboPOS 2
def cache_last_gc_time(self): def cache_last_gc_time(self):
t=Globals.Bobobase._jar.cache.cache_last_gc_time import Globals # for data
t = Globals.Bobobase._jar.cache.cache_last_gc_time
return time.asctime(time.localtime(t)) return time.asctime(time.localtime(t))
def manage_full_sweep(self,value,REQUEST): def manage_full_sweep(self,value,REQUEST):
......
...@@ -13,15 +13,19 @@ ...@@ -13,15 +13,19 @@
__version__ = "$Revision: 1.8 $"[11:-2] __version__ = "$Revision: 1.8 $"[11:-2]
import OFS, Acquisition, Globals from AccessControl.SecurityInfo import ClassSecurityInfo
from Globals import InitializeClass from AccessControl.SecurityManagement import getSecurityManager
from AccessControl import getSecurityManager, ClassSecurityInfo from Acquisition import aq_base
from Acquisition import Implicit
from App.class_init import InitializeClass
from App.special_dtml import DTMLFile
from OFS.SimpleItem import Item
from webdav.Lockable import wl_isLocked from webdav.Lockable import wl_isLocked
class DavLockManager(OFS.SimpleItem.Item, Acquisition.Implicit): class DavLockManager(Item, Implicit):
id = 'DavLockManager' id = 'DavLockManager'
name = title = 'WebDAV Lock Manager' name = title = 'WebDAV Lock Manager'
meta_type = 'WebDAV Lock Manager' meta_type = 'WebDAV Lock Manager'
icon = 'p_/davlocked' icon = 'p_/davlocked'
security = ClassSecurityInfo() security = ClassSecurityInfo()
...@@ -30,7 +34,7 @@ class DavLockManager(OFS.SimpleItem.Item, Acquisition.Implicit): ...@@ -30,7 +34,7 @@ class DavLockManager(OFS.SimpleItem.Item, Acquisition.Implicit):
'manage_unlockObjects') 'manage_unlockObjects')
security.declarePrivate('unlockObjects') security.declarePrivate('unlockObjects')
manage_davlocks=manage_main=manage=Globals.DTMLFile( manage_davlocks = manage_main = manage = DTMLFile(
'dtml/davLockManager', globals()) 'dtml/davLockManager', globals())
manage_davlocks._setName('manage_davlocks') manage_davlocks._setName('manage_davlocks')
...@@ -78,7 +82,7 @@ class DavLockManager(OFS.SimpleItem.Item, Acquisition.Implicit): ...@@ -78,7 +82,7 @@ class DavLockManager(OFS.SimpleItem.Item, Acquisition.Implicit):
if result is None: if result is None:
result = [] result = []
base = Acquisition.aq_base(obj) base = aq_base(obj)
if not hasattr(base, 'objectItems'): if not hasattr(base, 'objectItems'):
return result return result
try: items = obj.objectItems() try: items = obj.objectItems()
...@@ -90,7 +94,7 @@ class DavLockManager(OFS.SimpleItem.Item, Acquisition.Implicit): ...@@ -90,7 +94,7 @@ class DavLockManager(OFS.SimpleItem.Item, Acquisition.Implicit):
else: p = id else: p = id
dflag = hasattr(ob, '_p_changed') and (ob._p_changed == None) dflag = hasattr(ob, '_p_changed') and (ob._p_changed == None)
bs = Acquisition.aq_base(ob) bs = aq_base(ob)
if wl_isLocked(ob): if wl_isLocked(ob):
li = [] li = []
addlockinfo = li.append addlockinfo = li.append
......
...@@ -33,8 +33,7 @@ ...@@ -33,8 +33,7 @@
__version__='$Revision: 1.9 $'[11:-2] __version__='$Revision: 1.9 $'[11:-2]
from App.special_dtml import HTML
from Globals import HTML
MessageDialog = HTML(""" MessageDialog = HTML("""
<HTML> <HTML>
......
...@@ -15,34 +15,41 @@ __doc__='''Factory objects ...@@ -15,34 +15,41 @@ __doc__='''Factory objects
$Id$''' $Id$'''
__version__='$Revision: 1.27 $'[11:-2] __version__='$Revision: 1.27 $'[11:-2]
import OFS.SimpleItem, Acquisition, Globals, AccessControl.Role
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import edit_factories from AccessControl.Permissions import edit_factories
from AccessControl.Permissions import use_factories from AccessControl.Permissions import use_factories
from AccessControl.Role import RoleManager
class Factory( from AccessControl.SecurityInfo import ClassSecurityInfo
AccessControl.Role.RoleManager, from Acquisition import Acquired
Globals.Persistent, Acquisition.Implicit, OFS.SimpleItem.Item from Acquisition import Implicit
): from App.class_init import InitializeClass
"Model factory meta-data" from App.special_dtml import DTMLFile
meta_type='Zope Factory' from Persistence import Persistent
icon='p_/Factory_icon' from OFS.SimpleItem import Item
class Factory(RoleManager,
Persistent,
Implicit,
Item
):
"""Model factory meta-data
"""
meta_type = 'Zope Factory'
icon = 'p_/Factory_icon'
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(use_factories) security.declareObjectProtected(use_factories)
permission='' # Waaaa permission = '' # Waaaa
_setObject=_getOb=Acquisition.Acquired _setObject=_getOb = Acquired
manage_options=( manage_options = (
( (
{'label':'Edit', 'action':'manage_main', {'label':'Edit', 'action':'manage_main',
'help':('OFSP','Zope-Factory_Edit.stx')}, 'help':('OFSP','Zope-Factory_Edit.stx')},
) )
+AccessControl.Role.RoleManager.manage_options + RoleManager.manage_options
+OFS.SimpleItem.Item.manage_options + Item.manage_options
) )
def __init__(self, id, title, object_type, initial, permission=''): def __init__(self, id, title, object_type, initial, permission=''):
...@@ -62,53 +69,55 @@ class Factory( ...@@ -62,53 +69,55 @@ class Factory(
REQUEST=None): REQUEST=None):
"Modify factory properties." "Modify factory properties."
self._unregister() self._unregister()
self.title=title self.title = title
self.object_type=object_type self.object_type = object_type
self.initial=initial self.initial = initial
self.permission=permission self.permission = permission
self.manage_setPermissionMapping((use_factories,), (permission,)) self.manage_setPermissionMapping((use_factories,), (permission,))
self._register() self._register()
if REQUEST is not None: return self.manage_main(self, REQUEST) if REQUEST is not None:
return self.manage_main(self, REQUEST)
def manage_afterAdd(self, item, container): def manage_afterAdd(self, item, container):
import Product # local to avoid circular import from App.Product import Product # local to avoid circular import
if hasattr(self, 'aq_parent'): if hasattr(self, 'aq_parent'):
container=self.aq_parent container=self.aq_parent
elif item is not self: elif item is not self:
container=None container=None
if (item is self or if (item is self or
getattr(container, '__class__', None) is Product.Product): getattr(container, '__class__', None) is Product):
self._register() self._register()
def manage_beforeDelete(self, item, container): def manage_beforeDelete(self, item, container):
import Product # local to avoid circular import from App.Product import Product # local to avoid circular import
if hasattr(self, 'aq_parent'): if hasattr(self, 'aq_parent'):
container=self.aq_parent container=self.aq_parent
elif item is not self: elif item is not self:
container=None container=None
if (item is self or if (item is self or
getattr(container, '__class__', None) is Product.Product): getattr(container, '__class__', None) is Product):
self._unregister() self._unregister()
def _register(self): def _register(self):
# Register with the product folder # Register with the product folder
product=self.aq_parent product =self.aq_parent
product.aq_acquire('_manage_add_product_meta_type')( product.aq_acquire('_manage_add_product_meta_type')(
product, self.id, self.object_type, self.permission) product, self.id, self.object_type, self.permission)
def _unregister(self): def _unregister(self):
# Unregister with the product folder # Unregister with the product folder
product=self.aq_parent product = self.aq_parent
product.aq_acquire('_manage_remove_product_meta_type')( product.aq_acquire('_manage_remove_product_meta_type')(
product, self.id, self.object_type) product, self.id, self.object_type)
security.declareProtected(edit_factories, 'manage_main') security.declareProtected(edit_factories, 'manage_main')
manage_main=Globals.DTMLFile('dtml/editFactory',globals()) manage_main = DTMLFile('dtml/editFactory',globals())
security.declareProtected(use_factories, 'index_html') security.declareProtected(use_factories, 'index_html')
def index_html(self, REQUEST): def index_html(self, REQUEST):
" " """ Main factory view
"""
return getattr(self, self.initial)(self.aq_parent, REQUEST) return getattr(self, self.initial)(self.aq_parent, REQUEST)
def objectIds(self): def objectIds(self):
......
...@@ -13,19 +13,22 @@ ...@@ -13,19 +13,22 @@
# Implement the manage_addProduct method of object managers # Implement the manage_addProduct method of object managers
import sys
import types import types
import Acquisition, sys, Products
from Globals import InitializeClass from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl import ClassSecurityInfo
from AccessControl.PermissionMapping import aqwrap from AccessControl.PermissionMapping import aqwrap
from AccessControl.Owned import UnownableOwner from AccessControl.Owned import UnownableOwner
import Zope2 from Acquisition import Acquired
from Acquisition import aq_base
from Acquisition import Implicit
from App.class_init import InitializeClass
def _product_packages(): def _product_packages():
"""Returns all product packages including the regularly defined """Returns all product packages including the regularly defined
zope2 packages and those without the Products namespace package. zope2 packages and those without the Products namespace package.
""" """
import Products
packages = {} packages = {}
for x in dir(Products): for x in dir(Products):
m = getattr(Products, x) m = getattr(Products, x)
...@@ -37,7 +40,7 @@ def _product_packages(): ...@@ -37,7 +40,7 @@ def _product_packages():
return packages return packages
class ProductDispatcher(Acquisition.Implicit): class ProductDispatcher(Implicit):
" " " "
# Allow access to factory dispatchers # Allow access to factory dispatchers
__allow_access_to_unprotected_subobjects__=1 __allow_access_to_unprotected_subobjects__=1
...@@ -57,7 +60,7 @@ class ProductDispatcher(Acquisition.Implicit): ...@@ -57,7 +60,7 @@ class ProductDispatcher(Acquisition.Implicit):
dispatcher=dispatcher_class(product, self.aq_parent, REQUEST) dispatcher=dispatcher_class(product, self.aq_parent, REQUEST)
return dispatcher.__of__(self) return dispatcher.__of__(self)
class FactoryDispatcher(Acquisition.Implicit): class FactoryDispatcher(Implicit):
"""Provide a namespace for product "methods" """Provide a namespace for product "methods"
""" """
...@@ -66,7 +69,7 @@ class FactoryDispatcher(Acquisition.Implicit): ...@@ -66,7 +69,7 @@ class FactoryDispatcher(Acquisition.Implicit):
_owner=UnownableOwner _owner=UnownableOwner
def __init__(self, product, dest, REQUEST=None): def __init__(self, product, dest, REQUEST=None):
product = Acquisition.aq_base(product) product = aq_base(product)
self._product=product self._product=product
self._d=dest self._d=dest
if REQUEST is not None: if REQUEST is not None:
...@@ -100,19 +103,19 @@ class FactoryDispatcher(Acquisition.Implicit): ...@@ -100,19 +103,19 @@ class FactoryDispatcher(Acquisition.Implicit):
m=d[name] m=d[name]
w=getattr(m, '_permissionMapper', None) w=getattr(m, '_permissionMapper', None)
if w is not None: if w is not None:
m=aqwrap(m, Acquisition.aq_base(w), self) m=aqwrap(m, aq_base(w), self)
return m return m
# Waaa # Waaa
m='Products.%s' % p.id m = 'Products.%s' % p.id
if sys.modules.has_key(m) and sys.modules[m]._m.has_key(name): if sys.modules.has_key(m) and sys.modules[m]._m.has_key(name):
return sys.modules[m]._m[name] return sys.modules[m]._m[name]
raise AttributeError, name raise AttributeError, name
# Provide acquired indicators for critical OM methods: # Provide acquired indicators for critical OM methods:
_setObject=_getOb=Acquisition.Acquired _setObject = _getOb = Acquired
# Make sure factory methods are unowned: # Make sure factory methods are unowned:
_owner=UnownableOwner _owner=UnownableOwner
......
...@@ -18,25 +18,23 @@ import os ...@@ -18,25 +18,23 @@ import os
import stat import stat
import time import time
import Acquisition from AccessControl.SecurityInfo import ClassSecurityInfo
import Globals from Acquisition import Explicit
from Globals import InitializeClass from App.class_init import InitializeClass
from AccessControl import ClassSecurityInfo from App.Common import package_home
from App.Common import rfc1123_date
from App.config import getConfiguration from App.config import getConfiguration
from Globals import package_home from DateTime.DateTime import DateTime
from Common import rfc1123_date
from DateTime import DateTime
from zope.contenttype import guess_content_type from zope.contenttype import guess_content_type
from ZPublisher.Iterators import filestream_iterator from ZPublisher.Iterators import filestream_iterator
class ImageFile(Acquisition.Explicit): class ImageFile(Explicit):
"""Image objects stored in external files.""" """Image objects stored in external files."""
security = ClassSecurityInfo() security = ClassSecurityInfo()
def __init__(self,path,_prefix=None): def __init__(self,path,_prefix=None):
import Globals # for data
if _prefix is None: if _prefix is None:
_prefix=getConfiguration().softwarehome _prefix=getConfiguration().softwarehome
elif type(_prefix) is not type(''): elif type(_prefix) is not type(''):
......
...@@ -15,20 +15,23 @@ ...@@ -15,20 +15,23 @@
$Id$ $Id$
""" """
import sys, ExtensionClass, urllib from cgi import escape
from Globals import DTMLFile, HTMLFile import sys
from Globals import InitializeClass import urllib
from zExceptions import Redirect
from zope.interface import implements
from AccessControl import getSecurityManager, Unauthorized from AccessControl import getSecurityManager, Unauthorized
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import view_management_screens from AccessControl.Permissions import view_management_screens
from cgi import escape from App.class_init import InitializeClass
from zope.interface import implements from App.interfaces import INavigation
from App.special_dtml import HTMLFile
from interfaces import INavigation from App.special_dtml import DTMLFile
from ExtensionClass import Base
from zExceptions import Redirect
class Tabs(ExtensionClass.Base): class Tabs(Base):
"""Mix-in provides management folder tab support.""" """Mix-in provides management folder tab support."""
security = ClassSecurityInfo() security = ClassSecurityInfo()
...@@ -158,7 +161,7 @@ class Tabs(ExtensionClass.Base): ...@@ -158,7 +161,7 @@ class Tabs(ExtensionClass.Base):
InitializeClass(Tabs) InitializeClass(Tabs)
class Navigation(ExtensionClass.Base): class Navigation(Base):
"""Basic navigation UI support""" """Basic navigation UI support"""
implements(INavigation) implements(INavigation)
......
...@@ -15,29 +15,35 @@ __doc__='''Zope registerable permissions ...@@ -15,29 +15,35 @@ __doc__='''Zope registerable permissions
$Id$''' $Id$'''
__version__='$Revision: 1.9 $'[11:-2] __version__='$Revision: 1.9 $'[11:-2]
import OFS.SimpleItem, Acquisition, Globals, ExtensionClass, AccessControl.Role from AccessControl.Permissions import view_management_screens
from AccessControl import ClassSecurityInfo, Permissions from AccessControl.Permissions import define_permissions
from AccessControl.Role import RoleManager
view_management_screens = Permissions.view_management_screens from AccessControl.SecurityInfo import ClassSecurityInfo
define_permissions = Permissions.define_permissions from Acquisition import Implicit
from App.class_init import InitializeClass
from App.special_dtml import DTMLFile
class Permission( from ExtensionClass import Base
AccessControl.Role.RoleManager, from OFS.SimpleItem import Item
Globals.Persistent, Acquisition.Implicit, OFS.SimpleItem.Item from Persistence import Persistent
):
"Model Permission meta-data" class Permission(RoleManager,
meta_type='Zope Permission' Persistent,
icon='p_/Permission_icon' Implicit,
Item
):
"""Model Permission meta-data
"""
meta_type = 'Zope Permission'
icon = 'p_/Permission_icon'
security = ClassSecurityInfo() security = ClassSecurityInfo()
manage_options=( manage_options=(
( (
{'label':'Edit', 'action':'manage_main', {'label':'Edit', 'action':'manage_main',
'help':('OFSP','Zope-Permission_Edit.stx')}, 'help':('OFSP', 'Zope-Permission_Edit.stx')},
) )
+AccessControl.Role.RoleManager.manage_options + RoleManager.manage_options
+OFS.SimpleItem.Item.manage_options + Item.manage_options
) )
def __init__(self, id, title, name): def __init__(self, id, title, name):
...@@ -65,25 +71,25 @@ class Permission( ...@@ -65,25 +71,25 @@ class Permission(
def _register(self): def _register(self):
# Register with the product folder # Register with the product folder
product=self.aq_parent product = self.aq_parent
product.aq_acquire('_manage_add_product_permission')( product.aq_acquire('_manage_add_product_permission')(
product, self.name) product, self.name)
def _unregister(self): def _unregister(self):
# Unregister with the product folder # Unregister with the product folder
product=self.aq_parent product = self.aq_parent
product.aq_acquire('_manage_remove_product_permission')( product.aq_acquire('_manage_remove_product_permission')(
product, self.name) product, self.name)
security.declareProtected(view_management_screens, 'manage_main') security.declareProtected(view_management_screens, 'manage_main')
manage_main=Globals.DTMLFile('dtml/editPermission',globals()) manage_main = DTMLFile('dtml/editPermission', globals())
index_html=None index_html = None
Globals.InitializeClass(Permission) InitializeClass(Permission)
class PermissionManager(ExtensionClass.Base): class PermissionManager(Base):
security = ClassSecurityInfo() security = ClassSecurityInfo()
...@@ -92,15 +98,16 @@ class PermissionManager(ExtensionClass.Base): ...@@ -92,15 +98,16 @@ class PermissionManager(ExtensionClass.Base):
}, },
security.declareProtected(define_permissions, 'manage_addPermissionForm') security.declareProtected(define_permissions, 'manage_addPermissionForm')
manage_addPermissionForm=Globals.DTMLFile('dtml/addPermission',globals()) manage_addPermissionForm = DTMLFile('dtml/addPermission', globals())
security.declareProtected(define_permissions, 'manage_addPermission') security.declareProtected(define_permissions, 'manage_addPermission')
def manage_addPermission( def manage_addPermission(
self, id, title, permission, REQUEST=None): self, id, title, permission, REQUEST=None):
' ' """ Add a TTW permission.
"""
i=Permission(id, title, permission) i=Permission(id, title, permission)
self._setObject(id,i) self._setObject(id, i)
if REQUEST is not None: if REQUEST is not None:
return self.manage_main(self,REQUEST,update_menu=1) return self.manage_main(self, REQUEST, update_menu=1)
Globals.InitializeClass(PermissionManager) InitializeClass(PermissionManager)
...@@ -14,37 +14,26 @@ ...@@ -14,37 +14,26 @@
$Id$ $Id$
""" """
from DateTime.DateTime import DateTime
import Globals
from DateTime import DateTime
from Persistence import Persistent
from zope.interface import classImplements
from zope.interface import implements
from class_init import default__class_init__
from interfaces import IPersistentExtra
Persistent.__class_init__ = default__class_init__
class PersistentUtil: class PersistentUtil:
implements(IPersistentExtra)
def bobobase_modification_time(self): def bobobase_modification_time(self):
jar=self._p_jar jar=self._p_jar
oid=self._p_oid oid=self._p_oid
if jar is None or oid is None: return DateTime() if jar is None or oid is None:
return DateTime()
try: try:
t=self._p_mtime t = self._p_mtime
if t is None: return DateTime() except:
except: t=0 t = 0
return DateTime(t) return DateTime(t)
def locked_in_version(self): def locked_in_version(self):
"""Was the object modified in any version? """Was the object modified in any version?
""" """
import Globals # for data
jar=self._p_jar jar=self._p_jar
oid=self._p_oid oid=self._p_oid
if jar is None or oid is None: return None if jar is None or oid is None: return None
...@@ -80,8 +69,24 @@ class PersistentUtil: ...@@ -80,8 +69,24 @@ class PersistentUtil:
except: return 0 except: return 0
return 1 return 1
for k, v in PersistentUtil.__dict__.items():
if k[0] != '_':
setattr(Persistent, k, v)
classImplements(Persistent, IPersistentExtra) _patched = False
def patchPersistent():
global _patched
if _patched:
return
_patched = True
from zope.interface import classImplements
from Persistence import Persistent
from App.class_init import default__class_init__
from App.interfaces import IPersistentExtra
Persistent.__class_init__ = default__class_init__
for k, v in PersistentUtil.__dict__.items():
if k[0] != '_':
setattr(Persistent, k, v)
classImplements(Persistent, IPersistentExtra)
This diff is collapsed.
...@@ -15,23 +15,31 @@ ...@@ -15,23 +15,31 @@
$Id$ $Id$
""" """
import stat
import os.path, re
from logging import getLogger from logging import getLogger
import os
import re
import stat
from AccessControl.Permission import registerPermissions
from AccessControl.PermissionRole import PermissionRole from AccessControl.PermissionRole import PermissionRole
import Globals, os, OFS.ObjectManager, OFS.misc_, Products from App.Common import package_home
import AccessControl.Permission from App.ImageFile import ImageFile
from App.Product import doInstall from App.Product import doInstall
from HelpSys import HelpTopic, APIHelpTopic from DateTime.DateTime import DateTime
from HelpSys import APIHelpTopic
from HelpSys import HelpTopic
from HelpSys.HelpSys import ProductHelp from HelpSys.HelpSys import ProductHelp
from FactoryDispatcher import FactoryDispatcher from OFS.misc_ import Misc_
from OFS.misc_ import misc_
from OFS.ObjectManager import ObjectManager
from DateTime import DateTime
from zope.interface import implementedBy from zope.interface import implementedBy
from App.FactoryDispatcher import FactoryDispatcher
import ZClasses # to enable 'PC.registerBaseClass()' import ZClasses # to enable 'PC.registerBaseClass()'
# Waaaa
import Products
if not hasattr(Products, 'meta_types'): if not hasattr(Products, 'meta_types'):
Products.meta_types=() Products.meta_types=()
if not hasattr(Products, 'meta_classes'): if not hasattr(Products, 'meta_classes'):
...@@ -120,11 +128,9 @@ class ProductContext: ...@@ -120,11 +128,9 @@ class ProductContext:
for p in permissions: for p in permissions:
if isinstance(p, tuple): if isinstance(p, tuple):
p, default= p p, default= p
AccessControl.Permission.registerPermissions( registerPermissions(((p, (), default),))
((p, (), default),))
else: else:
AccessControl.Permission.registerPermissions( registerPermissions(((p, ()),))
((p, ()),))
############################################################ ############################################################
# Constructor permission setup # Constructor permission setup
...@@ -137,11 +143,10 @@ class ProductContext: ...@@ -137,11 +143,10 @@ class ProductContext:
default = ('Manager',) default = ('Manager',)
pr=PermissionRole(permission,default) pr=PermissionRole(permission,default)
AccessControl.Permission.registerPermissions( registerPermissions(((permission, (), default),))
((permission, (), default),))
############################################################ ############################################################
OM=OFS.ObjectManager.ObjectManager OM = ObjectManager
for method in legacy: for method in legacy:
if isinstance(method, tuple): if isinstance(method, tuple):
...@@ -183,7 +188,7 @@ class ProductContext: ...@@ -183,7 +188,7 @@ class ProductContext:
else: else:
interfaces = tuple(implementedBy(instance_class)) interfaces = tuple(implementedBy(instance_class))
Products.meta_types=Products.meta_types+( Products.meta_types = Products.meta_types + (
{ 'name': meta_type or instance_class.meta_type, { 'name': meta_type or instance_class.meta_type,
# 'action': The action in the add drop down in the ZMI. This is # 'action': The action in the add drop down in the ZMI. This is
# currently also required by the _verifyObjectPaste # currently also required by the _verifyObjectPaste
...@@ -217,12 +222,12 @@ class ProductContext: ...@@ -217,12 +222,12 @@ class ProductContext:
m[name+'__roles__']=pr m[name+'__roles__']=pr
if icon: if icon:
name=os.path.split(icon)[1] name = os.path.split(icon)[1]
icon=Globals.ImageFile(icon, self.__pack.__dict__) icon = ImageFile(icon, self.__pack.__dict__)
icon.__roles__=None icon.__roles__=None
if not hasattr(OFS.misc_.misc_, pid): if not hasattr(misc_, pid):
setattr(OFS.misc_.misc_, pid, OFS.misc_.Misc_(pid, {})) setattr(misc_, pid, Misc_(pid, {}))
getattr(OFS.misc_.misc_, pid)[name]=icon getattr(misc_, pid)[name]=icon
def registerZClass(self, Z, meta_type=None): def registerZClass(self, Z, meta_type=None):
# #
...@@ -303,7 +308,7 @@ class ProductContext: ...@@ -303,7 +308,7 @@ class ProductContext:
return return
help=self.getProductHelp() help=self.getProductHelp()
path=os.path.join(Globals.package_home(self.__pack.__dict__), path=os.path.join(package_home(self.__pack.__dict__),
directory) directory)
# If help directory does not exist, log a warning and return. # If help directory does not exist, log a warning and return.
......
...@@ -15,14 +15,14 @@ Functions for refreshing products. ...@@ -15,14 +15,14 @@ Functions for refreshing products.
$Id$ $Id$
''' '''
import os, sys from logging import getLogger
import os
import sys
from time import time from time import time
from traceback import format_exception from traceback import format_exception
from logging import getLogger
import transaction
import Products
from ExtensionClass import Base from ExtensionClass import Base
from Globals import PersistentMapping from Persistence import PersistentMapping
LOG = getLogger('RefreshFuncs') LOG = getLogger('RefreshFuncs')
global_classes_timestamp = 0 global_classes_timestamp = 0
...@@ -32,9 +32,14 @@ _marker = [] # create a new marker object. ...@@ -32,9 +32,14 @@ _marker = [] # create a new marker object.
refresh_exc_info = {} refresh_exc_info = {}
class dummyClass: pass class dummyClass:
class dummyClass2 (Base): pass pass
def dummyFunc(): pass
class dummyClass2(Base):
pass
def dummyFunc():
pass
ClassTypes = (type(dummyClass), type(dummyClass2)) ClassTypes = (type(dummyClass), type(dummyClass2))
ModuleType = type(sys) ModuleType = type(sys)
...@@ -207,6 +212,7 @@ def getLastRefreshException(productid): ...@@ -207,6 +212,7 @@ def getLastRefreshException(productid):
# Functions for quickly scanning the dates of product modules. # Functions for quickly scanning the dates of product modules.
def tryFindProductDirectory(productid): def tryFindProductDirectory(productid):
import Products
path_join = os.path.join path_join = os.path.join
isdir = os.path.isdir isdir = os.path.isdir
exists = os.path.exists exists = os.path.exists
...@@ -316,6 +322,7 @@ def finishAutoRefresh(jar, productids): ...@@ -316,6 +322,7 @@ def finishAutoRefresh(jar, productids):
def autoRefresh(jar): def autoRefresh(jar):
# Must be called before there are any changes made # Must be called before there are any changes made
# by the connection to the database! # by the connection to the database!
import transaction
auto_refresh_ids = checkAutoRefresh(jar) auto_refresh_ids = checkAutoRefresh(jar)
if auto_refresh_ids: if auto_refresh_ids:
finishAutoRefresh(jar, auto_refresh_ids) finishAutoRefresh(jar, auto_refresh_ids)
......
...@@ -15,20 +15,21 @@ ...@@ -15,20 +15,21 @@
$Id$ $Id$
""" """
from Acquisition import aq_base, aq_parent, aq_inner from Acquisition import aq_base
from Globals import InitializeClass from Acquisition import aq_inner
from Acquisition import aq_parent
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import undo_changes from AccessControl.Permissions import undo_changes
from DateTime import DateTime from App.class_init import InitializeClass
import Globals, ExtensionClass from App.interfaces import IUndoSupport
from ZopeUndo.Prefix import Prefix from App.special_dtml import DTMLFile
from DateTime.DateTime import DateTime
import ExtensionClass
import transaction import transaction
from ZopeUndo.Prefix import Prefix
from zope.interface import implements from zope.interface import implements
from interfaces import IUndoSupport
class UndoSupport(ExtensionClass.Base): class UndoSupport(ExtensionClass.Base):
implements(IUndoSupport) implements(IUndoSupport)
...@@ -41,7 +42,7 @@ class UndoSupport(ExtensionClass.Base): ...@@ -41,7 +42,7 @@ class UndoSupport(ExtensionClass.Base):
) )
security.declareProtected(undo_changes, 'manage_UndoForm') security.declareProtected(undo_changes, 'manage_UndoForm')
manage_UndoForm=Globals.DTMLFile( manage_UndoForm = DTMLFile(
'dtml/undo', 'dtml/undo',
globals(), globals(),
PrincipiaUndoBatchSize=20, PrincipiaUndoBatchSize=20,
......
...@@ -12,15 +12,13 @@ ...@@ -12,15 +12,13 @@
############################################################################## ##############################################################################
import logging import logging
from AccessControl.PermissionRole import PermissionRole
import AccessControl.Permission
class ApplicationDefaultPermissions: from AccessControl.Permission import ApplicationDefaultPermissions # BBB
_View_Permission='Manager', 'Anonymous'
_Access_contents_information_Permission='Manager', 'Anonymous'
def default__class_init__(self): def default__class_init__(self):
from AccessControl.Permission import registerPermissions
from AccessControl.PermissionRole import PermissionRole
dict=self.__dict__ dict=self.__dict__
have=dict.has_key have=dict.has_key
ft=type(default__class_init__) ft=type(default__class_init__)
...@@ -66,7 +64,7 @@ def default__class_init__(self): ...@@ -66,7 +64,7 @@ def default__class_init__(self):
break break
if self.__dict__.has_key('__ac_permissions__'): if self.__dict__.has_key('__ac_permissions__'):
AccessControl.Permission.registerPermissions(self.__ac_permissions__) registerPermissions(self.__ac_permissions__)
for acp in self.__ac_permissions__: for acp in self.__ac_permissions__:
pname, mnames = acp[:2] pname, mnames = acp[:2]
if len(acp) > 2: if len(acp) > 2:
...@@ -81,3 +79,5 @@ def default__class_init__(self): ...@@ -81,3 +79,5 @@ def default__class_init__(self):
"Class %s.%s has a security declaration for " "Class %s.%s has a security declaration for "
"nonexistent method %r", self.__module__, "nonexistent method %r", self.__module__,
self.__name__, mname) self.__name__, mname)
InitializeClass = default__class_init__ # instead of Globals.Initialize
...@@ -62,16 +62,13 @@ def setConfiguration(cfg): ...@@ -62,16 +62,13 @@ def setConfiguration(cfg):
os.environ["SOFTWARE_HOME"] = cfg.softwarehome os.environ["SOFTWARE_HOME"] = cfg.softwarehome
os.environ["ZOPE_HOME"] = cfg.zopehome os.environ["ZOPE_HOME"] = cfg.zopehome
if "Globals" in sys.modules: import Globals # to set data
# XXX We *really* want to avoid this if Globals hasn't already Globals.data_dir = cfg.clienthome
# been imported, due to circular imports. ;-( # Globals does not export CLIENT_HOME
import Globals Globals.INSTANCE_HOME = cfg.instancehome
Globals.data_dir = cfg.clienthome Globals.SOFTWARE_HOME = cfg.softwarehome
# Globals does not export CLIENT_HOME Globals.ZOPE_HOME = cfg.zopehome
Globals.INSTANCE_HOME = cfg.instancehome Globals.DevelopmentMode = cfg.debug_mode
Globals.SOFTWARE_HOME = cfg.softwarehome
Globals.ZOPE_HOME = cfg.zopehome
Globals.DevelopmentMode = cfg.debug_mode
class DefaultConfiguration: class DefaultConfiguration:
""" """
......
import unittest import unittest
import Testing
import Zope2
Zope2.startup()
class TestPersistentUtil(unittest.TestCase):
def test_z3interfaces(self):
from App.interfaces import IPersistentExtra
from App.PersistentExtra import PersistentUtil
from zope.interface.verify import verifyClass
verifyClass(IPersistentExtra, PersistentUtil)
class TestPersistent(unittest.TestCase): class TestPersistent(unittest.TestCase):
...@@ -20,13 +7,14 @@ class TestPersistent(unittest.TestCase): ...@@ -20,13 +7,14 @@ class TestPersistent(unittest.TestCase):
from App.interfaces import IPersistentExtra from App.interfaces import IPersistentExtra
from Persistence import Persistent from Persistence import Persistent
from zope.interface.verify import verifyClass from zope.interface.verify import verifyClass
from App.PersistentExtra import patchPersistent
patchPersistent()
verifyClass(IPersistentExtra, Persistent) verifyClass(IPersistentExtra, Persistent)
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestPersistentUtil),
unittest.makeSuite(TestPersistent), unittest.makeSuite(TestPersistent),
)) ))
......
...@@ -15,22 +15,8 @@ ...@@ -15,22 +15,8 @@
$Id$ $Id$
""" """
import unittest import unittest
import ZODB
from App.CacheManager import CacheManager
class TestCacheManager(CacheManager):
# Derived CacheManager that fakes enough of the DatabaseManager to
# make it possible to test at least some parts of the CacheManager.
def __init__(self, connection):
self._p_jar = connection
class DummyConnection: class DummyConnection:
def __init__(self, db, version=None): def __init__(self, db, version=None):
...@@ -62,23 +48,35 @@ class DummyDB: ...@@ -62,23 +48,35 @@ class DummyDB:
class CacheManagerTestCase(unittest.TestCase): class CacheManagerTestCase(unittest.TestCase):
def setUp(self): def _getManagerClass(self):
self.db = DummyDB(42, 24) from App.CacheManager import CacheManager
self.connection = DummyConnection(self.db) class TestCacheManager(CacheManager):
self.manager = TestCacheManager(self.connection) # Derived CacheManager that fakes enough of the DatabaseManager to
# make it possible to test at least some parts of the CacheManager.
def __init__(self, connection):
self._p_jar = connection
return TestCacheManager
def _makeThem(self):
manager = self._getManagerClass()(connection)
return db, connection, manager
def test_cache_size(self): def test_cache_size(self):
self.assertEqual(self.manager.cache_size(), 42) db = DummyDB(42, 24)
self.db._set_sizes(12, 2) connection = DummyConnection(db)
self.assertEqual(self.manager.cache_size(), 12) manager = self._getManagerClass()(connection)
self.assertEqual(manager.cache_size(), 42)
db._set_sizes(12, 2)
self.assertEqual(manager.cache_size(), 12)
def test_version_cache_size(self): def test_version_cache_size(self):
self.connection = DummyConnection(self.db, "my version") db = DummyDB(42, 24)
self.manager = TestCacheManager(self.connection) connection = DummyConnection(db, "my version")
manager = self._getManagerClass()(connection)
# perform test # perform test
self.assertEqual(self.manager.cache_size(), 24) self.assertEqual(manager.cache_size(), 24)
self.db._set_sizes(12, 2) db._set_sizes(12, 2)
self.assertEqual(self.manager.cache_size(), 2) self.assertEqual(manager.cache_size(), 2)
def test_suite(): def test_suite():
......
...@@ -14,16 +14,14 @@ ...@@ -14,16 +14,14 @@
"""Tests class initialization. """Tests class initialization.
""" """
import ExtensionClass
from App.class_init import default__class_init__ as InitializeClass
def test_InitializeClass(): def test_InitializeClass():
"""Test that InitializeClass (default__class_init__) """Test that InitializeClass (default__class_init__)
works in specific corner cases. works in specific corner cases.
Check when the class has an ExtensionClass as attribute. Check when the class has an ExtensionClass as attribute.
>>> import ExtensionClass
>>> from App.class_init import InitializeClass
>>> class AnotherClass(ExtensionClass.Base): >>> class AnotherClass(ExtensionClass.Base):
... _need__name__ = 1 ... _need__name__ = 1
......
...@@ -13,21 +13,19 @@ ...@@ -13,21 +13,19 @@
############################################################################## ##############################################################################
"""Tests for App.config.setConfiguration() """Tests for App.config.setConfiguration()
""" """
import unittest
import os, sys, unittest
import Testing import Testing
import Zope2 #import Zope2
Zope2.startup() #Zope2.startup()
import App.config from Testing.ZopeTestCase.layer import ZopeLite
import App.FindHomes
import Globals
import __builtin__
class SetConfigTests(unittest.TestCase): class SetConfigTests(unittest.TestCase):
layer = ZopeLite
def setUp(self): def setUp(self):
# Save away everything as we need to restore it later on # Save away everything as we need to restore it later on
self.clienthome = self.getconfig('clienthome') self.clienthome = self.getconfig('clienthome')
...@@ -44,16 +42,22 @@ class SetConfigTests(unittest.TestCase): ...@@ -44,16 +42,22 @@ class SetConfigTests(unittest.TestCase):
debug_mode=self.debug_mode) debug_mode=self.debug_mode)
def getconfig(self, key): def getconfig(self, key):
import App.config
config = App.config.getConfiguration() config = App.config.getConfiguration()
return getattr(config, key, None) return getattr(config, key, None)
def setconfig(self, **kw): def setconfig(self, **kw):
import App.config
config = App.config.getConfiguration() config = App.config.getConfiguration()
for key, value in kw.items(): for key, value in kw.items():
setattr(config, key, value) setattr(config, key, value)
App.config.setConfiguration(config) App.config.setConfiguration(config)
def testClientHomeLegacySources(self): def testClientHomeLegacySources(self):
import os
import App.FindHomes
import Globals # for data
import __builtin__
self.setconfig(clienthome='foo') self.setconfig(clienthome='foo')
self.assertEqual(os.environ.get('CLIENT_HOME'), 'foo') self.assertEqual(os.environ.get('CLIENT_HOME'), 'foo')
self.assertEqual(App.FindHomes.CLIENT_HOME, 'foo') self.assertEqual(App.FindHomes.CLIENT_HOME, 'foo')
...@@ -61,6 +65,10 @@ class SetConfigTests(unittest.TestCase): ...@@ -61,6 +65,10 @@ class SetConfigTests(unittest.TestCase):
self.assertEqual(Globals.data_dir, 'foo') self.assertEqual(Globals.data_dir, 'foo')
def testInstanceHomeLegacySources(self): def testInstanceHomeLegacySources(self):
import os
import App.FindHomes
import Globals # for data
import __builtin__
self.setconfig(instancehome='foo') self.setconfig(instancehome='foo')
self.assertEqual(os.environ.get('INSTANCE_HOME'), 'foo') self.assertEqual(os.environ.get('INSTANCE_HOME'), 'foo')
self.assertEqual(App.FindHomes.INSTANCE_HOME, 'foo') self.assertEqual(App.FindHomes.INSTANCE_HOME, 'foo')
...@@ -68,6 +76,10 @@ class SetConfigTests(unittest.TestCase): ...@@ -68,6 +76,10 @@ class SetConfigTests(unittest.TestCase):
self.assertEqual(Globals.INSTANCE_HOME, 'foo') self.assertEqual(Globals.INSTANCE_HOME, 'foo')
def testSoftwareHomeLegacySources(self): def testSoftwareHomeLegacySources(self):
import os
import App.FindHomes
import Globals # for data
import __builtin__
self.setconfig(softwarehome='foo') self.setconfig(softwarehome='foo')
self.assertEqual(os.environ.get('SOFTWARE_HOME'), 'foo') self.assertEqual(os.environ.get('SOFTWARE_HOME'), 'foo')
self.assertEqual(App.FindHomes.SOFTWARE_HOME, 'foo') self.assertEqual(App.FindHomes.SOFTWARE_HOME, 'foo')
...@@ -75,6 +87,10 @@ class SetConfigTests(unittest.TestCase): ...@@ -75,6 +87,10 @@ class SetConfigTests(unittest.TestCase):
self.assertEqual(Globals.SOFTWARE_HOME, 'foo') self.assertEqual(Globals.SOFTWARE_HOME, 'foo')
def testZopeHomeLegacySources(self): def testZopeHomeLegacySources(self):
import os
import App.FindHomes
import Globals # for data
import __builtin__
self.setconfig(zopehome='foo') self.setconfig(zopehome='foo')
self.assertEqual(os.environ.get('ZOPE_HOME'), 'foo') self.assertEqual(os.environ.get('ZOPE_HOME'), 'foo')
self.assertEqual(App.FindHomes.ZOPE_HOME, 'foo') self.assertEqual(App.FindHomes.ZOPE_HOME, 'foo')
...@@ -82,6 +98,7 @@ class SetConfigTests(unittest.TestCase): ...@@ -82,6 +98,7 @@ class SetConfigTests(unittest.TestCase):
self.assertEqual(Globals.ZOPE_HOME, 'foo') self.assertEqual(Globals.ZOPE_HOME, 'foo')
def testDebugModeLegacySources(self): def testDebugModeLegacySources(self):
import Globals # for data
self.setconfig(debug_mode=True) self.setconfig(debug_mode=True)
self.assertEqual(Globals.DevelopmentMode, True) self.assertEqual(Globals.DevelopmentMode, True)
self.setconfig(debug_mode=False) self.setconfig(debug_mode=False)
......
...@@ -15,41 +15,48 @@ ...@@ -15,41 +15,48 @@
$Id$ $Id$
""" """
import os
import unittest import unittest
import Zope2
import App.version_txt
class VersionTextTestCase(unittest.TestCase): class VersionTextTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.fn = os.path.join(os.path.dirname(Zope2.__file__), "version.txt") self._resetModuleGlobals()
App.version_txt._test_reset()
def tearDown(self): def tearDown(self):
try: import os
os.unlink(self.fn) from App.version_txt import _version_file
except OSError: if _version_file is not None:
pass os.unlink(_version_file)
self._resetModuleGlobals()
def _resetModuleGlobals(self):
from App import version_txt
version_txt._version_file = None
version_txt._version_string = None
version_txt._zope_version = None
def writeVersion(self, s): def writeVersion(self, s):
f = open(self.fn, 'w') import os
f.write(s) import tempfile
f.close() from App import version_txt
assert version_txt._version_file is None
f, version_txt._version_file = tempfile.mkstemp()
os.write(f, s)
os.close(f)
def test_without_version_txt(self): def test_without_version_txt(self):
self.assertEqual(App.version_txt.getZopeVersion(), from App.version_txt import getZopeVersion
(-1, -1, -1, '', -1)) self.assertEqual(getZopeVersion(), (-1, -1, -1, '', -1))
def test_with_version_txt_final(self): def test_with_version_txt_final(self):
from App.version_txt import getZopeVersion
self.writeVersion("Zope 2.6.1 (source release, python 2.1, linux2)") self.writeVersion("Zope 2.6.1 (source release, python 2.1, linux2)")
self.assertEqual(App.version_txt.getZopeVersion(), self.assertEqual(getZopeVersion(), (2, 6, 1, '', -1))
(2, 6, 1, '', -1))
def test_with_version_txt_beta(self): def test_with_version_txt_beta(self):
from App.version_txt import getZopeVersion
self.writeVersion("Zope 2.6.1b2 (source release, python 2.1, linux2)") self.writeVersion("Zope 2.6.1b2 (source release, python 2.1, linux2)")
self.assertEqual(App.version_txt.getZopeVersion(), self.assertEqual(getZopeVersion(), (2, 6, 1, 'b', 2))
(2, 6, 1, 'b', 2))
def test_suite(): def test_suite():
......
...@@ -14,24 +14,26 @@ ...@@ -14,24 +14,26 @@
$id$ $id$
""" """
import os, sys, re import os
import Zope2 import re
import sys
_version_file = None
_version_string = None _version_string = None
_zope_version = None _zope_version = None
def _test_reset(): def _get_filename():
# Needed for testing. import Zope2
global _version_string, _zope_version if _version_file is not None:
_version_string = None return _version_file
_zope_version = None return os.path.join(os.path.dirname(Zope2.__file__), 'version.txt')
def _prep_version_data(): def _prep_version_data():
global _version_string, _zope_version global _version_string, _zope_version
if _version_string is None: if _version_string is None:
v = sys.version_info v = sys.version_info
pyver = "python %d.%d.%d, %s" % (v[0], v[1], v[2], sys.platform) pyver = "python %d.%d.%d, %s" % (v[0], v[1], v[2], sys.platform)
fn = os.path.join(os.path.dirname(Zope2.__file__), 'version.txt') fn = _get_filename()
expr = re.compile( expr = re.compile(
r'(?P<product>[A-Za-z0-9]+) +(?P<major>[0-9]+)' r'(?P<product>[A-Za-z0-9]+) +(?P<major>[0-9]+)'
'\.(?P<minor>[0-9]+)\.(?P<micro>[0-9]+)' '\.(?P<minor>[0-9]+)\.(?P<micro>[0-9]+)'
......
...@@ -10,44 +10,65 @@ ...@@ -10,44 +10,65 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Shared global data
"""Global definitions""" o N.B.: DO NOT IMPORT ANYTHING HERE! This module is just for shared data!
"""
__version__='$Revision: 1.56 $'[11:-2] __version__='$Revision: 1.56 $'[11:-2]
# Global constants: __replaceable__ flags: # BBB imports
NOT_REPLACEABLE = 0 from zope.deferredimport import deprecated
REPLACEABLE = 1
UNIQUE = 2
import Acquisition, ComputedAttribute, App.PersistentExtra, os deprecated("import TreeDisplay directly",
import TreeDisplay TreeDisplay = "TreeDisplay",
)
from App.Common import package_home, attrget, Dictionary deprecated("import from App.Common instead",
from App.config import getConfiguration as _getConfiguration package_home = 'App.Common.package_home',
from Persistence import Persistent, PersistentMapping attrget = 'App.Common.attrget',
from App.class_init import default__class_init__, ApplicationDefaultPermissions Dictionary = 'App.Common.Dictionary',
)
# Nicer alias for class initializer. deprecated("import from Persistence instead",
InitializeClass = default__class_init__ Persistent = 'Persistence:Persistent',
PersistentMapping = 'Persistence:PersistentMapping',
)
from App.special_dtml import HTML, HTMLFile, DTMLFile deprecated("import from App.class_init instead",
from App.Dialogs import MessageDialog InitializeClass = 'App.class_init:InitializeClass',
from App.ImageFile import ImageFile )
VersionNameName='Zope-Version' deprecated("import from AccessControl.Permission instead",
ApplicationDefaultPermissions =
'AccessControl.Permission:ApplicationDefaultPermissions',
)
deprecated("import from App.special_dtml instead",
HTML = 'App.special_dtml:HTML',
HTMLFile = 'App.special_dtml:HTMLFile',
DTMLFile = 'App.special_dtml:DTMLFile',
)
_cfg = _getConfiguration() deprecated("import from App.Dialogs instead",
data_dir = _cfg.clienthome MessageDialog = 'App.Dialogs:MessageDialog',
)
# backward compatibility deprecated("import from App.ImageFile instead",
INSTANCE_HOME = _cfg.instancehome ImageFile = 'App.ImageFile:ImageFile',
SOFTWARE_HOME = _cfg.softwarehome )
ZOPE_HOME = _cfg.zopehome
opened=[] deprecated("import from OFS.ObjectManager instead",
UNIQUE = 'OFS.ObjectManager:UNIQUE',
REPLACEABLE = 'OFS.ObjectManager:REPLACEABLE',
NOT_REPLACEABLE = 'OFS.ObjectManager:NOT_REPLACEABLE',
)
del deprecated
DevelopmentMode = False
VersionNameName='Zope-Version'
DevelopmentMode=_cfg.debug_mode # XXX ZODB stashes the main database object here
opened = []
del _cfg, _getConfiguration
...@@ -17,16 +17,16 @@ $Id$ ...@@ -17,16 +17,16 @@ $Id$
import types import types
from AccessControl import ClassSecurityInfo from AccessControl.SecurityInfo import ClassSecurityInfo
from Globals import DTMLFile from App.class_init import InitializeClass
from Globals import InitializeClass from App.special_dtml import DTMLFile
from Globals import Persistent from Persistence import Persistent
import HelpTopic from HelpTopic import HelpTopic # XXX relative to avoid cycle
_ignore_objects = {} _ignore_objects = {}
class APIHelpTopic(HelpTopic.HelpTopic): class APIHelpTopic(HelpTopic):
""" Provides API documentation. """ Provides API documentation.
""" """
......
...@@ -10,23 +10,23 @@ ...@@ -10,23 +10,23 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
from cgi import escape
import Acquisition
from OFS.SimpleItem import Item
from OFS.ObjectManager import ObjectManager
from Globals import Persistent, DTMLFile, HTML
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import access_contents_information from AccessControl.Permissions import access_contents_information
from AccessControl.Permissions import add_documents_images_and_files from AccessControl.Permissions import add_documents_images_and_files
from AccessControl.Permissions import view as View from AccessControl.Permissions import view as View
from AccessControl.SecurityInfo import ClassSecurityInfo
from Acquisition import Implicit
from App.class_init import InitializeClass
from App.special_dtml import DTMLFile
from App.special_dtml import HTML
from OFS.ObjectManager import ObjectManager
from OFS.SimpleItem import Item
from Persistence import Persistent
from Products.ZCatalog.ZCatalog import ZCatalog from Products.ZCatalog.ZCatalog import ZCatalog
from Products.ZCatalog.Lazy import LazyCat from Products.ZCatalog.Lazy import LazyCat
from cgi import escape
import Products
import HelpTopic
class HelpSys(Acquisition.Implicit, ObjectManager, Item, Persistent): class HelpSys(Implicit, ObjectManager, Item, Persistent):
""" """
Zope Help System Zope Help System
...@@ -48,6 +48,7 @@ class HelpSys(Acquisition.Implicit, ObjectManager, Item, Persistent): ...@@ -48,6 +48,7 @@ class HelpSys(Acquisition.Implicit, ObjectManager, Item, Persistent):
security.declareProtected(access_contents_information, 'helpValues') security.declareProtected(access_contents_information, 'helpValues')
def helpValues(self, spec=None): def helpValues(self, spec=None):
"ProductHelp objects of all Products that have help" "ProductHelp objects of all Products that have help"
import Products
hv=[] hv=[]
for product in self.Control_Panel.Products.objectValues(): for product in self.Control_Panel.Products.objectValues():
productHelp=product.getProductHelp() productHelp=product.getProductHelp()
...@@ -192,7 +193,7 @@ class TreeCollection: ...@@ -192,7 +193,7 @@ class TreeCollection:
return self.id return self.id
class ProductHelp(Acquisition.Implicit, ObjectManager, Item, Persistent): class ProductHelp(Implicit, ObjectManager, Item, Persistent):
""" """
Manages a collection of Help Topics for a given Product. Manages a collection of Help Topics for a given Product.
...@@ -240,8 +241,9 @@ class ProductHelp(Acquisition.Implicit, ObjectManager, Item, Persistent): ...@@ -240,8 +241,9 @@ class ProductHelp(Acquisition.Implicit, ObjectManager, Item, Persistent):
security.declareProtected(add_documents_images_and_files, 'addTopic') security.declareProtected(add_documents_images_and_files, 'addTopic')
def addTopic(self, id, title, REQUEST=None): def addTopic(self, id, title, REQUEST=None):
"Add a Help Topic" "Add a Help Topic"
topic=HelpTopic.DTMLDocumentTopic( from HelpSys.HelpTopic import DTMLDocumentTopic
HelpTopic.default_topic_content, __name__=id) from HelpSys.HelpTopic import default_topic_content
topic = DTMLDocumentTopic(default_topic_content, __name__=id)
topic.title=title topic.title=title
self._setObject(id, topic) self._setObject(id, topic)
if REQUEST is not None: if REQUEST is not None:
...@@ -297,6 +299,7 @@ class ProductHelp(Acquisition.Implicit, ObjectManager, Item, Persistent): ...@@ -297,6 +299,7 @@ class ProductHelp(Acquisition.Implicit, ObjectManager, Item, Persistent):
return topics return topics
def all_meta_types(self): def all_meta_types(self):
import Products
f=lambda x: x['name'] in ('Image', 'File') f=lambda x: x['name'] in ('Image', 'File')
return filter(f, Products.meta_types) + self.meta_types return filter(f, Products.meta_types) + self.meta_types
......
...@@ -10,19 +10,21 @@ ...@@ -10,19 +10,21 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import os
import Acquisition
from ComputedAttribute import ComputedAttribute
from OFS.SimpleItem import Item
from Globals import Persistent, HTML, DTMLFile, ImageFile
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import access_contents_information from AccessControl.Permissions import access_contents_information
from AccessControl.Permissions import view as View from AccessControl.Permissions import view as View
from AccessControl.SecurityInfo import ClassSecurityInfo
from Acquisition import Implicit
from App.class_init import InitializeClass
from App.ImageFile import ImageFile
from App.special_dtml import DTMLFile
from App.special_dtml import HTML
from ComputedAttribute import ComputedAttribute
from OFS.DTMLDocument import DTMLDocument from OFS.DTMLDocument import DTMLDocument
from OFS.PropertyManager import PropertyManager from OFS.PropertyManager import PropertyManager
import os.path from OFS.SimpleItem import Item
import Globals from Persistence import Persistent
class HelpTopicBase: class HelpTopicBase:
"Mix-in Help Topic support class" "Mix-in Help Topic support class"
...@@ -110,7 +112,7 @@ class HelpTopicBase: ...@@ -110,7 +112,7 @@ class HelpTopicBase:
return c return c
class HelpTopic(Acquisition.Implicit, HelpTopicBase, Item, PropertyManager, Persistent): class HelpTopic(Implicit, HelpTopicBase, Item, PropertyManager, Persistent):
""" """
Abstract base class for Help Topics Abstract base class for Help Topics
""" """
......
...@@ -15,13 +15,19 @@ ...@@ -15,13 +15,19 @@
__version__='$Revision: 1.12 $'[11:-2] __version__='$Revision: 1.12 $'[11:-2]
import sys, re import re
import Globals, Acquisition import sys
from Acquisition import Implicit
from App.class_init import default__class_init__
from App.Dialogs import MessageDialog
from App.special_dtml import HTML
from Persistence import Persistent
from zope.structuredtext.html import HTMLWithImages from zope.structuredtext.html import HTMLWithImages
from zope.structuredtext.document import DocumentWithImages from zope.structuredtext.document import DocumentWithImages
class HelpBase(Acquisition.Implicit): class HelpBase(Implicit):
""" """ """ """
def __bobo_traverse__(self, REQUEST, name=None): def __bobo_traverse__(self, REQUEST, name=None):
# A sneaky trick - we cant really _have_ an index_html # A sneaky trick - we cant really _have_ an index_html
...@@ -35,7 +41,7 @@ class HelpBase(Acquisition.Implicit): ...@@ -35,7 +41,7 @@ class HelpBase(Acquisition.Implicit):
return 1 return 1
class object(Acquisition.Implicit): class object(Implicit):
def __init__(self, name, ob, op=None): def __init__(self, name, ob, op=None):
self._name=name self._name=name
self._obj_=ob self._obj_=ob
...@@ -373,15 +379,15 @@ class methodobject(object): ...@@ -373,15 +379,15 @@ class methodobject(object):
_classtypes=(type(Globals.HTML), _classtypes=(type(HTML),
type(Globals.Persistent), type(Persistent),
) )
_methodtypes=(type([].sort), _methodtypes=(type([].sort),
type(Globals.default__class_init__), type(default__class_init__),
type(Globals.HTML.manage_edit), type(HTML.manage_edit),
type(Globals.HTML.__changed__), type(HTML.__changed__),
type(Globals.MessageDialog.manage_edit), type(MessageDialog.manage_edit),
) )
def is_module(ob): def is_module(ob):
......
...@@ -14,16 +14,16 @@ ...@@ -14,16 +14,16 @@
__version__='$Revision: 1.10 $'[11:-2] __version__='$Revision: 1.10 $'[11:-2]
import sys
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
import sys, Globals
from HelpUtil import HelpBase, classobject
from HelpUtil import is_class, is_module
from Globals import DTMLFile
from urllib import quote from urllib import quote
from AccessControl.SecurityInfo import ClassSecurityInfo
from App.class_init import InitializeClass
from App.special_dtml import DTMLFile
from HelpSys.HelpUtil import classobject
from HelpSys.HelpUtil import HelpBase
from HelpSys.HelpUtil import is_class
from HelpSys.HelpUtil import is_module
class ObjectItem(HelpBase, classobject): class ObjectItem(HelpBase, classobject):
......
...@@ -21,18 +21,21 @@ from cgi import escape ...@@ -21,18 +21,21 @@ from cgi import escape
from StringIO import StringIO from StringIO import StringIO
from warnings import warn from warnings import warn
import Globals, Products, App.Product, App.ProductRegistry import Products
import App.Product
import App.ProductRegistry
import transaction import transaction
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.User import UserFolder from AccessControl.User import UserFolder
from Acquisition import aq_base from Acquisition import aq_base
from App.ApplicationManager import ApplicationManager from App.ApplicationManager import ApplicationManager
from App.class_init import InitializeClass
from App.class_init import ApplicationDefaultPermissions
from App.config import getConfiguration from App.config import getConfiguration
from App.Product import doInstall from App.Product import doInstall
from App.ProductContext import ProductContext
from DateTime import DateTime from DateTime import DateTime
from HelpSys.HelpSys import HelpSys from HelpSys.HelpSys import HelpSys
from Persistence import Persistent
from webdav.NullResource import NullResource from webdav.NullResource import NullResource
from zExceptions import Redirect as RedirectException, Forbidden from zExceptions import Redirect as RedirectException, Forbidden
...@@ -47,24 +50,26 @@ from misc_ import Misc_ ...@@ -47,24 +50,26 @@ from misc_ import Misc_
LOG = getLogger('Application') LOG = getLogger('Application')
class Application(Globals.ApplicationDefaultPermissions, class Application(ApplicationDefaultPermissions,
ZDOM.Root, Folder.Folder, ZDOM.Root,
App.ProductRegistry.ProductRegistry, FindSupport): Folder.Folder,
App.ProductRegistry.ProductRegistry,
FindSupport,
):
"""Top-level system object""" """Top-level system object"""
implements(IApplication) implements(IApplication)
security = ClassSecurityInfo() security = ClassSecurityInfo()
title ='Zope' title = 'Zope'
__defined_roles__=('Manager','Anonymous','Owner') __defined_roles__ = ('Manager','Anonymous','Owner')
web__form__method='GET' web__form__method = 'GET'
isTopLevelPrincipiaApplicationObject=1 isTopLevelPrincipiaApplicationObject = 1
_isBeingUsedAsAMethod_=0 _isBeingUsedAsAMethod_ = 0
# Create the help system object # Create the help system object
HelpSys=HelpSys('HelpSys') HelpSys = HelpSys('HelpSys')
p_=misc_.p_ p_=misc_.p_
misc_=misc_.misc_ misc_=misc_.misc_
...@@ -78,7 +83,7 @@ class Application(Globals.ApplicationDefaultPermissions, ...@@ -78,7 +83,7 @@ class Application(Globals.ApplicationDefaultPermissions,
# UserFolder is deleted. This is necessary to allow people # UserFolder is deleted. This is necessary to allow people
# to replace the top-level UserFolder object. # to replace the top-level UserFolder object.
__allow_groups__=UserFolder() __allow_groups__ = UserFolder()
# Set the universal default method to index_html # Set the universal default method to index_html
_object_manager_browser_default_id = 'index_html' _object_manager_browser_default_id = 'index_html'
...@@ -87,19 +92,21 @@ class Application(Globals.ApplicationDefaultPermissions, ...@@ -87,19 +92,21 @@ class Application(Globals.ApplicationDefaultPermissions,
def __init__(self): def __init__(self):
# Initialize users # Initialize users
uf=UserFolder() uf = UserFolder()
self.__allow_groups__=uf self.__allow_groups__ = uf
self._setObject('acl_users', uf) self._setObject('acl_users', uf)
# Initialize control panel # Initialize control panel
cpl=ApplicationManager() cpl = ApplicationManager()
cpl._init() cpl._init()
self._setObject('Control_Panel', cpl) self._setObject('Control_Panel', cpl)
transaction.get().note("Created Zope Application") transaction.get().note("Created Zope Application")
def id(self): def id(self):
try: return self.REQUEST['SCRIPT_NAME'][1:] try:
except: return self.title return self.REQUEST['SCRIPT_NAME'][1:]
except:
return self.title
def title_and_id(self): def title_and_id(self):
return self.title return self.title
...@@ -120,17 +127,24 @@ class Application(Globals.ApplicationDefaultPermissions, ...@@ -120,17 +127,24 @@ class Application(Globals.ApplicationDefaultPermissions,
def __bobo_traverse__(self, REQUEST, name=None): def __bobo_traverse__(self, REQUEST, name=None):
try: return getattr(self, name) try:
except AttributeError: pass return getattr(self, name)
try: return self[name] except AttributeError:
except KeyError: pass pass
method=REQUEST.get('REQUEST_METHOD', 'GET')
try:
return self[name]
except KeyError:
pass
method = REQUEST.get('REQUEST_METHOD', 'GET')
if not method in ('GET', 'POST'): if not method in ('GET', 'POST'):
return NullResource(self, name, REQUEST).__of__(self) return NullResource(self, name, REQUEST).__of__(self)
# Waaa. unrestrictedTraverse calls us with a fake REQUEST. # Waaa. unrestrictedTraverse calls us with a fake REQUEST.
# There is proabably a better fix for this. # There is proabably a better fix for this.
try: REQUEST.RESPONSE.notFoundError("%s\n%s" % (name, method)) try:
REQUEST.RESPONSE.notFoundError("%s\n%s" % (name, method))
except AttributeError: except AttributeError:
raise KeyError, name raise KeyError, name
...@@ -286,7 +300,7 @@ class Application(Globals.ApplicationDefaultPermissions, ...@@ -286,7 +300,7 @@ class Application(Globals.ApplicationDefaultPermissions,
InitializeClass(Application) InitializeClass(Application)
class Expired(Globals.Persistent): class Expired(Persistent):
icon='p_/broken' icon='p_/broken'
...@@ -345,7 +359,7 @@ class AppInitializer: ...@@ -345,7 +359,7 @@ class AppInitializer:
# Ensure that Control Panel exists. # Ensure that Control Panel exists.
if not hasattr(app, 'Control_Panel'): if not hasattr(app, 'Control_Panel'):
cpl=ApplicationManager() cpl = ApplicationManager()
cpl._init() cpl._init()
app._setObject('Control_Panel', cpl) app._setObject('Control_Panel', cpl)
self.commit('Added Control_Panel') self.commit('Added Control_Panel')
...@@ -535,15 +549,18 @@ class AppInitializer: ...@@ -535,15 +549,18 @@ class AppInitializer:
app = self.getApp() app = self.getApp()
if app._getInitializerFlag('virtual_hosting'): if app._getInitializerFlag('virtual_hosting'):
return return
if not app.objectIds('Virtual Host Monster') and not hasattr(app, 'virtual_hosting'): if (not app.objectIds('Virtual Host Monster') and
from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster not hasattr(app, 'virtual_hosting')):
vhm=VirtualHostMonster() from Products.SiteAccess.VirtualHostMonster \
vhm.id='virtual_hosting' import VirtualHostMonster
vhm = VirtualHostMonster()
vhm.id = 'virtual_hosting'
vhm.addToContainer(app) vhm.addToContainer(app)
app._setInitializerFlag('virtual_hosting') app._setInitializerFlag('virtual_hosting')
self.commit('Added virtual_hosting') self.commit('Added virtual_hosting')
def check_zglobals(self): def check_zglobals(self):
import Globals
if not doInstall(): if not doInstall():
return return
...@@ -615,7 +632,7 @@ def install_products(app): ...@@ -615,7 +632,7 @@ def install_products(app):
meta_types=[] meta_types=[]
done={} done={}
debug_mode = App.config.getConfiguration().debug_mode debug_mode = getConfiguration().debug_mode
transaction.get().note('Prior to product installs') transaction.get().note('Prior to product installs')
transaction.commit() transaction.commit()
...@@ -673,7 +690,7 @@ def import_products(): ...@@ -673,7 +690,7 @@ def import_products():
done={} done={}
products = get_products() products = get_products()
debug_mode = App.config.getConfiguration().debug_mode debug_mode = getConfiguration().debug_mode
for priority, product_name, index, product_dir in products: for priority, product_name, index, product_dir in products:
if done.has_key(product_name): if done.has_key(product_name):
...@@ -739,6 +756,7 @@ def get_folder_permissions(): ...@@ -739,6 +756,7 @@ def get_folder_permissions():
def install_product(app, product_dir, product_name, meta_types, def install_product(app, product_dir, product_name, meta_types,
folder_permissions, raise_exc=0, log_exc=1): folder_permissions, raise_exc=0, log_exc=1):
from App.ProductContext import ProductContext
path_join=os.path.join path_join=os.path.join
isdir=os.path.isdir isdir=os.path.isdir
exists=os.path.exists exists=os.path.exists
...@@ -846,6 +864,7 @@ def install_product(app, product_dir, product_name, meta_types, ...@@ -846,6 +864,7 @@ def install_product(app, product_dir, product_name, meta_types,
def install_package(app, module, init_func, raise_exc=False, log_exc=True): def install_package(app, module, init_func, raise_exc=False, log_exc=True):
"""Installs a Python package like a product.""" """Installs a Python package like a product."""
from App.ProductContext import ProductContext
try: try:
product = App.Product.initializeProduct(module, product = App.Product.initializeProduct(module,
module.__name__, module.__name__,
...@@ -878,13 +897,16 @@ def install_standards(app): ...@@ -878,13 +897,16 @@ def install_standards(app):
return return
# Install the replaceable standard objects # Install the replaceable standard objects
from App.Common import package_home
from App.special_dtml import DTMLFile
from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplateFile import PageTemplateFile
std_dir = os.path.join(Globals.package_home(globals()), 'standard')
std_dir = os.path.join(package_home(globals()), 'standard')
wrote = 0 wrote = 0
for fn in os.listdir(std_dir): for fn in os.listdir(std_dir):
base, ext = os.path.splitext(fn) base, ext = os.path.splitext(fn)
if ext == '.dtml': if ext == '.dtml':
ob = Globals.DTMLFile(base, std_dir) ob = DTMLFile(base, std_dir)
fn = base fn = base
if hasattr(app, fn): if hasattr(app, fn):
continue continue
......
...@@ -14,18 +14,22 @@ ...@@ -14,18 +14,22 @@
$Id$ $Id$
""" """
import time, sys
from logging import getLogger from logging import getLogger
import Globals import sys
from Globals import InitializeClass import time
from Globals import DTMLFile
from Acquisition import aq_get, aq_acquire, aq_inner, aq_parent, aq_base
from AccessControl import ClassSecurityInfo
from AccessControl import getSecurityManager
from AccessControl.Role import _isBeingUsedAsAMethod
from AccessControl import Unauthorized
from AccessControl.Permissions import view_management_screens from AccessControl.Permissions import view_management_screens
from AccessControl.Role import _isBeingUsedAsAMethod
from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.unauthorized import Unauthorized
from Acquisition import aq_acquire
from Acquisition import aq_base
from Acquisition import aq_get
from Acquisition import aq_inner
from Acquisition import aq_parent
from App.class_init import InitializeClass
from App.special_dtml import DTMLFile
ZCM_MANAGERS = '__ZCacheManager_ids__' ZCM_MANAGERS = '__ZCacheManager_ids__'
......
...@@ -15,23 +15,33 @@ ...@@ -15,23 +15,33 @@
$Id$ $Id$
""" """
import re, sys, tempfile
import warnings
from cgi import escape from cgi import escape
from marshal import loads, dumps from marshal import dumps
from urllib import quote, unquote from marshal import loads
from zlib import compress, decompress import re
import sys
import Globals, Moniker, ExtensionClass import tempfile
from urllib import quote
from urllib import unquote
import warnings
from zlib import compress
from zlib import decompress
import transaction import transaction
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from AccessControl.Permissions import view_management_screens from AccessControl.Permissions import view_management_screens
from AccessControl.Permissions import copy_or_move from AccessControl.Permissions import copy_or_move
from AccessControl.Permissions import delete_objects from AccessControl.Permissions import delete_objects
from Acquisition import aq_base, aq_inner, aq_parent from Acquisition import aq_base
from Acquisition import aq_inner
from Acquisition import aq_parent
from App.class_init import InitializeClass
from App.Dialogs import MessageDialog from App.Dialogs import MessageDialog
from App.special_dtml import HTML
from App.special_dtml import HTMLFile
from App.special_dtml import DTMLFile
from ExtensionClass import Base
from webdav.Lockable import ResourceLockedError from webdav.Lockable import ResourceLockedError
from zExceptions import Unauthorized, BadRequest from zExceptions import Unauthorized, BadRequest
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
...@@ -40,22 +50,25 @@ from zope.event import notify ...@@ -40,22 +50,25 @@ from zope.event import notify
from zope.lifecycleevent import ObjectCopiedEvent from zope.lifecycleevent import ObjectCopiedEvent
from zope.app.container.contained import ObjectMovedEvent from zope.app.container.contained import ObjectMovedEvent
from zope.app.container.contained import notifyContainerModified from zope.app.container.contained import notifyContainerModified
from OFS.event import ObjectWillBeMovedEvent from OFS.event import ObjectWillBeMovedEvent
from OFS.event import ObjectClonedEvent from OFS.event import ObjectClonedEvent
import OFS.subscribers
from OFS.interfaces import ICopyContainer from OFS.interfaces import ICopyContainer
from OFS.interfaces import ICopySource from OFS.interfaces import ICopySource
from OFS.Moniker import loadMoniker
from OFS.Moniker import Moniker
from OFS.subscribers import compatibilityCall
class CopyError(Exception): pass class CopyError(Exception):
pass
copy_re = re.compile('^copy([0-9]*)_of_(.*)') copy_re = re.compile('^copy([0-9]*)_of_(.*)')
_marker=[] _marker=[]
class CopyContainer(ExtensionClass.Base): class CopyContainer(Base):
"""Interface for containerish objects which allow cut/copy/paste""" """Interface for containerish objects which allow cut/copy/paste"""
...@@ -103,7 +116,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -103,7 +116,7 @@ class CopyContainer(ExtensionClass.Base):
if not ob.cb_isMoveable(): if not ob.cb_isMoveable():
raise CopyError, eNotSupported % escape(id) raise CopyError, eNotSupported % escape(id)
m=Moniker.Moniker(ob) m = Moniker(ob)
oblist.append(m.dump()) oblist.append(m.dump())
cp=(1, oblist) cp=(1, oblist)
cp=_cb_encode(cp) cp=_cb_encode(cp)
...@@ -129,7 +142,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -129,7 +142,7 @@ class CopyContainer(ExtensionClass.Base):
ob=self._getOb(id) ob=self._getOb(id)
if not ob.cb_isCopyable(): if not ob.cb_isCopyable():
raise CopyError, eNotSupported % escape(id) raise CopyError, eNotSupported % escape(id)
m=Moniker.Moniker(ob) m = Moniker(ob)
oblist.append(m.dump()) oblist.append(m.dump())
cp=(0, oblist) cp=(0, oblist)
cp=_cb_encode(cp) cp=_cb_encode(cp)
...@@ -185,7 +198,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -185,7 +198,7 @@ class CopyContainer(ExtensionClass.Base):
oblist = [] oblist = []
app = self.getPhysicalRoot() app = self.getPhysicalRoot()
for mdata in mdatas: for mdata in mdatas:
m = Moniker.loadMoniker(mdata) m = loadMoniker(mdata)
try: try:
ob = m.bind(app) ob = m.bind(app)
except ConflictError: except ConflictError:
...@@ -227,7 +240,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -227,7 +240,7 @@ class CopyContainer(ExtensionClass.Base):
ob._postCopy(self, op=0) ob._postCopy(self, op=0)
OFS.subscribers.compatibilityCall('manage_afterClone', ob, ob) compatibilityCall('manage_afterClone', ob, ob)
notify(ObjectClonedEvent(ob)) notify(ObjectClonedEvent(ob))
...@@ -309,7 +322,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -309,7 +322,7 @@ class CopyContainer(ExtensionClass.Base):
return result return result
security.declareProtected(view_management_screens, 'manage_renameForm') security.declareProtected(view_management_screens, 'manage_renameForm')
manage_renameForm=Globals.DTMLFile('dtml/renameForm', globals()) manage_renameForm = DTMLFile('dtml/renameForm', globals())
security.declareProtected(view_management_screens, 'manage_renameObjects') security.declareProtected(view_management_screens, 'manage_renameObjects')
def manage_renameObjects(self, ids=[], new_ids=[], REQUEST=None): def manage_renameObjects(self, ids=[], new_ids=[], REQUEST=None):
...@@ -427,7 +440,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -427,7 +440,7 @@ class CopyContainer(ExtensionClass.Base):
ob._postCopy(self, op=0) ob._postCopy(self, op=0)
OFS.subscribers.compatibilityCall('manage_afterClone', ob, ob) compatibilityCall('manage_afterClone', ob, ob)
notify(ObjectClonedEvent(ob)) notify(ObjectClonedEvent(ob))
...@@ -447,7 +460,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -447,7 +460,7 @@ class CopyContainer(ExtensionClass.Base):
app = self.getPhysicalRoot() app = self.getPhysicalRoot()
for mdata in cp[1]: for mdata in cp[1]:
m = Moniker.loadMoniker(mdata) m = loadMoniker(mdata)
oblist.append(m.bind(app)) oblist.append(m.bind(app))
return oblist return oblist
...@@ -527,7 +540,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -527,7 +540,7 @@ class CopyContainer(ExtensionClass.Base):
InitializeClass(CopyContainer) InitializeClass(CopyContainer)
class CopySource(ExtensionClass.Base): class CopySource(Base):
"""Interface for objects which allow themselves to be copied.""" """Interface for objects which allow themselves to be copied."""
...@@ -645,7 +658,7 @@ def cookie_path(request): ...@@ -645,7 +658,7 @@ def cookie_path(request):
fMessageDialog=Globals.HTML(""" fMessageDialog = HTML("""
<HTML> <HTML>
<HEAD> <HEAD>
<TITLE>&dtml-title;</TITLE> <TITLE>&dtml-title;</TITLE>
......
...@@ -14,20 +14,25 @@ ...@@ -14,20 +14,25 @@
$Id$ $Id$
""" """
from Globals import InitializeClass
from ZPublisher.Converters import type_converters
from Globals import HTML, DTMLFile, MessageDialog
from zope.contenttype import guess_content_type
from DTMLMethod import DTMLMethod, decapitate
from PropertyManager import PropertyManager
from webdav.common import rfc1123_date
from webdav.Lockable import ResourceLockedError
from sgmllib import SGMLParser from sgmllib import SGMLParser
from urllib import quote from urllib import quote
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from AccessControl.Permissions import change_dtml_methods from AccessControl.Permissions import change_dtml_methods
from AccessControl.Permissions import change_dtml_documents from AccessControl.Permissions import change_dtml_documents
from App.class_init import InitializeClass
from App.Dialogs import MessageDialog
from App.special_dtml import DTMLFile
from App.special_dtml import HTML
from OFS.DTMLMethod import decapitate
from OFS.DTMLMethod import DTMLMethod
from webdav.common import rfc1123_date
from webdav.Lockable import ResourceLockedError
from zExceptions.TracebackSupplement import PathTracebackSupplement from zExceptions.TracebackSupplement import PathTracebackSupplement
from zope.contenttype import guess_content_type
from ZPublisher.Converters import type_converters
from OFS.PropertyManager import PropertyManager
done='done' done='done'
......
...@@ -14,20 +14,17 @@ ...@@ -14,20 +14,17 @@
$Id$ $Id$
""" """
import History import sys
from Globals import HTML, DTMLFile, MessageDialog from urllib import quote
from Globals import InitializeClass
from SimpleItem import Item_w__name__, pretty_tb from AccessControl.SecurityInfo import ClassSecurityInfo
from zope.contenttype import guess_content_type
from PropertyManager import PropertyManager
from AccessControl import ClassSecurityInfo
from AccessControl.Role import RoleManager from AccessControl.Role import RoleManager
from webdav.common import rfc1123_date from Acquisition import Implicit
from webdav.Lockable import ResourceLockedError from App.class_init import InitializeClass
from ZDOM import ElementWithTitle from App.Dialogs import MessageDialog
from App.special_dtml import DTMLFile
from App.special_dtml import HTML
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
from urllib import quote
import Globals, sys, Acquisition
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from AccessControl.Permissions import change_dtml_methods from AccessControl.Permissions import change_dtml_methods
from AccessControl.Permissions import view_management_screens from AccessControl.Permissions import view_management_screens
...@@ -36,18 +33,32 @@ from AccessControl.Permissions import view as View ...@@ -36,18 +33,32 @@ from AccessControl.Permissions import view as View
from AccessControl.Permissions import ftp_access from AccessControl.Permissions import ftp_access
from AccessControl.DTML import RestrictedDTML from AccessControl.DTML import RestrictedDTML
from AccessControl.requestmethod import requestmethod from AccessControl.requestmethod import requestmethod
from Cache import Cacheable from webdav.common import rfc1123_date
from webdav.Lockable import ResourceLockedError
from zExceptions import Forbidden from zExceptions import Forbidden
from zExceptions.TracebackSupplement import PathTracebackSupplement from zExceptions.TracebackSupplement import PathTracebackSupplement
from ZPublisher.Iterators import IStreamIterator from ZPublisher.Iterators import IStreamIterator
from zope.contenttype import guess_content_type
from OFS.Cache import Cacheable
from OFS.History import Historical
from OFS.History import html_diff
from OFS.PropertyManager import PropertyManager
from OFS.SimpleItem import Item_w__name__
from OFS.SimpleItem import pretty_tb
from OFS.ZDOM import ElementWithTitle
_marker = [] # Create a new marker object. _marker = [] # Create a new marker object.
class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, class DTMLMethod(RestrictedDTML,
ElementWithTitle, Item_w__name__, HTML,
History.Historical, Implicit,
RoleManager,
ElementWithTitle,
Item_w__name__,
Historical,
Cacheable, Cacheable,
): ):
"""DTML Method objects are DocumentTemplate.HTML objects that act """DTML Method objects are DocumentTemplate.HTML objects that act
as methods of their containers.""" as methods of their containers."""
meta_type='DTML Method' meta_type='DTML Method'
...@@ -59,12 +70,13 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -59,12 +70,13 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
security.declareObjectProtected(View) security.declareObjectProtected(View)
# Documents masquerade as functions: # Documents masquerade as functions:
class func_code: pass class func_code:
pass
func_code=func_code() func_code=func_code()
func_code.co_varnames='self','REQUEST','RESPONSE' func_code.co_varnames = 'self','REQUEST','RESPONSE'
func_code.co_argcount=3 func_code.co_argcount = 3
manage_options=( manage_options = (
( (
{'label':'Edit', 'action':'manage_main', {'label':'Edit', 'action':'manage_main',
'help':('OFSP','DTML-DocumentOrMethod_Edit.stx')}, 'help':('OFSP','DTML-DocumentOrMethod_Edit.stx')},
...@@ -76,10 +88,10 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -76,10 +88,10 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
{'label':'Proxy', 'action':'manage_proxyForm', {'label':'Proxy', 'action':'manage_proxyForm',
'help':('OFSP','DTML-DocumentOrMethod_Proxy.stx')}, 'help':('OFSP','DTML-DocumentOrMethod_Proxy.stx')},
) )
+History.Historical.manage_options + Historical.manage_options
+RoleManager.manage_options + RoleManager.manage_options
+Item_w__name__.manage_options + Item_w__name__.manage_options
+Cacheable.manage_options + Cacheable.manage_options
) )
# Careful in permissiong changes--used by DTMLDocument! # Careful in permissiong changes--used by DTMLDocument!
...@@ -375,9 +387,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -375,9 +387,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
historyComparisonResults=''): historyComparisonResults=''):
return DTMLMethod.inheritedAttribute('manage_historyCompare')( return DTMLMethod.inheritedAttribute('manage_historyCompare')(
self, rev1, rev2, REQUEST, self, rev1, rev2, REQUEST,
historyComparisonResults=History.html_diff( historyComparisonResults = html_diff(rev1.read(), rev2.read()))
rev1.read(), rev2.read()
))
InitializeClass(DTMLMethod) InitializeClass(DTMLMethod)
......
...@@ -17,23 +17,24 @@ $Id$ ...@@ -17,23 +17,24 @@ $Id$
from string import translate from string import translate
import ExtensionClass
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.DTML import RestrictedDTML from AccessControl.DTML import RestrictedDTML
from AccessControl.Permission import name_trans from AccessControl.Permission import name_trans
from AccessControl.Permissions import view_management_screens from AccessControl.Permissions import view_management_screens
from Acquisition import aq_base from Acquisition import aq_base
from DateTime import DateTime from App.special_dtml import DTMLFile
from App.class_init import InitializeClass
from DateTime.DateTime import DateTime
from DocumentTemplate.DT_Util import Eval from DocumentTemplate.DT_Util import Eval
from DocumentTemplate.DT_Util import InstanceDict, TemplateDict from DocumentTemplate.DT_Util import InstanceDict
from Globals import DTMLFile from DocumentTemplate.DT_Util import TemplateDict
from Globals import InitializeClass from ExtensionClass import Base
from zope.interface import implements from zope.interface import implements
from interfaces import IFindSupport from OFS.interfaces import IFindSupport
class FindSupport(ExtensionClass.Base): class FindSupport(Base):
"""Find support for Zope Folders""" """Find support for Zope Folders"""
......
...@@ -17,18 +17,21 @@ Folders are the basic container objects and are analogous to directories. ...@@ -17,18 +17,21 @@ Folders are the basic container objects and are analogous to directories.
$Id$ $Id$
""" """
import AccessControl.Role, webdav.Collection
from Globals import InitializeClass
from AccessControl import getSecurityManager
from AccessControl import Unauthorized
from AccessControl.Permissions import add_page_templates from AccessControl.Permissions import add_page_templates
from AccessControl.Permissions import add_user_folders from AccessControl.Permissions import add_user_folders
from Globals import DTMLFile from AccessControl.Role import RoleManager
from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.unauthorized import Unauthorized
from App.class_init import InitializeClass
from App.special_dtml import DTMLFile
from webdav.Collection import Collection
from zope.interface import implements from zope.interface import implements
import FindSupport from OFS.FindSupport import FindSupport
import SimpleItem, ObjectManager, PropertyManager from OFS.interfaces import IFolder
from interfaces import IFolder from OFS.ObjectManager import ObjectManager
from OFS.PropertyManager import PropertyManager
from OFS.SimpleItem import Item
manage_addFolderForm=DTMLFile('dtml/folderAdd', globals()) manage_addFolderForm=DTMLFile('dtml/folderAdd', globals())
...@@ -70,12 +73,12 @@ def manage_addFolder(self, id, title='', ...@@ -70,12 +73,12 @@ def manage_addFolder(self, id, title='',
class Folder( class Folder(
ObjectManager.ObjectManager, ObjectManager,
PropertyManager.PropertyManager, PropertyManager,
AccessControl.Role.RoleManager, RoleManager,
webdav.Collection.Collection, Collection,
SimpleItem.Item, Item,
FindSupport.FindSupport, FindSupport,
): ):
"""Folders are basic container objects that provide a standard """Folders are basic container objects that provide a standard
...@@ -89,15 +92,15 @@ class Folder( ...@@ -89,15 +92,15 @@ class Folder(
_properties=({'id':'title', 'type': 'string','mode':'wd'},) _properties=({'id':'title', 'type': 'string','mode':'wd'},)
manage_options=( manage_options=(
ObjectManager.ObjectManager.manage_options+ ObjectManager.manage_options+
( (
{'label':'View', 'action':'', {'label':'View', 'action':'',
'help':('OFSP','Folder_View.stx')}, 'help':('OFSP','Folder_View.stx')},
)+ )+
PropertyManager.PropertyManager.manage_options+ PropertyManager.manage_options+
AccessControl.Role.RoleManager.manage_options+ RoleManager.manage_options+
SimpleItem.Item.manage_options+ Item.manage_options+
FindSupport.FindSupport.manage_options FindSupport.manage_options
) )
__ac_permissions__=() __ac_permissions__=()
......
...@@ -14,19 +14,25 @@ ...@@ -14,19 +14,25 @@
$Id$ $Id$
""" """
import Globals, ExtensionClass, difflib
from Globals import InitializeClass
from DateTime import DateTime
from Acquisition import Implicit, aq_base
from struct import pack, unpack
from cgi import escape from cgi import escape
from zExceptions import Redirect import difflib
from AccessControl import ClassSecurityInfo from struct import pack, unpack
from AccessControl.Permissions import view_history from AccessControl.Permissions import view_history
from AccessControl.SecurityInfo import ClassSecurityInfo
from Acquisition import aq_base
from Acquisition import Implicit
from App.class_init import InitializeClass
from App.special_dtml import DTMLFile
from DateTime.DateTime import DateTime
from ExtensionClass import Base
from zExceptions import Redirect
class TemporalParadox(Exception): pass class TemporalParadox(Exception):
pass
class HistorySelectionError(Exception): pass class HistorySelectionError(Exception):
pass
class HystoryJar: class HystoryJar:
"""A ZODB Connection-like object that provides access to data """A ZODB Connection-like object that provides access to data
...@@ -75,7 +81,7 @@ class Historian(Implicit): ...@@ -75,7 +81,7 @@ class Historian(Implicit):
"We aren't real, so we delegate to that that spawned us!" "We aren't real, so we delegate to that that spawned us!"
raise Redirect, REQUEST['URL2']+'/manage_change_history_page' raise Redirect, REQUEST['URL2']+'/manage_change_history_page'
class Historical(ExtensionClass.Base): class Historical(Base):
"""Mix-in class to provide a veiw that shows hystorical changes """Mix-in class to provide a veiw that shows hystorical changes
The display is similar to that used for undo, except that the transactions The display is similar to that used for undo, except that the transactions
...@@ -97,7 +103,7 @@ class Historical(ExtensionClass.Base): ...@@ -97,7 +103,7 @@ class Historical(ExtensionClass.Base):
) )
security.declareProtected(view_history, 'manage_change_history_page') security.declareProtected(view_history, 'manage_change_history_page')
manage_change_history_page=Globals.DTMLFile( manage_change_history_page = DTMLFile(
'dtml/history', globals(), 'dtml/history', globals(),
HistoryBatchSize=20, HistoryBatchSize=20,
first_transaction=0, last_transaction=20) first_transaction=0, last_transaction=20)
...@@ -155,7 +161,7 @@ class Historical(ExtensionClass.Base): ...@@ -155,7 +161,7 @@ class Historical(ExtensionClass.Base):
def manage_afterHistoryCopy(self): pass # ? (Hook) def manage_afterHistoryCopy(self): pass # ? (Hook)
_manage_historyComparePage=Globals.DTMLFile( _manage_historyComparePage = DTMLFile(
'dtml/historyCompare', globals(), management_view='History') 'dtml/historyCompare', globals(), management_view='History')
security.declareProtected(view_history, 'manage_historyCompare') security.declareProtected(view_history, 'manage_historyCompare')
def manage_historyCompare(self, rev1, rev2, REQUEST, def manage_historyCompare(self, rev1, rev2, REQUEST,
......
...@@ -14,48 +14,53 @@ ...@@ -14,48 +14,53 @@
$Id$ $Id$
""" """
from cgi import escape
from cStringIO import StringIO
from mimetools import choose_boundary
import struct import struct
from zope.contenttype import guess_content_type
from zope.interface import implementedBy
from zope.interface import implements
from Globals import DTMLFile
from Globals import InitializeClass
from PropertyManager import PropertyManager
from AccessControl import ClassSecurityInfo
from AccessControl.Role import RoleManager
from AccessControl.Permissions import change_images_and_files from AccessControl.Permissions import change_images_and_files
from AccessControl.Permissions import view_management_screens from AccessControl.Permissions import view_management_screens
from AccessControl.Permissions import view as View from AccessControl.Permissions import view as View
from AccessControl.Permissions import ftp_access from AccessControl.Permissions import ftp_access
from AccessControl.Permissions import delete_objects from AccessControl.Permissions import delete_objects
from AccessControl.Role import RoleManager
from AccessControl.SecurityInfo import ClassSecurityInfo
from Acquisition import Implicit
from App.class_init import InitializeClass
from App.special_dtml import DTMLFile
from DateTime.DateTime import DateTime
from Persistence import Persistent
from webdav.common import rfc1123_date from webdav.common import rfc1123_date
from webdav.interfaces import IWriteLock from webdav.interfaces import IWriteLock
from webdav.Lockable import ResourceLockedError from webdav.Lockable import ResourceLockedError
from SimpleItem import Item_w__name__
from cStringIO import StringIO
from Globals import Persistent
from Acquisition import Implicit
from DateTime import DateTime
from Cache import Cacheable
from mimetools import choose_boundary
from ZPublisher import HTTPRangeSupport from ZPublisher import HTTPRangeSupport
from ZPublisher.HTTPRequest import FileUpload from ZPublisher.HTTPRequest import FileUpload
from ZPublisher.Iterators import filestream_iterator from ZPublisher.Iterators import filestream_iterator
from zExceptions import Redirect from zExceptions import Redirect
from cgi import escape from zope.contenttype import guess_content_type
import transaction from zope.interface import implementedBy
from zope.interface import implements
manage_addFileForm=DTMLFile('dtml/imageAdd', globals(),Kind='File',kind='file') from OFS.Cache import Cacheable
def manage_addFile(self,id,file='',title='',precondition='', content_type='', from OFS.PropertyManager import PropertyManager
REQUEST=None): from OFS.SimpleItem import Item_w__name__
manage_addFileForm = DTMLFile('dtml/imageAdd',
globals(),
Kind='File',
kind='file',
)
def manage_addFile(self, id, file='', title='', precondition='',
content_type='', REQUEST=None):
"""Add a new File object. """Add a new File object.
Creates a new File object 'id' with the contents of 'file'""" Creates a new File object 'id' with the contents of 'file'"""
id=str(id) id = str(id)
title=str(title) title = str(title)
content_type=str(content_type) content_type = str(content_type)
precondition=str(precondition) precondition = str(precondition)
id, title = cookId(id, title, file) id, title = cookId(id, title, file)
...@@ -498,6 +503,7 @@ class File(Persistent, Implicit, PropertyManager, ...@@ -498,6 +503,7 @@ class File(Persistent, Implicit, PropertyManager,
return content_type return content_type
def _read_data(self, file): def _read_data(self, file):
import transaction
n=1 << 16 n=1 << 16
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
$Id$ $Id$
""" """
import Globals
class Moniker: class Moniker:
"""An object moniker is an intelligent reference to a """An object moniker is an intelligent reference to a
......
...@@ -15,16 +15,16 @@ ...@@ -15,16 +15,16 @@
$Id$ $Id$
""" """
import warnings
import marshal
import sys, fnmatch, copy, os, re
from cgi import escape from cgi import escape
from cStringIO import StringIO from cStringIO import StringIO
from types import StringType, UnicodeType import copy
import fnmatch
import marshal
import os
import re
import sys
import warnings
import App.Common
import App.FactoryDispatcher, Products
import App.Management, Acquisition
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import view_management_screens from AccessControl.Permissions import view_management_screens
from AccessControl.Permissions import access_contents_information from AccessControl.Permissions import access_contents_information
...@@ -34,40 +34,50 @@ from AccessControl.Permissions import import_export_objects ...@@ -34,40 +34,50 @@ from AccessControl.Permissions import import_export_objects
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from AccessControl.ZopeSecurityPolicy import getRoles from AccessControl.ZopeSecurityPolicy import getRoles
from Acquisition import aq_base from Acquisition import aq_base
from Acquisition import Implicit
from App.class_init import InitializeClass
from App.Common import is_acquired
from App.config import getConfiguration from App.config import getConfiguration
from Globals import InitializeClass from App.Dialogs import MessageDialog
from Globals import DTMLFile, Persistent from App.FactoryDispatcher import ProductDispatcher
from Globals import MessageDialog from App.Management import Navigation
from Globals import REPLACEABLE, NOT_REPLACEABLE, UNIQUE from App.Management import Tabs
from App.special_dtml import DTMLFile
from Persistence import Persistent
from webdav.Collection import Collection from webdav.Collection import Collection
from webdav.Lockable import ResourceLockedError from webdav.Lockable import ResourceLockedError
from webdav.NullResource import NullResource from webdav.NullResource import NullResource
from zExceptions import BadRequest from zExceptions import BadRequest
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from zope.interface import implements from zope.interface import implements
from zope.component.interfaces import ComponentLookupError from zope.component.interfaces import ComponentLookupError
import CopySupport
from interfaces import IObjectManager
from Traversable import Traversable
from zope.event import notify from zope.event import notify
from zope.app.container.contained import ObjectAddedEvent from zope.app.container.contained import ObjectAddedEvent
from zope.app.container.contained import ObjectRemovedEvent from zope.app.container.contained import ObjectRemovedEvent
from zope.app.container.contained import notifyContainerModified from zope.app.container.contained import notifyContainerModified
from zope.app.container.interfaces import IContainer from zope.app.container.interfaces import IContainer
from zope.interface import implements from zope.interface import implements
from OFS.CopySupport import CopyContainer
from OFS.interfaces import IObjectManager
from OFS.Traversable import Traversable
from OFS.event import ObjectWillBeAddedEvent from OFS.event import ObjectWillBeAddedEvent
from OFS.event import ObjectWillBeRemovedEvent from OFS.event import ObjectWillBeRemovedEvent
import OFS.subscribers from OFS.subscribers import compatibilityCall
from OFS.XMLExportImport import importXML
from OFS.XMLExportImport import exportXML
from OFS.XMLExportImport import magic
# Constants: __replaceable__ flags:
NOT_REPLACEABLE = 0
REPLACEABLE = 1
UNIQUE = 2
# the name BadRequestException is relied upon by 3rd-party code # the name BadRequestException is relied upon by 3rd-party code
BadRequestException = BadRequest BadRequestException = BadRequest
import XMLExportImport customImporters={magic: importXML,
customImporters={ }
XMLExportImport.magic: XMLExportImport.importXML,
}
bad_id=re.compile(r'[^a-zA-Z0-9-_~,.$\(\)# @]').search bad_id=re.compile(r'[^a-zA-Z0-9-_~,.$\(\)# @]').search
...@@ -77,9 +87,11 @@ def checkValidId(self, id, allow_dup=0): ...@@ -77,9 +87,11 @@ def checkValidId(self, id, allow_dup=0):
# only check that the id string contains no illegal chars; # only check that the id string contains no illegal chars;
# check_valid_id() will be called again later with allow_dup # check_valid_id() will be called again later with allow_dup
# set to false before the object is added. # set to false before the object is added.
import Globals # for data
if not id or not isinstance(id, StringType): if not id or not isinstance(id, str):
if isinstance(id, UnicodeType): id = escape(id) if isinstance(id, unicode):
id = escape(id)
raise BadRequest, ('Empty or invalid id specified', id) raise BadRequest, ('Empty or invalid id specified', id)
if bad_id(id) is not None: if bad_id(id) is not None:
raise BadRequest, ( raise BadRequest, (
...@@ -127,15 +139,14 @@ class BreakoutException(Exception): ...@@ -127,15 +139,14 @@ class BreakoutException(Exception):
_marker=[] _marker=[]
class ObjectManager( class ObjectManager(CopyContainer,
CopySupport.CopyContainer, Navigation,
App.Management.Navigation, Tabs,
App.Management.Tabs, Implicit,
Acquisition.Implicit, Persistent,
Persistent, Collection,
Collection, Traversable,
Traversable, ):
):
"""Generic object manager """Generic object manager
...@@ -204,6 +215,7 @@ class ObjectManager( ...@@ -204,6 +215,7 @@ class ObjectManager(
def all_meta_types(self, interfaces=None): def all_meta_types(self, interfaces=None):
# A list of products registered elsewhere # A list of products registered elsewhere
import Products
external_candidates = [] external_candidates = []
# Look at _product_meta_types, if there is one # Look at _product_meta_types, if there is one
...@@ -255,6 +267,7 @@ class ObjectManager( ...@@ -255,6 +267,7 @@ class ObjectManager(
return meta_types return meta_types
def _subobject_permissions(self): def _subobject_permissions(self):
import Products
Products_permissions = getattr(Products, '__ac_permissions__', ()) Products_permissions = getattr(Products, '__ac_permissions__', ())
return (Products_permissions + return (Products_permissions +
self.aq_acquire('_getProductRegistryData')('ac_permissions') self.aq_acquire('_getProductRegistryData')('ac_permissions')
...@@ -353,7 +366,7 @@ class ObjectManager( ...@@ -353,7 +366,7 @@ class ObjectManager(
notify(ObjectAddedEvent(ob, self, id)) notify(ObjectAddedEvent(ob, self, id))
notifyContainerModified(self) notifyContainerModified(self)
OFS.subscribers.compatibilityCall('manage_afterAdd', ob, ob, self) compatibilityCall('manage_afterAdd', ob, ob, self)
return id return id
...@@ -379,7 +392,7 @@ class ObjectManager( ...@@ -379,7 +392,7 @@ class ObjectManager(
""" """
ob = self._getOb(id) ob = self._getOb(id)
OFS.subscribers.compatibilityCall('manage_beforeDelete', ob, ob, self) compatibilityCall('manage_beforeDelete', ob, ob, self)
if not suppress_events: if not suppress_events:
notify(ObjectWillBeRemovedEvent(ob, self, id)) notify(ObjectWillBeRemovedEvent(ob, self, id))
...@@ -497,7 +510,7 @@ class ObjectManager( ...@@ -497,7 +510,7 @@ class ObjectManager(
return vals return vals
manage_addProduct=App.FactoryDispatcher.ProductDispatcher() manage_addProduct = ProductDispatcher()
security.declareProtected(delete_objects, 'manage_delObjects') security.declareProtected(delete_objects, 'manage_delObjects')
def manage_delObjects(self, ids=[], REQUEST=None): def manage_delObjects(self, ids=[], REQUEST=None):
...@@ -571,8 +584,10 @@ class ObjectManager( ...@@ -571,8 +584,10 @@ class ObjectManager(
if download: if download:
f=StringIO() f=StringIO()
if toxml: XMLExportImport.exportXML(ob._p_jar, ob._p_oid, f) if toxml:
else: ob._p_jar.exportFile(ob._p_oid, f) exportXML(ob._p_jar, ob._p_oid, f)
else:
ob._p_jar.exportFile(ob._p_oid, f)
if RESPONSE is not None: if RESPONSE is not None:
RESPONSE.setHeader('Content-type','application/data') RESPONSE.setHeader('Content-type','application/data')
RESPONSE.setHeader('Content-Disposition', RESPONSE.setHeader('Content-Disposition',
...@@ -582,7 +597,7 @@ class ObjectManager( ...@@ -582,7 +597,7 @@ class ObjectManager(
cfg = getConfiguration() cfg = getConfiguration()
f = os.path.join(cfg.clienthome, '%s.%s' % (id, suffix)) f = os.path.join(cfg.clienthome, '%s.%s' % (id, suffix))
if toxml: if toxml:
XMLExportImport.exportXML(ob._p_jar, ob._p_oid, f) exportXML(ob._p_jar, ob._p_oid, f)
else: else:
ob._p_jar.exportFile(ob._p_oid, f) ob._p_jar.exportFile(ob._p_oid, f)
...@@ -667,7 +682,7 @@ class ObjectManager( ...@@ -667,7 +682,7 @@ class ObjectManager(
# check to see if we are being acquiring or not # check to see if we are being acquiring or not
ob=self ob=self
while 1: while 1:
if App.Common.is_acquired(ob): if is_acquired(ob):
raise ValueError('FTP List not supported on acquired objects') raise ValueError('FTP List not supported on acquired objects')
if not hasattr(ob,'aq_parent'): if not hasattr(ob,'aq_parent'):
break break
......
...@@ -15,19 +15,19 @@ ...@@ -15,19 +15,19 @@
$Id$ $Id$
""" """
from types import StringType
import warnings import warnings
from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import access_contents_information from AccessControl.Permissions import access_contents_information
from AccessControl.Permissions import manage_properties from AccessControl.Permissions import manage_properties
from AccessControl.SecurityInfo import ClassSecurityInfo
from Acquisition import aq_base from Acquisition import aq_base
from App.class_init import InitializeClass
from DocumentTemplate.sequence import sort from DocumentTemplate.sequence import sort
from Globals import InitializeClass
from zope.interface import implements from zope.interface import implements
from zope.app.container.contained import notifyContainerModified from zope.app.container.contained import notifyContainerModified
from interfaces import IOrderedContainer as IOrderedContainer from OFS.interfaces import IOrderedContainer as IOrderedContainer
from ObjectManager import ObjectManager from OFS.ObjectManager import ObjectManager
class OrderSupport(object): class OrderSupport(object):
...@@ -138,7 +138,7 @@ class OrderSupport(object): ...@@ -138,7 +138,7 @@ class OrderSupport(object):
suppress_events=False): suppress_events=False):
""" Move specified sub-objects by delta. """ Move specified sub-objects by delta.
""" """
if type(ids) is StringType: if type(ids) is str:
ids = (ids,) ids = (ids,)
min_position = 0 min_position = 0
objects = list(self._objects) objects = list(self._objects)
......
...@@ -15,16 +15,16 @@ ...@@ -15,16 +15,16 @@
$Id$ $Id$
""" """
from AccessControl import getSecurityManager from AccessControl.SecurityManagement import getSecurityManager
from AccessControl import Unauthorized from AccessControl.unauthorized import Unauthorized
from AccessControl.Permissions import add_page_templates from AccessControl.Permissions import add_page_templates
from AccessControl.Permissions import add_user_folders from AccessControl.Permissions import add_user_folders
from Globals import DTMLFile from App.special_dtml import DTMLFile
from zope.interface import implements from zope.interface import implements
from Folder import Folder from OFS.Folder import Folder
from interfaces import IOrderedFolder from OFS.interfaces import IOrderedFolder
from OrderSupport import OrderSupport from OFS.OrderSupport import OrderSupport
manage_addOrderedFolderForm = DTMLFile('dtml/addOrderedFolder', globals()) manage_addOrderedFolderForm = DTMLFile('dtml/addOrderedFolder', globals())
......
...@@ -16,26 +16,26 @@ $Id$ ...@@ -16,26 +16,26 @@ $Id$
""" """
from cgi import escape from cgi import escape
from types import ListType
import ExtensionClass
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import access_contents_information from AccessControl.Permissions import access_contents_information
from AccessControl.Permissions import manage_properties from AccessControl.Permissions import manage_properties
from AccessControl.SecurityInfo import ClassSecurityInfo
from Acquisition import aq_base from Acquisition import aq_base
from Globals import DTMLFile, MessageDialog from App.class_init import InitializeClass
from Globals import Persistent from ExtensionClass import Base
from App.special_dtml import DTMLFile
from App.Dialogs import MessageDialog
from Persistence import Persistent
from zExceptions import BadRequest from zExceptions import BadRequest
from zope.interface import implements from zope.interface import implements
from ZPublisher.Converters import type_converters from ZPublisher.Converters import type_converters
import ZDOM from OFS.interfaces import IPropertyManager
from interfaces import IPropertyManager from OFS.PropertySheets import DefaultPropertySheets
from PropertySheets import DefaultPropertySheets, vps from OFS.PropertySheets import vps
from OFS.ZDOM import ElementWithAttributes
class PropertyManager(Base, ElementWithAttributes):
class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
""" """
The PropertyManager mixin class provides an object with The PropertyManager mixin class provides an object with
...@@ -170,7 +170,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes): ...@@ -170,7 +170,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
def _setPropValue(self, id, value): def _setPropValue(self, id, value):
self._wrapperCheck(value) self._wrapperCheck(value)
if type(value) == ListType: if type(value) == list:
value = tuple(value) value = tuple(value)
setattr(self,id,value) setattr(self,id,value)
......
...@@ -14,34 +14,36 @@ ...@@ -14,34 +14,36 @@
$Id$ $Id$
""" """
import time, App.Management, Globals, sys from cgi import escape
from webdav.interfaces import IWriteLock import time
from ZPublisher.Converters import type_converters import sys
from Globals import InitializeClass
from Globals import DTMLFile, MessageDialog from AccessControl.Permissions import access_contents_information
from AccessControl.Permissions import manage_properties
from AccessControl.Permissions import view_management_screens
from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.SecurityManagement import getSecurityManager
from Acquisition import aq_base from Acquisition import aq_base
from Acquisition import aq_parent from Acquisition import aq_parent
from Acquisition import Implicit, Explicit from Acquisition import Implicit, Explicit
from App.Common import rfc1123_date, iso8601_date from App.class_init import InitializeClass
from webdav.common import urlbase from App.Common import iso8601_date
from App.Common import rfc1123_date
from App.Dialogs import MessageDialog
from App.Management import Tabs
from App.special_dtml import DTMLFile
from ExtensionClass import Base from ExtensionClass import Base
from Globals import Persistent from Persistence import Persistent
from Traversable import Traversable from Traversable import Traversable
from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import access_contents_information
from AccessControl.Permissions import manage_properties
from AccessControl.Permissions import view_management_screens
from AccessControl import getSecurityManager
from webdav.common import isDavCollection from webdav.common import isDavCollection
from zExceptions import BadRequest, Redirect from webdav.common import urlbase
from cgi import escape from webdav.interfaces import IWriteLock
from types import ListType from zExceptions import BadRequest
from zExceptions import Redirect
# DM: we would like to import this from somewhere from ZPublisher.Converters import type_converters
BadRequestException= 'Bad Request'
class View(App.Management.Tabs, Base): class View(Tabs, Base):
"""A view of an object, typically used for management purposes """A view of an object, typically used for management purposes
This class provides bits of management framework needed by propertysheets This class provides bits of management framework needed by propertysheets
...@@ -215,7 +217,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -215,7 +217,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
else: value=[] else: value=[]
# bleah - can't change kw name in api, so use ugly workaround. # bleah - can't change kw name in api, so use ugly workaround.
if sys.modules['__builtin__'].type(value) == ListType: if sys.modules['__builtin__'].type(value) == list:
value = tuple(value) value = tuple(value)
setattr(self, id, value) setattr(self, id, value)
...@@ -242,7 +244,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -242,7 +244,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
props.append(prop) props.append(prop)
pself._properties=tuple(props) pself._properties=tuple(props)
if type(value) == ListType: if type(value) == list:
value = tuple(value) value = tuple(value)
setattr(self.v_self(), id, value) setattr(self.v_self(), id, value)
...@@ -409,7 +411,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -409,7 +411,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
# Web interface # Web interface
manage=DTMLFile('dtml/properties', globals()) manage = DTMLFile('dtml/properties', globals())
security.declareProtected(manage_properties, 'manage_propertiesForm') security.declareProtected(manage_properties, 'manage_propertiesForm')
def manage_propertiesForm(self, URL1): def manage_propertiesForm(self, URL1):
...@@ -614,7 +616,7 @@ class DAVProperties(Virtual, PropertySheet, View): ...@@ -614,7 +616,7 @@ class DAVProperties(Virtual, PropertySheet, View):
InitializeClass(DAVProperties) InitializeClass(DAVProperties)
class PropertySheets(Traversable, Implicit, App.Management.Tabs): class PropertySheets(Traversable, Implicit, Tabs):
"""A tricky container to keep property sets from polluting """A tricky container to keep property sets from polluting
an object's direct attribute namespace.""" an object's direct attribute namespace."""
...@@ -708,7 +710,8 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -708,7 +710,8 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
'''delete all sheets identified by *ids*.''' '''delete all sheets identified by *ids*.'''
for id in ids: for id in ids:
if not self.isDeletable(id): if not self.isDeletable(id):
raise BadRequestException, 'attempt to delete undeletable property sheet: ' + id raise BadRequest(
'attempt to delete undeletable property sheet: ' + id)
self.delPropertySheet(id) self.delPropertySheet(id)
if REQUEST is not None: if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage' % self.absolute_url()) REQUEST.RESPONSE.redirect('%s/manage' % self.absolute_url())
...@@ -723,7 +726,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -723,7 +726,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
# Management interface: # Management interface:
security.declareProtected(view_management_screens, 'manage') security.declareProtected(view_management_screens, 'manage')
manage=Globals.DTMLFile('dtml/propertysheets', globals()) manage = DTMLFile('dtml/propertysheets', globals())
def manage_options(self): def manage_options(self):
"""Return a manage option data structure for me instance """Return a manage option data structure for me instance
......
...@@ -21,42 +21,59 @@ $Id$ ...@@ -21,42 +21,59 @@ $Id$
""" """
import inspect import inspect
import marshal
import re
import sys
import time
import warnings import warnings
import marshal, re, sys, time
import AccessControl.Role, AccessControl.Owned, App.Common from AccessControl.SecurityInfo import ClassSecurityInfo
import Globals, App.Management, Acquisition, App.Undo from AccessControl.SecurityManagement import getSecurityManager
from Globals import InitializeClass from AccessControl.Owned import Owned
from AccessControl import ClassSecurityInfo
from AccessControl import getSecurityManager, Unauthorized
from AccessControl.Permissions import view as View from AccessControl.Permissions import view as View
from AccessControl.Role import RoleManager
from AccessControl.unauthorized import Unauthorized
from AccessControl.ZopeSecurityPolicy import getRoles from AccessControl.ZopeSecurityPolicy import getRoles
from Acquisition import aq_base, aq_parent, aq_inner, aq_acquire from Acquisition import Acquired
from Acquisition import aq_acquire
from Acquisition import aq_base
from Acquisition import aq_inner
from Acquisition import aq_parent
from Acquisition import Implicit
from App.Management import Tabs
from App.class_init import InitializeClass
from App.special_dtml import HTML
from App.special_dtml import DTMLFile
from App.Undo import UndoSupport
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
from DocumentTemplate.html_quote import html_quote from DocumentTemplate.html_quote import html_quote
from DocumentTemplate.ustr import ustr from DocumentTemplate.ustr import ustr
from ExtensionClass import Base from ExtensionClass import Base
from Persistence import Persistent
from webdav.Resource import Resource from webdav.Resource import Resource
from zExceptions import Redirect, upgradeException from zExceptions import Redirect
from zExceptions import upgradeException
from zExceptions.ExceptionFormatter import format_exception from zExceptions.ExceptionFormatter import format_exception
from zope.interface import implements from zope.interface import implements
import ZDOM from OFS.interfaces import IItem
from CopySupport import CopySource from OFS.interfaces import IItemWithName
from interfaces import IItem from OFS.interfaces import ISimpleItem
from interfaces import IItemWithName from OFS.CopySupport import CopySource
from interfaces import ISimpleItem from OFS.Traversable import Traversable
from Traversable import Traversable from OFS.ZDOM import Element
HTML=Globals.HTML
import logging import logging
logger = logging.getLogger() logger = logging.getLogger()
class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, class Item(Base,
ZDOM.Element, Resource,
AccessControl.Owned.Owned, CopySource,
App.Undo.UndoSupport, Tabs,
Traversable,
Element,
Owned,
UndoSupport,
): ):
"""A common base class for simple, non-container objects.""" """A common base class for simple, non-container objects."""
...@@ -115,14 +132,14 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -115,14 +132,14 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
__propsets__=() __propsets__=()
manage_options=( manage_options=(
App.Undo.UndoSupport.manage_options UndoSupport.manage_options
+AccessControl.Owned.Owned.manage_options + Owned.manage_options
+({'label': 'Interfaces', + ({'label': 'Interfaces',
'action': 'manage_interfaces'},) 'action': 'manage_interfaces'},)
) )
# Attributes that must be acquired # Attributes that must be acquired
REQUEST=Acquisition.Acquired REQUEST = Acquired
# Allow (reluctantly) access to unprotected attributes # Allow (reluctantly) access to unprotected attributes
__allow_access_to_unprotected_subobjects__=1 __allow_access_to_unprotected_subobjects__=1
...@@ -159,7 +176,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -159,7 +176,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
# My sub-objects as used by the tree tag # My sub-objects as used by the tree tag
return () return ()
_manage_editedDialog=Globals.DTMLFile('dtml/editedDialog', globals()) _manage_editedDialog = DTMLFile('dtml/editedDialog', globals())
def manage_editedDialog(self, REQUEST, **args): def manage_editedDialog(self, REQUEST, **args):
return apply(self._manage_editedDialog,(self, REQUEST), args) return apply(self._manage_editedDialog,(self, REQUEST), args)
...@@ -358,10 +375,11 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -358,10 +375,11 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
In the case of non-Foldoid objects, the listing should contain one In the case of non-Foldoid objects, the listing should contain one
object, the object itself. object, the object itself.
""" """
from App.Common import is_acquired
# check to see if we are being acquiring or not # check to see if we are being acquiring or not
ob=self ob=self
while 1: while 1:
if App.Common.is_acquired(ob): if is_acquired(ob):
raise ValueError('FTP List not supported on acquired objects') raise ValueError('FTP List not supported on acquired objects')
if not hasattr(ob,'aq_parent'): if not hasattr(ob,'aq_parent'):
break break
...@@ -449,9 +467,10 @@ def pretty_tb(t, v, tb, as_html=1): ...@@ -449,9 +467,10 @@ def pretty_tb(t, v, tb, as_html=1):
return tb return tb
class SimpleItem(Item, Globals.Persistent, class SimpleItem(Item,
Acquisition.Implicit, Persistent,
AccessControl.Role.RoleManager, Implicit,
RoleManager,
): ):
# Blue-plate special, Zope Masala # Blue-plate special, Zope Masala
......
...@@ -17,22 +17,27 @@ $Id$ ...@@ -17,22 +17,27 @@ $Id$
from urllib import quote from urllib import quote
from Globals import InitializeClass from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl import ClassSecurityInfo from AccessControl.SecurityManagement import getSecurityManager
from AccessControl import getSecurityManager from AccessControl.unauthorized import Unauthorized
from AccessControl import Unauthorized
from AccessControl.ZopeGuards import guarded_getattr from AccessControl.ZopeGuards import guarded_getattr
from Acquisition import Acquired, aq_inner, aq_parent, aq_acquire, aq_base from Acquisition import Acquired
from Acquisition import aq_acquire
from Acquisition import aq_base
from Acquisition import aq_inner
from Acquisition import aq_parent
from Acquisition.interfaces import IAcquirer from Acquisition.interfaces import IAcquirer
from App.class_init import InitializeClass
from OFS.interfaces import ITraversable
from zExceptions import NotFound from zExceptions import NotFound
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from OFS.interfaces import ITraversable
import webdav
from zope.interface import implements, Interface from zope.interface import implements
from zope.interface import Interface
from zope.component import queryMultiAdapter from zope.component import queryMultiAdapter
from zope.traversing.interfaces import TraversalError from zope.traversing.interfaces import TraversalError
from zope.traversing.namespace import nsParse, namespaceLookup from zope.traversing.namespace import namespaceLookup
from zope.traversing.namespace import nsParse
_marker = object() _marker = object()
...@@ -138,6 +143,7 @@ class Traversable: ...@@ -138,6 +143,7 @@ class Traversable:
If true, then all of the objects along the path are validated with If true, then all of the objects along the path are validated with
the security machinery. Usually invoked using restrictedTraverse(). the security machinery. Usually invoked using restrictedTraverse().
""" """
from webdav.NullResource import NullResource
if not path: if not path:
return self return self
...@@ -245,8 +251,7 @@ class Traversable: ...@@ -245,8 +251,7 @@ class Traversable:
# The item lookup may return a NullResource, # The item lookup may return a NullResource,
# if this is the case we save it and return it # if this is the case we save it and return it
# if all other lookups fail. # if all other lookups fail.
if isinstance(next, if isinstance(next, NullResource):
webdav.NullResource.NullResource):
resource = next resource = next
raise KeyError(name) raise KeyError(name)
except AttributeError: except AttributeError:
......
...@@ -13,20 +13,21 @@ ...@@ -13,20 +13,21 @@
""" """
Objects for packages that have been uninstalled. Objects for packages that have been uninstalled.
""" """
import SimpleItem, Globals, Acquisition
from Acquisition import Acquired
import Persistence
from thread import allocate_lock
from cgi import escape from cgi import escape
from logging import getLogger from logging import getLogger
from thread import allocate_lock
from Acquisition import Acquired
from Acquisition import Explicit
from App.special_dtml import DTMLFile
from OFS.SimpleItem import Item
from Persistence import Overridable
broken_klasses={} broken_klasses={}
broken_klasses_lock = allocate_lock() broken_klasses_lock = allocate_lock()
LOG = getLogger('OFS.Uninstalled') LOG = getLogger('OFS.Uninstalled')
class BrokenClass(Acquisition.Explicit, SimpleItem.Item, class BrokenClass(Explicit, Item, Overridable):
Persistence.Overridable):
_p_changed=0 _p_changed=0
meta_type='Broken Because Product is Gone' meta_type='Broken Because Product is Gone'
icon='p_/broken' icon='p_/broken'
...@@ -47,9 +48,9 @@ class BrokenClass(Acquisition.Explicit, SimpleItem.Item, ...@@ -47,9 +48,9 @@ class BrokenClass(Acquisition.Explicit, SimpleItem.Item,
return BrokenClass.inheritedAttribute('__getattr__')(self, name) return BrokenClass.inheritedAttribute('__getattr__')(self, name)
raise AttributeError, escape(name) raise AttributeError, escape(name)
manage=Globals.DTMLFile('dtml/brokenEdit',globals()) manage = DTMLFile('dtml/brokenEdit',globals())
manage_main=Globals.DTMLFile('dtml/brokenEdit',globals()) manage_main = DTMLFile('dtml/brokenEdit',globals())
manage_workspace=Globals.DTMLFile('dtml/brokenEdit',globals()) manage_workspace = DTMLFile('dtml/brokenEdit',globals())
def Broken(self, oid, pair): def Broken(self, oid, pair):
......
...@@ -15,12 +15,13 @@ DOM implementation in ZOPE : Read-Only methods ...@@ -15,12 +15,13 @@ DOM implementation in ZOPE : Read-Only methods
All standard Zope objects support DOM to a limited extent. All standard Zope objects support DOM to a limited extent.
""" """
import Acquisition from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.Permissions import access_contents_information
from Acquisition import Explicit
from Acquisition import Implicit
from Acquisition import aq_base from Acquisition import aq_base
from Acquisition import aq_parent from Acquisition import aq_parent
from Globals import InitializeClass from App.class_init import InitializeClass
from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import access_contents_information
# Node type codes # Node type codes
...@@ -167,7 +168,7 @@ class Node: ...@@ -167,7 +168,7 @@ class Node:
InitializeClass(Node) InitializeClass(Node)
class Document(Acquisition.Explicit, Node): class Document(Explicit, Node):
""" """
Document Interface Document Interface
""" """
...@@ -534,7 +535,7 @@ class NamedNodeMap: ...@@ -534,7 +535,7 @@ class NamedNodeMap:
return None return None
class Attr(Acquisition.Implicit, Node): class Attr(Implicit, Node):
""" """
Attr interface - The Attr interface represents an attriubte in an Attr interface - The Attr interface represents an attriubte in an
Element object. Attr objects inherit the Node Interface Element object. Attr objects inherit the Node Interface
......
...@@ -11,11 +11,10 @@ ...@@ -11,11 +11,10 @@
# #
############################################################################## ##############################################################################
from Globals import InitializeClass from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl import ClassSecurityInfo from App.class_init import InitializeClass
from App.ImageFile import ImageFile from App.ImageFile import ImageFile
class misc_: class misc_:
"Miscellaneous product information" "Miscellaneous product information"
security = ClassSecurityInfo() security = ClassSecurityInfo()
......
...@@ -16,34 +16,36 @@ ...@@ -16,34 +16,36 @@
$Id: BTreeFolder2.py,v 1.27 2004/03/17 22:49:25 urbanape Exp $ $Id: BTreeFolder2.py,v 1.27 2004/03/17 22:49:25 urbanape Exp $
""" """
import sys
from cgi import escape from cgi import escape
from urllib import quote
from random import randint
from types import StringType
from logging import getLogger from logging import getLogger
from random import randint
import sys
from urllib import quote
import Globals from AccessControl.SecurityInfo import ClassSecurityInfo
from Globals import DTMLFile from AccessControl.SecurityManagement import getSecurityManager
from Globals import Persistent from AccessControl.Permissions import access_contents_information
from AccessControl.Permissions import view_management_screens
from Acquisition import aq_base from Acquisition import aq_base
from BTrees.OOBTree import OOBTree from App.class_init import InitializeClass
from BTrees.OIBTree import OIBTree, union from App.special_dtml import DTMLFile
from BTrees.Length import Length from BTrees.Length import Length
from ZODB.POSException import ConflictError from BTrees.OIBTree import OIBTree
from OFS.ObjectManager import BadRequestException, BeforeDeleteException from BTrees.OIBTree import union
from BTrees.OOBTree import OOBTree
from OFS.event import ObjectWillBeAddedEvent
from OFS.event import ObjectWillBeRemovedEvent
from OFS.Folder import Folder from OFS.Folder import Folder
from AccessControl import getSecurityManager, ClassSecurityInfo from OFS.ObjectManager import BadRequestException
from AccessControl.Permissions import access_contents_information, \ from OFS.ObjectManager import BeforeDeleteException
view_management_screens from OFS.subscribers import compatibilityCall
from Persistence import Persistent
from Products.ZCatalog.Lazy import LazyMap from Products.ZCatalog.Lazy import LazyMap
from ZODB.POSException import ConflictError
from zope.event import notify from zope.event import notify
from zope.app.container.contained import ObjectAddedEvent from zope.app.container.contained import ObjectAddedEvent
from zope.app.container.contained import ObjectRemovedEvent from zope.app.container.contained import ObjectRemovedEvent
from zope.app.container.contained import notifyContainerModified from zope.app.container.contained import notifyContainerModified
from OFS.event import ObjectWillBeAddedEvent
from OFS.event import ObjectWillBeRemovedEvent
import OFS.subscribers
LOG = getLogger('BTreeFolder2') LOG = getLogger('BTreeFolder2')
...@@ -346,7 +348,7 @@ class BTreeFolder2Base (Persistent): ...@@ -346,7 +348,7 @@ class BTreeFolder2Base (Persistent):
if spec is None: if spec is None:
spec = mti.keys() #all meta types spec = mti.keys() #all meta types
if isinstance(spec, StringType): if isinstance(spec, str):
spec = [spec] spec = [spec]
set = None set = None
for meta_type in spec: for meta_type in spec:
...@@ -448,7 +450,7 @@ class BTreeFolder2Base (Persistent): ...@@ -448,7 +450,7 @@ class BTreeFolder2Base (Persistent):
notify(ObjectAddedEvent(ob, self, id)) notify(ObjectAddedEvent(ob, self, id))
notifyContainerModified(self) notifyContainerModified(self)
OFS.subscribers.compatibilityCall('manage_afterAdd', ob, ob, self) compatibilityCall('manage_afterAdd', ob, ob, self)
return id return id
...@@ -456,7 +458,7 @@ class BTreeFolder2Base (Persistent): ...@@ -456,7 +458,7 @@ class BTreeFolder2Base (Persistent):
def _delObject(self, id, dp=1, suppress_events=False): def _delObject(self, id, dp=1, suppress_events=False):
ob = self._getOb(id) ob = self._getOb(id)
OFS.subscribers.compatibilityCall('manage_beforeDelete', ob, ob, self) compatibilityCall('manage_beforeDelete', ob, ob, self)
if not suppress_events: if not suppress_events:
notify(ObjectWillBeRemovedEvent(ob, self, id)) notify(ObjectWillBeRemovedEvent(ob, self, id))
...@@ -519,7 +521,7 @@ class BTreeFolder2Base (Persistent): ...@@ -519,7 +521,7 @@ class BTreeFolder2Base (Persistent):
return res return res
Globals.InitializeClass(BTreeFolder2Base) InitializeClass(BTreeFolder2Base)
class BTreeFolder2 (BTreeFolder2Base, Folder): class BTreeFolder2 (BTreeFolder2Base, Folder):
...@@ -532,5 +534,5 @@ class BTreeFolder2 (BTreeFolder2Base, Folder): ...@@ -532,5 +534,5 @@ class BTreeFolder2 (BTreeFolder2Base, Folder):
BTreeFolder2Base._checkId(self, id, allow_dup) BTreeFolder2Base._checkId(self, id, allow_dup)
Globals.InitializeClass(BTreeFolder2) InitializeClass(BTreeFolder2)
...@@ -10,24 +10,35 @@ ...@@ -10,24 +10,35 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""External Method Product """External Method Product
This product provides support for external methods, which allow This product provides support for external methods, which allow
domain-specific customization of web environments. domain-specific customization of web environments.
""" """
__version__='$Revision: 1.52 $'[11:-2] __version__='$Revision: 1.52 $'[11:-2]
from Globals import Persistent, DTMLFile, MessageDialog, HTML
import OFS.SimpleItem, Acquisition import os
from Globals import InitializeClass import stat
from AccessControl import ClassSecurityInfo import sys
import traceback
from AccessControl.Permissions import change_external_methods from AccessControl.Permissions import change_external_methods
from AccessControl.Permissions import view_management_screens from AccessControl.Permissions import view_management_screens
from AccessControl.Permissions import view as View from AccessControl.Permissions import view as View
import AccessControl.Role, sys, os, stat, traceback from AccessControl.Role import RoleManager
from AccessControl.SecurityInfo import ClassSecurityInfo
from Acquisition import Acquired
from Acquisition import Explicit
from App.class_init import InitializeClass
from App.Dialogs import MessageDialog
from App.Extensions import getObject
from App.Extensions import getPath
from App.Extensions import FuncCode
from App.special_dtml import DTMLFile
from App.special_dtml import HTML
from OFS.SimpleItem import Item
from OFS.SimpleItem import pretty_tb from OFS.SimpleItem import pretty_tb
from App.Extensions import getObject, getPath, FuncCode from Persistence import Persistent
from Globals import DevelopmentMode
from App.Management import Navigation from App.Management import Navigation
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
...@@ -66,8 +77,8 @@ def manage_addExternalMethod(self, id, title, module, function, REQUEST=None): ...@@ -66,8 +77,8 @@ def manage_addExternalMethod(self, id, title, module, function, REQUEST=None):
if REQUEST is not None: if REQUEST is not None:
return self.manage_main(self,REQUEST) return self.manage_main(self,REQUEST)
class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit, class ExternalMethod(Item, Persistent, Explicit,
AccessControl.Role.RoleManager, Navigation): RoleManager, Navigation):
"""Web-callable functions that encapsulate external python functions. """Web-callable functions that encapsulate external python functions.
The function is defined in an external file. This file is treated The function is defined in an external file. This file is treated
...@@ -93,9 +104,9 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit, ...@@ -93,9 +104,9 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
func_code = ComputedAttribute(lambda self: self.getFuncCode()) func_code = ComputedAttribute(lambda self: self.getFuncCode())
ZopeTime=Acquisition.Acquired ZopeTime = Acquired
HelpSys=Acquisition.Acquired HelpSys = Acquired
manage_page_header=Acquisition.Acquired manage_page_header = Acquired
manage_options=( manage_options=(
( (
...@@ -104,8 +115,8 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit, ...@@ -104,8 +115,8 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
{'label':'Test', 'action':'', {'label':'Test', 'action':'',
'help':('ExternalMethod','External-Method_Try-It.stx')}, 'help':('ExternalMethod','External-Method_Try-It.stx')},
) )
+OFS.SimpleItem.Item.manage_options + Item.manage_options
+AccessControl.Role.RoleManager.manage_options + RoleManager.manage_options
) )
def __init__(self, id, title, module, function): def __init__(self, id, title, module, function):
...@@ -162,30 +173,21 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit, ...@@ -162,30 +173,21 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
self._v_f=self.getFunction(1) self._v_f=self.getFunction(1)
self._v_last_read=ts self._v_last_read=ts
if DevelopmentMode: def getFuncDefaults(self):
# In development mode we do an automatic reload import Globals # for data
# if the module code changed if Globals.DevelopmentMode:
def getFuncDefaults(self):
self.reloadIfChanged() self.reloadIfChanged()
if not hasattr(self, '_v_func_defaults'): if not hasattr(self, '_v_func_defaults'):
self._v_f = self.getFunction() self._v_f = self.getFunction()
return self._v_func_defaults return self._v_func_defaults
def getFuncCode(self): def getFuncCode(self):
import Globals # for data
if Globals.DevelopmentMode:
self.reloadIfChanged() self.reloadIfChanged()
if not hasattr(self, '_v_func_code'): if not hasattr(self, '_v_func_code'):
self._v_f = self.getFunction() self._v_f = self.getFunction()
return self._v_func_code return self._v_func_code
else:
def getFuncDefaults(self):
if not hasattr(self, '_v_func_defaults'):
self._v_f = self.getFunction()
return self._v_func_defaults
def getFuncCode(self):
if not hasattr(self, '_v_func_code'):
self._v_f = self.getFunction()
return self._v_func_code
security.declareProtected(View, '__call__') security.declareProtected(View, '__call__')
def __call__(self, *args, **kw): def __call__(self, *args, **kw):
...@@ -206,6 +208,7 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit, ...@@ -206,6 +208,7 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
In this case, the URL parent of the object is supplied as the In this case, the URL parent of the object is supplied as the
first argument. first argument.
""" """
import Globals # for data
filePath = self.filepath() filePath = self.filepath()
if filePath==None: if filePath==None:
...@@ -218,7 +221,7 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit, ...@@ -218,7 +221,7 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
"external method could not be called " \ "external method could not be called " \
"because the file does not exist" "because the file does not exist"
if DevelopmentMode: if Globals.DevelopmentMode:
self.reloadIfChanged() self.reloadIfChanged()
if hasattr(self, '_v_f'): if hasattr(self, '_v_f'):
......
...@@ -26,13 +26,14 @@ from zope.interface import Interface ...@@ -26,13 +26,14 @@ from zope.interface import Interface
from zope.component.zcml import handler from zope.component.zcml import handler
from zope.component.interface import provideInterface from zope.component.interface import provideInterface
from zope.configuration.exceptions import ConfigurationError from zope.configuration.exceptions import ConfigurationError
from zope.publisher.interfaces.browser import IBrowserRequest, \ from zope.publisher.interfaces.browser import IBrowserRequest
IDefaultBrowserLayer from zope.publisher.interfaces.browser import IDefaultBrowserLayer
import zope.app.publisher.browser.viewmeta import zope.app.publisher.browser.viewmeta
import zope.app.pagetemplate.simpleviewclass import zope.app.pagetemplate.simpleviewclass
from zope.app.publisher.browser.viewmeta import (providesCallable, from zope.app.publisher.browser.viewmeta import providesCallable
_handle_menu, _handle_for) from zope.app.publisher.browser.viewmeta import _handle_menu
from zope.app.publisher.browser.viewmeta import _handle_for
from Products.Five.browser import BrowserView from Products.Five.browser import BrowserView
from Products.Five.browser.resource import FileResourceFactory from Products.Five.browser.resource import FileResourceFactory
...@@ -41,10 +42,12 @@ from Products.Five.browser.resource import PageTemplateResourceFactory ...@@ -41,10 +42,12 @@ from Products.Five.browser.resource import PageTemplateResourceFactory
from Products.Five.browser.resource import DirectoryResourceFactory from Products.Five.browser.resource import DirectoryResourceFactory
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.Five.metaclass import makeClass from Products.Five.metaclass import makeClass
from Products.Five.security import getSecurityInfo, protectClass, protectName from Products.Five.security import getSecurityInfo
from Products.Five.security import protectClass
from Products.Five.security import protectName
from Products.Five.security import CheckerPrivateId from Products.Five.security import CheckerPrivateId
from Globals import InitializeClass as initializeClass from App.class_init import InitializeClass
def page(_context, name, permission, for_, def page(_context, name, permission, for_,
layer=IDefaultBrowserLayer, template=None, class_=None, layer=IDefaultBrowserLayer, template=None, class_=None,
...@@ -155,7 +158,7 @@ def page(_context, name, permission, for_, ...@@ -155,7 +158,7 @@ def page(_context, name, permission, for_,
# Protect the class # Protect the class
_context.action( _context.action(
discriminator = ('five:initialize:class', new_class), discriminator = ('five:initialize:class', new_class),
callable = initializeClass, callable = InitializeClass,
args = (new_class,) args = (new_class,)
) )
...@@ -317,7 +320,7 @@ def resource(_context, name, layer=IDefaultBrowserLayer, permission='zope.Public ...@@ -317,7 +320,7 @@ def resource(_context, name, layer=IDefaultBrowserLayer, permission='zope.Public
) )
_context.action( _context.action(
discriminator = ('five:initialize:class', new_class), discriminator = ('five:initialize:class', new_class),
callable = initializeClass, callable = InitializeClass,
args = (new_class,) args = (new_class,)
) )
...@@ -385,7 +388,7 @@ def resourceDirectory(_context, name, directory, layer=IDefaultBrowserLayer, ...@@ -385,7 +388,7 @@ def resourceDirectory(_context, name, directory, layer=IDefaultBrowserLayer,
) )
_context.action( _context.action(
discriminator = ('five:initialize:class', new_class), discriminator = ('five:initialize:class', new_class),
callable = initializeClass, callable = InitializeClass,
args = (new_class,) args = (new_class,)
) )
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
$Id$ $Id$
""" """
import ExtensionClass from App.class_init import InitializeClass
from Globals import InitializeClass as initializeClass from ExtensionClass import Base
import zope.component import zope.component
from zope.interface import Interface from zope.interface import Interface
...@@ -60,14 +60,14 @@ def EditViewFactory(name, schema, label, permission, layer, ...@@ -60,14 +60,14 @@ def EditViewFactory(name, schema, label, permission, layer,
# BaseFormDirective, that means that zope.Public has been # BaseFormDirective, that means that zope.Public has been
# translated to the CheckerPublic object # translated to the CheckerPublic object
protectClass(class_, permission) protectClass(class_, permission)
initializeClass(class_) InitializeClass(class_)
class FiveFormDirective(BaseFormDirective): class FiveFormDirective(BaseFormDirective):
def _processWidgets(self): def _processWidgets(self):
if self._widgets: if self._widgets:
customWidgetsObject = makeClass( customWidgetsObject = makeClass(
'CustomWidgetsMixin', (ExtensionClass.Base,), self._widgets) 'CustomWidgetsMixin', (Base,), self._widgets)
self.bases = self.bases + (customWidgetsObject,) self.bases = self.bases + (customWidgetsObject,)
class EditFormDirective(FiveFormDirective): class EditFormDirective(FiveFormDirective):
...@@ -123,7 +123,7 @@ def AddViewFactory(name, schema, label, permission, layer, ...@@ -123,7 +123,7 @@ def AddViewFactory(name, schema, label, permission, layer,
# BaseFormDirective, that means that zope.Public has been # BaseFormDirective, that means that zope.Public has been
# translated to the CheckerPublic object # translated to the CheckerPublic object
protectClass(class_, permission) protectClass(class_, permission)
initializeClass(class_) InitializeClass(class_)
class AddFormDirective(FiveFormDirective): class AddFormDirective(FiveFormDirective):
......
...@@ -20,20 +20,21 @@ the widget's sub-editform. ...@@ -20,20 +20,21 @@ the widget's sub-editform.
$Id$ $Id$
""" """
import zope.app.form.browser.objectwidget from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl import ClassSecurityInfo from App.class_init import InitializeClass
from Globals import InitializeClass as initializeClass
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from zope.app.form.browser.objectwidget import ObjectWidget as OWBase
from zope.app.form.browser.objectwidget import ObjectWidgetView as OWVBase
class ObjectWidgetView(zope.app.form.browser.objectwidget.ObjectWidgetView): class ObjectWidgetView(OWVBase):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectPublic() security.declareObjectPublic()
template = ViewPageTemplateFile('objectwidget.pt') template = ViewPageTemplateFile('objectwidget.pt')
initializeClass(ObjectWidgetView) InitializeClass(ObjectWidgetView)
class ObjectWidgetClass(zope.app.form.browser.objectwidget.ObjectWidget): class ObjectWidgetClass(OWBase):
def setRenderedValue(self, value): def setRenderedValue(self, value):
"""Slightly more robust re-implementation this method.""" """Slightly more robust re-implementation this method."""
......
...@@ -15,14 +15,14 @@ ...@@ -15,14 +15,14 @@
$Id$ $Id$
""" """
from App.class_init import InitializeClass
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from Globals import InitializeClass from Products.Five.form.objectwidget import ObjectWidget
from zope.i18nmessageid import MessageFactory from zope.i18nmessageid import MessageFactory
from zope.interface import implements, Interface from zope.interface import implements, Interface
from zope.schema import TextLine, Text, Object, Int, List from zope.schema import TextLine, Text, Object, Int, List
from zope.app.form import CustomWidgetFactory from zope.app.form import CustomWidgetFactory
from Products.Five.form.objectwidget import ObjectWidget
_ = MessageFactory('formtest') _ = MessageFactory('formtest')
......
...@@ -15,12 +15,15 @@ ...@@ -15,12 +15,15 @@
$Id$ $Id$
""" """
from App.class_init import InitializeClass
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from Globals import InitializeClass
from zope.interface import implements, Interface
from zope.schema import ASCIILine, TextLine, List
from zope.i18nmessageid import MessageFactory from zope.i18nmessageid import MessageFactory
from zope.interface import implements
from zope.interface import Interface
from zope.schema import ASCIILine
from zope.schema import List
from zope.schema import TextLine
_ = MessageFactory('formtest') _ = MessageFactory('formtest')
......
...@@ -18,7 +18,8 @@ $Id$ ...@@ -18,7 +18,8 @@ $Id$
import warnings import warnings
from zope.configuration.exceptions import ConfigurationError from zope.configuration.exceptions import ConfigurationError
from zope.app.component import contentdirective from zope.app.component import contentdirective
from Products.Five.security import protectName, initializeClass from App.class_init import InitializeClass
from Products.Five.security import protectName
class ClassDirective(contentdirective.ClassDirective): class ClassDirective(contentdirective.ClassDirective):
...@@ -41,6 +42,6 @@ class ClassDirective(contentdirective.ClassDirective): ...@@ -41,6 +42,6 @@ class ClassDirective(contentdirective.ClassDirective):
def __call__(self): def __call__(self):
return self.__context.action( return self.__context.action(
discriminator = None, discriminator = None,
callable = initializeClass, callable = InitializeClass,
args = (self.__class,) args = (self.__class,)
) )
...@@ -15,19 +15,22 @@ ...@@ -15,19 +15,22 @@
$Id$ $Id$
""" """
from zope.component import queryUtility, getUtility from zope.component import getUtility
from zope.interface import implements, classProvides from zope.component import queryUtility
from zope.security.interfaces import IInteraction, ISecurityPolicy from zope.interface import classProvides
from zope.interface import implements
from zope.security.checker import CheckerPublic
from zope.security.interfaces import IInteraction
from zope.security.interfaces import ISecurityPolicy
from zope.security.interfaces import IPermission from zope.security.interfaces import IPermission
from zope.security.management import thread_local from zope.security.management import thread_local
from zope.security.simplepolicies import ParanoidSecurityPolicy from zope.security.simplepolicies import ParanoidSecurityPolicy
from AccessControl import ClassSecurityInfo, getSecurityManager from AccessControl.SecurityInfo import ClassSecurityInfo
from Globals import InitializeClass as initializeClass from AccessControl.SecurityManagement import getSecurityManager
CheckerPublicId = 'zope.Public' CheckerPublicId = 'zope.Public'
CheckerPrivateId = 'zope2.Private' CheckerPrivateId = 'zope2.Private'
from zope.security.checker import CheckerPublic
def getSecurityInfo(klass): def getSecurityInfo(klass):
sec = {} sec = {}
......
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
$Id$ $Id$
""" """
from zope.interface import Interface, implements from zope.interface import implements
from AccessControl import ClassSecurityInfo from zope.interface import Interface
from AccessControl.SecurityInfo import ClassSecurityInfo
class ISuperDummy(Interface): class ISuperDummy(Interface):
""" """
...@@ -95,7 +96,7 @@ def test_security_equivalence(): ...@@ -95,7 +96,7 @@ def test_security_equivalence():
... ''' ... '''
>>> zcml.load_string(configure_zcml) >>> zcml.load_string(configure_zcml)
>>> from Globals import InitializeClass >>> from App.class_init import InitializeClass
>>> InitializeClass(Dummy2) >>> InitializeClass(Dummy2)
Now we compare their access controls: Now we compare their access controls:
......
...@@ -15,17 +15,18 @@ ...@@ -15,17 +15,18 @@
$Id$ $Id$
""" """
import Acquisition from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl import ClassSecurityInfo from Acquisition import Explicit
from App.class_init import InitializeClass
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from Globals import InitializeClass
from zope.interface import Interface, implements from zope.interface import implements
from zope.interface import Interface
class IFancyContent(Interface): class IFancyContent(Interface):
pass pass
class FancyAttribute(Acquisition.Explicit): class FancyAttribute(Explicit):
"""Doc test fanatics""" """Doc test fanatics"""
def __init__(self, name): def __init__(self, name):
......
...@@ -15,11 +15,12 @@ ...@@ -15,11 +15,12 @@
$Id$ $Id$
""" """
from AccessControl.SecurityInfo import ClassSecurityInfo
from App.class_init import InitializeClass
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from zope.interface import Interface, implements from zope.interface import implements
from zope.interface import Interface
class ISimpleContent(Interface): class ISimpleContent(Interface):
pass pass
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
$Id$ $Id$
""" """
import os import os
from zope.app.publisher.browser import viewmeta from zope.app.publisher.browser import viewmeta
from zope.component import zcml from zope.component import zcml
from zope.configuration.exceptions import ConfigurationError from zope.configuration.exceptions import ConfigurationError
...@@ -26,8 +27,10 @@ from zope.publisher.interfaces.browser import IBrowserView ...@@ -26,8 +27,10 @@ from zope.publisher.interfaces.browser import IBrowserView
from zope.publisher.interfaces.browser import IDefaultBrowserLayer from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.viewlet import interfaces from zope.viewlet import interfaces
from Globals import InitializeClass as initializeClass from App.class_init import InitializeClass
from Products.Five.security import protectClass, protectName from App.special_dtml import DTMLFile
from Products.Five.security import protectClass
from Products.Five.security import protectName
from Products.Five.viewlet import manager from Products.Five.viewlet import manager
from Products.Five.viewlet import viewlet from Products.Five.viewlet import viewlet
...@@ -88,7 +91,7 @@ def viewletManagerDirective( ...@@ -88,7 +91,7 @@ def viewletManagerDirective(
) )
_context.action( _context.action(
discriminator = ('five:initialize:class', new_class), discriminator = ('five:initialize:class', new_class),
callable = initializeClass, callable = InitializeClass,
args = (new_class,) args = (new_class,)
) )
...@@ -188,6 +191,6 @@ def viewletDirective( ...@@ -188,6 +191,6 @@ def viewletDirective(
) )
_context.action( _context.action(
discriminator = ('five:initialize:class', new_class), discriminator = ('five:initialize:class', new_class),
callable = initializeClass, callable = InitializeClass,
args = (new_class,) args = (new_class,)
) )
This diff is collapsed.
...@@ -10,50 +10,58 @@ ...@@ -10,50 +10,58 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import Globals, AccessControl.User
from Globals import Persistent from AccessControl.SecurityInfo import ClassSecurityInfo
from Globals import InitializeClass from AccessControl.User import UserFolder
from AccessControl import ClassSecurityInfo from App.class_init import InitializeClass
from App.special_dtml import HTMLFile
from Acquisition import Implicit from Acquisition import Implicit
from OFS import SimpleItem from OFS.SimpleItem import Item
from Persistence import Persistent
manage_addPrincipiaDraftForm=Globals.HTMLFile('dtml/draftAdd',globals()) manage_addPrincipiaDraftForm = HTMLFile('dtml/draftAdd',globals())
def manage_addPrincipiaDraft(self, id, baseid, PATH_INFO, REQUEST=None): def manage_addPrincipiaDraft(self, id, baseid, PATH_INFO, REQUEST=None):
"Add a draft object" "Add a draft object"
self._setObject(id, Draft(id, baseid, PATH_INFO)) self._setObject(id, Draft(id, baseid, PATH_INFO))
if REQUEST is not None: return self.manage_main(self,REQUEST) if REQUEST is not None:
return self.manage_main(self,REQUEST)
class Draft(Persistent, Implicit, SimpleItem.Item): class Draft(Persistent, Implicit, Item):
"Daft objects" "Daft objects"
_refid='' _refid = ''
_version='/version' _version = '/version'
meta_type='Zope Draft' meta_type = 'Zope Draft'
security = ClassSecurityInfo() security = ClassSecurityInfo()
def __init__(self, id, baseid, PATH_INFO): def __init__(self, id, baseid, PATH_INFO):
self.id=id self.id = id
self._refid=baseid self._refid = baseid
version=PATH_INFO version = PATH_INFO
l=version.rfind('/') l = version.rfind('/')
if l >= 0: version=version[:l] if l >= 0:
self._version="%s/%s" % (version, id) version = version[:l]
self.users__draft__=uf=AccessControl.User.UserFolder() self._version = "%s/%s" % (version, id)
self.__allow_groups__=uf self.users__draft__ = uf = UserFolder()
self.__allow_groups__ = uf
def icon(self): def icon(self):
try: return getattr(self.aq_parent.aq_base,self._refid).icon try:
except: return 'p_/broken' return getattr(self.aq_parent.aq_base,self._refid).icon
except:
return 'p_/broken'
def manage_options(self): def manage_options(self):
try: return getattr(self.aq_parent.aq_base,self._refid).manage_options try:
except: return () return getattr(self.aq_parent.aq_base,self._refid).manage_options
except:
return ()
def title(self): def title(self):
return 'draft of '+self._refid return 'draft of '+self._refid
def title_and_id(self): def title_and_id(self):
nonempty=self.nonempty() nonempty = self.nonempty()
if nonempty: if nonempty:
return ('draft of %s (%s)' return ('draft of %s (%s)'
'</a> <a href="%s/users__draft__/manage_main">[Users]' '</a> <a href="%s/users__draft__/manage_main">[Users]'
...@@ -69,53 +77,68 @@ class Draft(Persistent, Implicit, SimpleItem.Item): ...@@ -69,53 +77,68 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
self.id, self.id,
)) ))
def __bobo_traverse__(self, REQUEST, name):
if name[-9:]=='__draft__': return getattr(self, name)
def _getVersionBase(self):
import Globals # for data
versionbase = getattr(Globals, 'VersionBase', {})
return versionbase.get(self._version)
try: db=self._p_jar.db() def _bobo_traverse__(self, REQUEST, name):
if name[-9:] == '__draft__':
return getattr(self, name)
try:
db = self._p_jar.db()
except: except:
# BoboPOS 2 # BoboPOS 2
jar = Globals.VersionBase[self._version].jar vb = self._getVersionBase()
jar = vb and vb.jar
else: else:
# ZODB 3 # ZODB 3
jar = db.open(self._version) jar = db.open(self._version)
cleanup = Cleanup(jar) cleanup = Cleanup(jar)
REQUEST[Cleanup]=cleanup REQUEST[Cleanup] = cleanup
dself=getdraft(self, jar) dself = getdraft(self, jar)
ref=getattr(dself.aq_parent.aq_base,dself._refid).aq_base.__of__(dself) ref = getattr(dself.aq_parent.aq_base,dself._refid
if hasattr(ref, name): return dself, ref, getattr(ref, name) ).aq_base.__of__(dself)
if hasattr(ref, name):
return dself, ref, getattr(ref, name)
return getattr(self, name) return getattr(self, name)
def nonempty(self): def nonempty(self):
try: db=self._p_jar.db() try:
db = self._p_jar.db()
except: except:
# BoboPOS 2 # BoboPOS 2
return Globals.VersionBase[self._version].nonempty() vb = self._getVersionBase()
return vb and vb.nonempty()
else: else:
# ZODB 3 # ZODB 3
return not db.versionEmpty(self._version) return not db.versionEmpty(self._version)
security.declareProtected('Approve draft changes', security.declareProtected('Approve draft changes',
'manage_approve__draft__') 'manage_approve__draft__')
manage_approve__draft__=Globals.HTMLFile('dtml/draftApprove', globals()) manage_approve__draft__ = HTMLFile('dtml/draftApprove', globals())
security.declareProtected('Approve draft changes', security.declareProtected('Approve draft changes',
'manage_Save__draft__') 'manage_Save__draft__')
def manage_Save__draft__(self, remark, REQUEST=None): def manage_Save__draft__(self, remark, REQUEST=None):
"""Make version changes permanent""" """Make version changes permanent"""
try: db=self._p_jar.db() try:
db = self._p_jar.db()
except: except:
# BoboPOS 2 # BoboPOS 2
Globals.VersionBase[self._version].commit(remark) vb = self._getVersionBase()
vb.commit(remark)
else: else:
# ZODB 3 # ZODB 3
s=self._version s = self._version
d=self._p_jar.getVersion() d = self._p_jar.getVersion()
if d==s: d='' if d == s:
d = ''
db.commitVersion(s, d) db.commitVersion(s, d)
if REQUEST: if REQUEST:
...@@ -125,10 +148,12 @@ class Draft(Persistent, Implicit, SimpleItem.Item): ...@@ -125,10 +148,12 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
'manage_Discard__draft__') 'manage_Discard__draft__')
def manage_Discard__draft__(self, REQUEST=None): def manage_Discard__draft__(self, REQUEST=None):
'Discard changes made during the version' 'Discard changes made during the version'
try: db=self._p_jar.db() try:
db = self._p_jar.db()
except: except:
# BoboPOS 2 # BoboPOS 2
Globals.VersionBase[self._version].abort() vb = self._getVersionBase()
vb.abort()
else: else:
# ZODB 3 # ZODB 3
db.abortVersion(self._version) db.abortVersion(self._version)
...@@ -137,11 +162,11 @@ class Draft(Persistent, Implicit, SimpleItem.Item): ...@@ -137,11 +162,11 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main') REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main')
def manage_afterClone(self, item): def manage_afterClone(self, item):
self._version='' self._version = ''
def manage_afterAdd(self, item, container): def manage_afterAdd(self, item, container):
if not self._version: if not self._version:
self._version=self.absolute_url(1) self._version = self.absolute_url(1)
def manage_beforeDelete(self, item, container): def manage_beforeDelete(self, item, container):
if self.nonempty(): if self.nonempty():
...@@ -157,7 +182,8 @@ def getdraft(ob, jar): ...@@ -157,7 +182,8 @@ def getdraft(ob, jar):
if hasattr(ob,'aq_parent'): if hasattr(ob,'aq_parent'):
return getdraft(ob.aq_self, jar).__of__(getdraft(ob.aq_parent, jar)) return getdraft(ob.aq_self, jar).__of__(getdraft(ob.aq_parent, jar))
if hasattr(ob,'_p_oid'): ob=jar[ob._p_oid] if hasattr(ob,'_p_oid'):
ob = jar[ob._p_oid]
return ob return ob
......
...@@ -14,28 +14,29 @@ ...@@ -14,28 +14,29 @@
__version__='$Revision: 1.55 $'[11:-2] __version__='$Revision: 1.55 $'[11:-2]
import Globals, time from cgi import escape
from AccessControl.Role import RoleManager import time
from Globals import MessageDialog
from Globals import Persistent
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import change_versions from AccessControl.Permissions import change_versions
from AccessControl.Permissions import join_leave_versions from AccessControl.Permissions import join_leave_versions
from AccessControl.Permissions import save_discard_version_changes from AccessControl.Permissions import save_discard_version_changes
from AccessControl.Permissions import view_management_screens from AccessControl.Permissions import view_management_screens
from AccessControl.Role import RoleManager
from AccessControl.SecurityInfo import ClassSecurityInfo
from Acquisition import Implicit from Acquisition import Implicit
from OFS.SimpleItem import Item from App.class_init import InitializeClass
from Globals import HTML
from App.Dialogs import MessageDialog from App.Dialogs import MessageDialog
from App.special_dtml import DTMLFile
from App.special_dtml import HTML
from OFS.SimpleItem import Item
from Persistence import Persistent
from OFS.ObjectManager import BeforeDeleteException from OFS.ObjectManager import BeforeDeleteException
from cgi import escape
import transaction import transaction
class VersionException(BeforeDeleteException): pass class VersionException(BeforeDeleteException):
pass
manage_addVersionForm=Globals.DTMLFile('dtml/versionAdd', globals()) manage_addVersionForm = DTMLFile('dtml/versionAdd', globals())
def manage_addVersion(self, id, title, REQUEST=None): def manage_addVersion(self, id, title, REQUEST=None):
""" """ """ """
...@@ -77,23 +78,32 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -77,23 +78,32 @@ class Version(Persistent,Implicit,RoleManager,Item):
self.title=title self.title=title
security.declareProtected(join_leave_versions, 'manage_main') security.declareProtected(join_leave_versions, 'manage_main')
manage_main=Globals.DTMLFile('dtml/version', globals()) manage_main = DTMLFile('dtml/version', globals())
security.declareProtected(save_discard_version_changes, 'manage_end') security.declareProtected(save_discard_version_changes, 'manage_end')
manage_end=Globals.DTMLFile('dtml/versionEnd', globals()) manage_end = DTMLFile('dtml/versionEnd', globals())
security.declareProtected(view_management_screens, 'manage_editForm') security.declareProtected(view_management_screens, 'manage_editForm')
manage_editForm =Globals.DTMLFile('dtml/versionEdit', globals()) manage_editForm = DTMLFile('dtml/versionEdit', globals())
def _getVersionBaseCookie(self):
import Globals # for data
versionbase = getattr(Globals, 'VersionBase', {})
return versionbase.get(self.cookie)
def title_and_id(self): def title_and_id(self):
r=Version.inheritedAttribute('title_and_id')(self) r = Version.inheritedAttribute('title_and_id')(self)
try: db=self._p_jar.db() try:
db = self._p_jar.db()
except: except:
# BoboPOS 2 # BoboPOS 2
if Globals.VersionBase[self.cookie].nonempty(): return '%s *' % r vbc = self._getVersionBaseCookie()
if vbc and vbc.nonempty():
return '%s *' % r
else: else:
# ZODB 3 # ZODB 3
if not db.versionEmpty(self.cookie): return '%s *' % r if not db.versionEmpty(self.cookie):
return '%s *' % r
return r return r
...@@ -103,7 +113,8 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -103,7 +113,8 @@ class Version(Persistent,Implicit,RoleManager,Item):
'alt': self.meta_type, 'title': self.meta_type}, 'alt': self.meta_type, 'title': self.meta_type},
{'path': 'misc_/PageTemplates/exclamation.gif', {'path': 'misc_/PageTemplates/exclamation.gif',
'alt': 'Deprecated object', 'alt': 'Deprecated object',
'title': 'Version objects are deprecated and should not be used anyore.'},) 'title': 'Version objects are deprecated '
'and should not be used anyore.'},)
security.declareProtected(change_versions, 'manage_edit') security.declareProtected(change_versions, 'manage_edit')
def manage_edit(self, title, REQUEST=None): def manage_edit(self, title, REQUEST=None):
...@@ -116,7 +127,9 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -116,7 +127,9 @@ class Version(Persistent,Implicit,RoleManager,Item):
security.declareProtected(join_leave_versions, 'enter') security.declareProtected(join_leave_versions, 'enter')
def enter(self, REQUEST, RESPONSE): def enter(self, REQUEST, RESPONSE):
"""Begin working in a version""" """Begin working in a version.
"""
import Globals # for data
RESPONSE.setCookie( RESPONSE.setCookie(
Globals.VersionNameName, self.cookie, Globals.VersionNameName, self.cookie,
path=(REQUEST['BASEPATH1'] or '/'), path=(REQUEST['BASEPATH1'] or '/'),
...@@ -134,7 +147,9 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -134,7 +147,9 @@ class Version(Persistent,Implicit,RoleManager,Item):
security.declareProtected(join_leave_versions, 'leave') security.declareProtected(join_leave_versions, 'leave')
def leave(self, REQUEST, RESPONSE): def leave(self, REQUEST, RESPONSE):
"""Temporarily stop working in a version""" """Temporarily stop working in a version
"""
import Globals # for data
RESPONSE.setCookie( RESPONSE.setCookie(
Globals.VersionNameName,'No longer active', Globals.VersionNameName,'No longer active',
expires="Mon, 25-Jan-1999 23:59:59 GMT", expires="Mon, 25-Jan-1999 23:59:59 GMT",
...@@ -159,10 +174,13 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -159,10 +174,13 @@ class Version(Persistent,Implicit,RoleManager,Item):
security.declareProtected(save_discard_version_changes, 'save') security.declareProtected(save_discard_version_changes, 'save')
def save(self, remark, REQUEST=None): def save(self, remark, REQUEST=None):
"""Make version changes permanent""" """Make version changes permanent"""
try: db=self._p_jar.db() try:
db = self._p_jar.db()
except: except:
# BoboPOS 2 # BoboPOS 2
Globals.VersionBase[self.cookie].commit(remark) vbc = self._getVersionBaseCookie()
if vbc:
vbc.commit(remark)
else: else:
# ZODB 3 # ZODB 3
s=self.cookie s=self.cookie
...@@ -177,10 +195,13 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -177,10 +195,13 @@ class Version(Persistent,Implicit,RoleManager,Item):
security.declareProtected(save_discard_version_changes, 'discard') security.declareProtected(save_discard_version_changes, 'discard')
def discard(self, remark='', REQUEST=None): def discard(self, remark='', REQUEST=None):
'Discard changes made during the version' 'Discard changes made during the version'
try: db=self._p_jar.db() try:
db = self._p_jar.db()
except: except:
# BoboPOS 2 # BoboPOS 2
Globals.VersionBase[self.cookie].abort() vbc = self._getVersionBaseCookie()
if vbc:
vbc.abort()
else: else:
# ZODB 3 # ZODB 3
transaction.get().note(remark) transaction.get().note(remark)
...@@ -190,10 +211,12 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -190,10 +211,12 @@ class Version(Persistent,Implicit,RoleManager,Item):
REQUEST['RESPONSE'].redirect(REQUEST['URL1']+'/manage_main') REQUEST['RESPONSE'].redirect(REQUEST['URL1']+'/manage_main')
def nonempty(self): def nonempty(self):
try: db=self._p_jar.db() try:
db = self._p_jar.db()
except: except:
# BoboPOS 2 # BoboPOS 2
return Globals.VersionBase[self.cookie].nonempty() vbc = self._getVersionBaseCookie()
return vbc and vbc.nonempty()
else: else:
# ZODB 3 # ZODB 3
return not db.versionEmpty(self.cookie) return not db.versionEmpty(self.cookie)
...@@ -212,13 +235,16 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -212,13 +235,16 @@ class Version(Persistent,Implicit,RoleManager,Item):
self.cookie='/'.join(self.getPhysicalPath()) self.cookie='/'.join(self.getPhysicalPath())
def manage_beforeDelete(self, item, container): def manage_beforeDelete(self, item, container):
import Globals # for data
if self.nonempty(): if self.nonempty():
raise VersionException( raise VersionException(
'Attempt to %sdelete a non-empty version.<br />' % 'Attempt to %sdelete a non-empty version.<br />' %
((self is not item) and 'indirectly ' or '')) ((self is not item) and 'indirectly ' or ''))
try: REQUEST=self.REQUEST try:
except: pass REQUEST=self.REQUEST
except:
pass
else: else:
v=self.cookie v=self.cookie
if REQUEST.get(Globals.VersionNameName, '') == v: if REQUEST.get(Globals.VersionNameName, '') == v:
......
...@@ -14,8 +14,11 @@ ...@@ -14,8 +14,11 @@
import os import os
from logging import getLogger from logging import getLogger
import AccessControl from AccessControl.SecurityInfo import ClassSecurityInfo
from Globals import package_home, InitializeClass, DevelopmentMode from AccessControl.SecurityManagement import getSecurityManager
from App.class_init import InitializeClass
from App.Common import package_home
from App.special_dtml import DTMLFile
from App.config import getConfiguration from App.config import getConfiguration
from Acquisition import aq_parent, aq_inner, aq_get from Acquisition import aq_parent, aq_inner, aq_get
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
...@@ -54,13 +57,12 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable): ...@@ -54,13 +57,12 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
func_code = FuncCode((), 0) func_code = FuncCode((), 0)
_v_last_read = 0 _v_last_read = 0
# needed by App.class_init.default__class_init__, often imported # needed by App.class_init.InitializeClass
# using the alias Globals.InitializeClass
_need__name__ = 1 _need__name__ = 1
_default_bindings = {'name_subpath': 'traverse_subpath'} _default_bindings = {'name_subpath': 'traverse_subpath'}
security = AccessControl.ClassSecurityInfo() security = ClassSecurityInfo()
security.declareProtected('View management screens', security.declareProtected('View management screens',
'read', 'document_src') 'read', 'document_src')
...@@ -118,7 +120,7 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable): ...@@ -118,7 +120,7 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
response.setHeader('content-type', self.content_type) response.setHeader('content-type', self.content_type)
# Execute the template in a new security context. # Execute the template in a new security context.
security = AccessControl.getSecurityManager() security = getSecurityManager()
bound_names['user'] = security.getUser() bound_names['user'] = security.getUser()
security.addContext(self) security.addContext(self)
...@@ -138,7 +140,8 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable): ...@@ -138,7 +140,8 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
return self.__name__ # Don't reveal filesystem paths return self.__name__ # Don't reveal filesystem paths
def _cook_check(self): def _cook_check(self):
if self._v_last_read and not DevelopmentMode: import Globals # for data
if self._v_last_read and not Globals.DevelopmentMode:
return return
__traceback_info__ = self.filename __traceback_info__ = self.filename
try: try:
......
...@@ -14,25 +14,30 @@ ...@@ -14,25 +14,30 @@
$Id$ $Id$
""" """
import re
import os import os
import Acquisition import re
from AccessControl.Permissions import change_page_templates
from AccessControl.Permissions import ftp_access
from AccessControl.Permissions import view
from AccessControl.Permissions import view_management_screens
from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.ZopeGuards import safe_builtins
from Acquisition import Acquired
from Acquisition import Explicit
from Acquisition import aq_get from Acquisition import aq_get
from Globals import ImageFile, package_home, InitializeClass from App.class_init import InitializeClass
from App.Common import package_home
from App.ImageFile import ImageFile
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
from Shared.DC.Scripts.Script import Script
from Shared.DC.Scripts.Signature import FuncCode
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from OFS.History import Historical, html_diff from OFS.History import Historical, html_diff
from OFS.Cache import Cacheable from OFS.Cache import Cacheable
from OFS.Traversable import Traversable from OFS.Traversable import Traversable
from OFS.PropertyManager import PropertyManager from OFS.PropertyManager import PropertyManager
from Shared.DC.Scripts.Script import Script
from AccessControl import getSecurityManager, safe_builtins, ClassSecurityInfo from Shared.DC.Scripts.Signature import FuncCode
from AccessControl.Permissions import view, ftp_access, change_page_templates
from AccessControl.Permissions import view_management_screens
from webdav.Lockable import ResourceLockedError from webdav.Lockable import ResourceLockedError
from Products.PageTemplates.PageTemplate import PageTemplate from Products.PageTemplates.PageTemplate import PageTemplate
...@@ -40,9 +45,9 @@ from Products.PageTemplates.PageTemplateFile import PageTemplateFile ...@@ -40,9 +45,9 @@ from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PageTemplates.PageTemplateFile import guess_type from Products.PageTemplates.PageTemplateFile import guess_type
from Products.PageTemplates.Expressions import SecureModuleImporter from Products.PageTemplates.Expressions import SecureModuleImporter
from Products.PageTemplates.utils import encodingFromXMLPreamble, \ from Products.PageTemplates.utils import encodingFromXMLPreamble
charsetFromMetaEquiv, convertToUnicode from Products.PageTemplates.utils import charsetFromMetaEquiv
from Products.PageTemplates.utils import convertToUnicode
preferred_encodings = ['utf-8', 'iso-8859-15'] preferred_encodings = ['utf-8', 'iso-8859-15']
if os.environ.has_key('ZPT_PREFERRED_ENCODING'): if os.environ.has_key('ZPT_PREFERRED_ENCODING'):
...@@ -50,10 +55,10 @@ if os.environ.has_key('ZPT_PREFERRED_ENCODING'): ...@@ -50,10 +55,10 @@ if os.environ.has_key('ZPT_PREFERRED_ENCODING'):
class Src(Acquisition.Explicit): class Src(Explicit):
""" I am scary code """ """ I am scary code """
PUT = document_src = Acquisition.Acquired PUT = document_src = Acquired
index_html = None index_html = None
def __before_publishing_traverse__(self, ob, request): def __before_publishing_traverse__(self, ob, request):
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
$Id$ $Id$
""" """
from Globals import DTMLFile from App.special_dtml import DTMLFile
from Products.PluginIndexes.common.UnIndex import UnIndex from Products.PluginIndexes.common.UnIndex import UnIndex
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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