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