Commit 37ab4573 authored by Jim Fulton's avatar Jim Fulton

Changed many files to work with BoboPOS 2 and ZODB 3 to ease

the transaction between the two. Also tried to clean a number
of things up (in preparation for the move). Rearranged things,
moving alot of code out of Globals into other modules.
Migrates some modules into packages and did away with the
infamous Scheduler.

Hold on to your butts. ;)
parent ffbe3537
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Access control support""" """Access control support"""
__version__='$Revision: 1.27 $'[11:-2] __version__='$Revision: 1.28 $'[11:-2]
from Globals import HTMLFile, MessageDialog, Dictionary from Globals import HTMLFile, MessageDialog, Dictionary
...@@ -92,7 +92,7 @@ from string import join, strip, split, find ...@@ -92,7 +92,7 @@ from string import join, strip, split, find
from Acquisition import Implicit from Acquisition import Implicit
import Globals, ExtensionClass import Globals, ExtensionClass
from Permission import Permission from Permission import Permission
from Common import aq_base from App.Common import aq_base
ListType=type([]) ListType=type([])
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Access control package""" """Access control package"""
__version__='$Revision: 1.73 $'[11:-2] __version__='$Revision: 1.74 $'[11:-2]
import Globals, App.Undo, socket, regex import Globals, App.Undo, socket, regex
from Globals import HTMLFile, MessageDialog, Persistent, PersistentMapping from Globals import HTMLFile, MessageDialog, Persistent, PersistentMapping
...@@ -93,7 +93,7 @@ from App.Management import Navigation, Tabs ...@@ -93,7 +93,7 @@ from App.Management import Navigation, Tabs
from Acquisition import Implicit from Acquisition import Implicit
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from base64 import decodestring from base64 import decodestring
from ImageFile import ImageFile from App.ImageFile import ImageFile
from Role import RoleManager from Role import RoleManager
from string import split, join from string import split, join
from PermissionRole import _what_not_even_god_should_do from PermissionRole import _what_not_even_god_should_do
......
##############################################################################
#
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# This license has been certified as Open Source(tm).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Digital Creations requests that attribution be given to Zope
# in any manner possible. Zope includes a "Powered by Zope"
# button that is installed by default. While it is not a license
# violation to remove this button, it is requested that the
# attribution remain. A significant investment has been put
# into Zope, and this effort will continue if the Zope community
# continues to grow. This is one way to assure that growth.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
"""Commonly used utility functions."""
__version__='$Revision: 1.2 $'[11:-2]
from time import time, asctime, gmtime
from string import split
def rfc1123_date(t=None, time=time, asctime=asctime, gmtime=gmtime,
split=split):
# Return an RFC 1123 format date string.
t=split(asctime(gmtime(t or time())))
return '%s, %s %s %s %s GMT' % (t[0],t[2],t[1],t[4],t[3])
def absattr(attr, c=callable):
# Return the absolute value of an attribute,
# calling the attr if it is callable.
if c(attr):
return attr()
return attr
def aq_base(ob, hasattr=hasattr):
# Return the aq_base of an object.
if hasattr(ob, 'aq_base'):
return ob.aq_base
return ob
def is_acquired(ob, hasattr=hasattr, aq_base=aq_base, absattr=absattr):
# Return true if this object is not a direct
# subobject of its aq_parent object.
if not hasattr(ob, 'aq_parent'):
return 0
if hasattr(aq_base(ob.aq_parent), absattr(ob.id)):
return 0
if hasattr(aq_base(ob), 'isTopLevelPrincipiaApplicationObject'):
return 0
return 1
...@@ -85,192 +85,30 @@ ...@@ -85,192 +85,30 @@
"""Global definitions""" """Global definitions"""
__version__='$Revision: 1.40 $'[11:-2] __version__='$Revision: 1.41 $'[11:-2]
import sys, os import Acquisition, ComputedAttribute, App.PersistentExtra, os
from DateTime import DateTime import TreeDisplay, string
from string import atof, rfind
import Acquisition
DevelopmentMode=None
def package_home(globals_dict):
__name__=globals_dict['__name__']
m=sys.modules[__name__]
if hasattr(m,'__path__'):
r=m.__path__[0]
elif "." in __name__:
r=sys.modules[__name__[:rfind(__name__,'.')]].__path__[0]
else:
r=__name__
return os.path.join(os.getcwd(), r)
try: home=os.environ['SOFTWARE_HOME']
except:
import Products
home=package_home(Products.__dict__)
if not os.path.isabs(home):
home=os.path.join(os.getcwd(), home)
home,e=os.path.split(home)
if os.path.split(home)[1]=='.': home=os.path.split(home)[0]
if os.path.split(home)[1]=='..':
home=os.path.split(os.path.split(home)[0])[0]
SOFTWARE_HOME=sys.modules['__builtin__'].SOFTWARE_HOME=home
try: chome=os.environ['INSTANCE_HOME']
except:
chome=home
d,e=os.path.split(chome)
if e=='python':
d,e=os.path.split(d)
if e=='lib': chome=d or os.getcwd()
INSTANCE_HOME=sys.modules['__builtin__'].INSTANCE_HOME=chome
from BoboPOS import Persistent, PickleDictionary
import BoboPOS.PersistentMapping
sys.modules['PersistentMapping']=BoboPOS.PersistentMapping # hack for bw comp
from BoboPOS.PersistentMapping import PersistentMapping
import DocumentTemplate, MethodObject
from AccessControl.PermissionRole import PermissionRole
class ApplicationDefaultPermissions:
_View_Permission='Manager', 'Anonymous'
def default__class_init__(self):
dict=self.__dict__
have=dict.has_key
ft=type(default__class_init__)
for name, v in dict.items():
if hasattr(v,'_need__name__') and v._need__name__:
v.__dict__['__name__']=name
if name=='manage' or name[:7]=='manage_':
name=name+'__roles__'
if not have(name): dict[name]='Manager',
elif name=='manage' or name[:7]=='manage_' and type(v) is ft:
name=name+'__roles__'
if not have(name): dict[name]='Manager',
if hasattr(self, '__ac_permissions__'):
for acp in self.__ac_permissions__:
pname, mnames = acp[:2]
pr=PermissionRole(pname)
for mname in mnames:
try: getattr(self, mname).__roles__=pr
except: dict[mname+'__roles__']=pr
pname=pr._p
if not hasattr(ApplicationDefaultPermissions, pname):
if len(acp) > 2:
setattr(ApplicationDefaultPermissions, pname, acp[2])
else:
setattr(ApplicationDefaultPermissions, pname, ('Manager',))
Persistent.__dict__['__class_init__']=default__class_init__
class PersistentUtil:
def bobobase_modification_time(self):
try:
t=self._p_mtime
if t is None: return DateTime()
except: t=0
return DateTime(t)
def locked_in_version(self):
oid=self._p_oid
return (oid and VersionBase.locks.has_key(oid)
and VersionBase.verify_lock(oid))
def modified_in_version(self):
jar=self._p_jar
if jar is None:
if hasattr(self,'aq_parent') and hasattr(self.aq_parent, '_p_jar'):
jar=self.aq_parent._p_jar
if jar is None: return 0
if not jar.name: return 0
try: jar.db[self._p_oid]
except: return 0
return 1
for k, v in PersistentUtil.__dict__.items(): Persistent.__dict__[k]=v
class HTML(DocumentTemplate.HTML,Persistent,):
"Persistent HTML Document Templates"
class HTMLDefault(DocumentTemplate.HTMLDefault,Persistent,):
"Persistent Default HTML Document Templates"
class HTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,):
"Persistent HTML Document Templates read from files"
class func_code: pass
func_code=func_code()
func_code.co_varnames='trueself', 'self', 'REQUEST'
func_code.co_argcount=3
_need__name__=1
_v_last_read=0
def __init__(self,name,_prefix=None, **kw):
if _prefix is None: _prefix=SOFTWARE_HOME
elif type(_prefix) is not type(''): _prefix=package_home(_prefix)
args=(self, '%s/%s.dtml' % (_prefix,name))
if not kw.has_key('__name__'): kw['__name__']=name
apply(HTMLFile.inheritedAttribute('__init__'),args,kw)
def __call__(self, *args, **kw):
if DevelopmentMode:
__traceback_info__=self.raw
t=os.stat(self.raw)
if t != self._v_last_read:
self.cook()
self._v_last_read=t
return apply(HTMLFile.inheritedAttribute('__call__'),
(self,)+args[1:],kw)
data_dir = INSTANCE_HOME+'/var'
BobobaseName = '%s/Data.bbb' % data_dir
from App.FindHomes import INSTANCE_HOME, SOFTWARE_HOME
from DateTime import DateTime
from App.Common import package_home, attrget, Dictionary
from Persistence import Persistent, PersistentMapping
from App.special_dtml import HTML, HTMLFile
from App.class_init import default__class_init__, ApplicationDefaultPermissions
from App.Dialogs import MessageDialog from App.Dialogs import MessageDialog
from ImageFile import ImageFile from App.ImageFile import ImageFile
VersionNameName='Zope-Version' DevelopmentMode=None
# utility stuff
def attrget(o,name,default):
if hasattr(o,name): return getattr(o,name)
return default
class Selector:
def __init__(self, key):
self._k=key
def __call__(self, o):
return o[key]
class MultipleSelector: data_dir = INSTANCE_HOME+'/var'
def __init__(self, keys):
self._k=keys
def __call__(self, o):
r=[]
a=r.append
for key in self._k: a(o[key])
return r
def getitems(o,names): for n in 'Z', 'BOBO':
r=[] if os.environ.has_key('%s_DEBUG_MODE' % n):
for name in names: n=string.lower(os.environ['%s_DEBUG_MODE' % n])
v=o[name] if n=='no' or n=='off': continue
r.append(v) try: n=string.atoi(n)
return r except: pass
if n: DevelopmentMode=1
def Dictionary(**kw): return kw # Sorry Guido
from ImageFile import ImageFile # So we can import from here opened=[]
...@@ -84,13 +84,13 @@ ...@@ -84,13 +84,13 @@
############################################################################## ##############################################################################
"""Help system implementation""" """Help system implementation"""
__version__='$Revision: 1.6 $'[11:-2] __version__='$Revision: 1.7 $'[11:-2]
import sys, os, string, Globals, Acquisition import sys, os, string, Globals, Acquisition
from HelpUtil import HelpBase from HelpUtil import HelpBase
from ObjectRef import ObjectRef from ObjectRef import ObjectRef
from ImageFile import ImageFile from App.ImageFile import ImageFile
from Globals import HTMLFile from Globals import HTMLFile
......
...@@ -84,67 +84,14 @@ ...@@ -84,67 +84,14 @@
############################################################################## ##############################################################################
"""Image object that is stored in a file""" """Image object that is stored in a file"""
__version__='$Revision: 1.10 $'[11:-2] __version__='$Revision: 1.11 $'[11:-2]
from Globals import package_home ############################################################
from Common import rfc1123_date #
from string import rfind, split # Eventually this module will go away!
from DateTime import DateTime #
from time import time ############################################################
from os import stat
import Acquisition
class ImageFile(Acquisition.Explicit): from App.ImageFile import ImageFile
"""Image objects stored in external files."""
def __init__(self,path,_prefix=None):
if _prefix is None: _prefix=SOFTWARE_HOME
elif type(_prefix) is not type(''):
_prefix=package_home(_prefix)
path='%s/%s' % (_prefix, path)
self.path=path
self.content_type='image/%s' % path[rfind(path,'.')+1:]
self.__name__=path[rfind(path,'/')+1:]
# Determine a reasonable last-modification time
# to support aggressive image caching.
self.lmt=float(stat(path)[8]) or time()
self.lmh=rfc1123_date(self.lmt)
def _init_headers(self, request, response):
# attempt aggressive caching!
ms=request.get_header('If-Modified-Since', None)
if ms is not None:
# Netscape inexplicably adds a length component
# to the IMS header. Waaaa....
ms=split(ms, ';')[0]
mst=DateTime(ms).timeTime()
if mst >= self.lmt:
response.setStatus(304)
return response
response.setHeader('Content-Type', self.content_type)
response.setHeader('Last-Modified', self.lmh)
response.setHeader('Expires', rfc1123_date(time()+86400.0))
def index_html(self, REQUEST, RESPONSE):
"""Default document"""
self._init_headers(REQUEST, RESPONSE)
f=open(self.path,'rb')
data=f.read()
f.close()
return data
HEAD__roles__=None
def HEAD(self, REQUEST, RESPONSE):
""" """
self._init_headers(self, REQUEST, RESPONSE)
return ''
def __len__(self):
# This is bogus and needed because of the way Python tests truth.
return 1
def __str__(self):
return '<IMG SRC="%s" ALT="%s">' % (self.__name__, self.title_or_id())
...@@ -82,26 +82,55 @@ ...@@ -82,26 +82,55 @@
# attributions are listed in the accompanying credits file. # attributions are listed in the accompanying credits file.
# #
############################################################################## ##############################################################################
import sys, dcdb """Provide a Main application for the Zope framework
dcdb.debug() # Make it easy to set a breakpoint near here. The Job of this module is to:
import os, string - Configure and open the database
from BoboPOS import SimpleDB, TJar, SingleThreadedTransaction
import Globals - Establish the top-level object for ZPublisher
- Perform very high-level configuration tasks
import OFS.Application """
import TreeDisplay.TreeTag # We import BoboPOS before importing any other application
import Scheduler.Scheduler # modules. This is needed to assure that the right
# versions of Persistent etc get registered.
from BoboPOS import SimpleDB, TJar, SingleThreadedTransaction
import sys, os, string, Globals, OFS.Application
Globals.BobobaseName = '%s/Data.bbb' % Globals.data_dir
Globals.VersionNameName='Zope-Version'
# Setup support for broken objects: # Setup support for broken objects:
import OFS.Uninstalled, BoboPOS.PickleJar import OFS.Uninstalled, BoboPOS.PickleJar
BoboPOS.PickleJar.PickleJar.Broken=OFS.Uninstalled.Broken BoboPOS.PickleJar.PickleJar.Broken=OFS.Uninstalled.Broken
# Open the application database # Open the application database
Bobobase=OFS.Application.open_bobobase() OFS.Application.import_products()
revision=read_only=None
if os.environ.has_key('ZOPE_READ_ONLY'):
read_only=1
try: revision=DateTime(os.environ['ZOPE_READ_ONLY']).timeTime()
except: pass
Bobobase=Globals.Bobobase=BoboPOS.PickleDictionary(
Globals.BobobaseName, read_only=read_only, revision=revision)
Globals.opened.append(Bobobase)
VersionBase=Globals.VersionBase=TJar.TM(Bobobase) VersionBase=Globals.VersionBase=TJar.TM(Bobobase)
Globals.opened.append(VersionBase)
try: app=Bobobase['Application']
except KeyError:
app=OFS.Application.Application()
Bobobase['Application']=app
get_transaction().note('created Application object')
get_transaction().commit()
bobo_application=app
OFS.Application.initialize(app)
if os.environ.has_key('ZOPE_DATABASE_QUOTA'): if os.environ.has_key('ZOPE_DATABASE_QUOTA'):
quota=string.atoi(os.environ['ZOPE_DATABASE_QUOTA']) quota=string.atoi(os.environ['ZOPE_DATABASE_QUOTA'])
...@@ -112,17 +141,5 @@ if os.environ.has_key('ZOPE_DATABASE_QUOTA'): ...@@ -112,17 +141,5 @@ if os.environ.has_key('ZOPE_DATABASE_QUOTA'):
lambda x, quota=quota, otherdb=Bobobase._jar.db: lambda x, quota=quota, otherdb=Bobobase._jar.db:
x + otherdb.pos > quota) x + otherdb.pos > quota)
SingleThreadedTransaction.Transaction.commit=VersionBase.committer() SingleThreadedTransaction.Transaction.commit=VersionBase.committer()
bobo_application=app=Bobobase['Application']
for n in 'Z', 'BOBO':
if os.environ.has_key('%s_DEBUG_MODE' % n):
n=string.lower(os.environ['%s_DEBUG_MODE' % n])
if n=='no' or n=='off': continue
try: n=string.atoi(n)
except: pass
if n: Globals.DevelopmentMode=1
...@@ -85,8 +85,8 @@ ...@@ -85,8 +85,8 @@
__doc__='''Application support __doc__='''Application support
$Id: Application.py,v 1.101 1999/04/27 23:49:46 amos Exp $''' $Id: Application.py,v 1.102 1999/04/29 19:21:29 jim Exp $'''
__version__='$Revision: 1.101 $'[11:-2] __version__='$Revision: 1.102 $'[11:-2]
import Globals,Folder,os,regex,sys,App.Product, App.ProductRegistry, misc_ import Globals,Folder,os,regex,sys,App.Product, App.ProductRegistry, misc_
...@@ -205,7 +205,7 @@ class Application(Globals.ApplicationDefaultPermissions, Folder.Folder, ...@@ -205,7 +205,7 @@ class Application(Globals.ApplicationDefaultPermissions, Folder.Folder,
__allow_groups__=UserFolder() __allow_groups__=UserFolder()
def _init(self): def __init__(self):
# Initialize users # Initialize users
self.__allow_groups__=UserFolder() self.__allow_groups__=UserFolder()
self._setObject('acl_users', self.__allow_groups__) self._setObject('acl_users', self.__allow_groups__)
...@@ -248,15 +248,18 @@ class Application(Globals.ApplicationDefaultPermissions, Folder.Folder, ...@@ -248,15 +248,18 @@ class Application(Globals.ApplicationDefaultPermissions, Folder.Folder,
Redirect=ZopeRedirect=PrincipiaRedirect Redirect=ZopeRedirect=PrincipiaRedirect
def __bobo_traverse__(self, REQUEST, name=None): def __bobo_traverse__(self, REQUEST, name=None):
if name is None and REQUEST.has_key(Globals.VersionNameName): if hasattr(Globals,'VersionBase'):
pd=Globals.VersionBase[REQUEST[Globals.VersionNameName]] # BoboPOS 2
alternate_self=pd.jar[self._p_oid] if name is None and REQUEST.has_key(Globals.VersionNameName):
if hasattr(self, 'aq_parent'): pd=Globals.VersionBase[REQUEST[Globals.VersionNameName]]
alternate_self=alternate_self.__of__(self.aq_parent) alternate_self=pd.jar[self._p_oid]
return alternate_self if hasattr(self, 'aq_parent'):
alternate_self=alternate_self.__of__(self.aq_parent)
try: self._p_jar.cache.incrgc() # Perform incremental GC return alternate_self
except: pass
try: self._p_jar.cache.incrgc() # Perform incremental GC
except: pass
try: return getattr(self, name) try: return getattr(self, name)
except AttributeError: pass except AttributeError: pass
try: return self[name] try: return self[name]
...@@ -264,6 +267,7 @@ class Application(Globals.ApplicationDefaultPermissions, Folder.Folder, ...@@ -264,6 +267,7 @@ class Application(Globals.ApplicationDefaultPermissions, Folder.Folder,
method=REQUEST.get('REQUEST_METHOD', 'GET') method=REQUEST.get('REQUEST_METHOD', 'GET')
if not method in ('GET', 'POST'): if not method in ('GET', 'POST'):
return NullResource(self, name, REQUEST).__of__(self) return NullResource(self, name, REQUEST).__of__(self)
REQUEST.RESPONSE.notFoundError("%s\n%s" % (name, method)) REQUEST.RESPONSE.notFoundError("%s\n%s" % (name, method))
def PrincipiaTime(self, *args): def PrincipiaTime(self, *args):
...@@ -314,33 +318,11 @@ class Expired(Globals.Persistent): ...@@ -314,33 +318,11 @@ class Expired(Globals.Persistent):
__inform_commit__=__save__ __inform_commit__=__save__
def open_bobobase(): def initialize(app):
# Open the application database # Open the application database
import_products()
revision=read_only=None
if os.environ.has_key('ZOPE_READ_ONLY'):
read_only=1
try: revision=DateTime(os.environ['ZOPE_READ_ONLY']).timeTime()
except: pass
Bobobase=Globals.Bobobase=Globals.PickleDictionary(
Globals.BobobaseName, read_only=read_only, revision=revision)
product_dir=os.path.join(SOFTWARE_HOME,'Products') product_dir=os.path.join(SOFTWARE_HOME,'Products')
__traceback_info__=sys.path
try: app=Bobobase['Application']
except KeyError:
app=Application()
app._init()
Bobobase['Application']=app
get_transaction().note('created Application object')
get_transaction().commit()
# The following items marked b/c are backward compatibility hacks # The following items marked b/c are backward compatibility hacks
# which make sure that expected system objects are added to the # which make sure that expected system objects are added to the
# bobobase. This is required because the bobobase in use may pre- # bobobase. This is required because the bobobase in use may pre-
...@@ -376,8 +358,6 @@ def open_bobobase(): ...@@ -376,8 +358,6 @@ def open_bobobase():
get_transaction().note('Product installations') get_transaction().note('Product installations')
get_transaction().commit() get_transaction().commit()
return Bobobase
def import_products(_st=type('')): def import_products(_st=type('')):
# Try to import each product, checking for and catching errors. # Try to import each product, checking for and catching errors.
path_join=os.path.join path_join=os.path.join
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
# #
############################################################################## ##############################################################################
__doc__="""Copy interface""" __doc__="""Copy interface"""
__version__='$Revision: 1.32 $'[11:-2] __version__='$Revision: 1.33 $'[11:-2]
import sys, string, Globals, Moniker, tempfile, ExtensionClass import sys, string, Globals, Moniker, tempfile, ExtensionClass
from marshal import loads, dumps from marshal import loads, dumps
...@@ -383,9 +383,9 @@ class CopySource: ...@@ -383,9 +383,9 @@ class CopySource:
def _getCopy(self, container): def _getCopy(self, container):
# Ask an object for a new copy of itself. # Ask an object for a new copy of itself.
f=tempfile.TemporaryFile() f=tempfile.TemporaryFile()
self._p_jar.export_file(self,f) self._p_jar.exportFile(self._p_oid,f)
f.seek(0) f.seek(0)
ob=container._p_jar.import_file(f) ob=container._p_jar.importFile(f)
f.close() f.close()
return ob return ob
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""DTML Document objects.""" """DTML Document objects."""
__version__='$Revision: 1.22 $'[11:-2] __version__='$Revision: 1.23 $'[11:-2]
from DocumentTemplate.DT_Util import InstanceDict, TemplateDict from DocumentTemplate.DT_Util import InstanceDict, TemplateDict
from ZPublisher.Converters import type_converters from ZPublisher.Converters import type_converters
from Globals import HTML, HTMLFile, MessageDialog from Globals import HTML, HTMLFile, MessageDialog
...@@ -181,9 +181,17 @@ class DTMLDocument(DTMLMethod, PropertyManager): ...@@ -181,9 +181,17 @@ class DTMLDocument(DTMLMethod, PropertyManager):
return self.raise_standardErrorMessage(client, REQUEST) return self.raise_standardErrorMessage(client, REQUEST)
if RESPONSE is None: return r if RESPONSE is None: return r
RESPONSE.setHeader('Last-Modified', rfc1123_date(self._p_mtime)) RESPONSE.setHeader('Last-Modified', rfc1123_date(self._p_mtime))
# Try to handle content types intelligently... # Try to handle content types intelligently...
c, e=guess_content_type(self.__name__, r) if self.__dict__.has_key('content_type'):
c=self.content_type
else:
c, e=guess_content_type(self.__name__, r)
RESPONSE.setHeader('Content-Type', c) RESPONSE.setHeader('Content-Type', c)
return r
# We don't allow document to set headers
return decapitate(r, RESPONSE) return decapitate(r, RESPONSE)
......
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
and aquisition relationships via a simple interface. and aquisition relationships via a simple interface.
""" """
__version__='$Revision: 1.10 $'[11:-2] __version__='$Revision: 1.11 $'[11:-2]
import Globals import Globals
...@@ -103,7 +103,7 @@ class Moniker: ...@@ -103,7 +103,7 @@ class Moniker:
def __init__(self, ob=None): def __init__(self, ob=None):
if ob is None: return if ob is None: return
self.jar=ob._p_jar.name self.jar=ob._p_jar.getVersion()
self.ids=[] self.ids=[]
while 1: while 1:
if not hasattr(ob, '_p_oid'): if not hasattr(ob, '_p_oid'):
...@@ -122,8 +122,15 @@ class Moniker: ...@@ -122,8 +122,15 @@ class Moniker:
def bind(self): def bind(self):
"Return the real object named by this moniker" "Return the real object named by this moniker"
if self.jar is None: jar=Globals.Bobobase._jar if hasattr(Globals,'VersionBase'):
else: jar=Globals.VersionBase[self.jar].jar # BoboPOS 2
if not self.jar: jar=Globals.Bobobase._jar
else: jar=Globals.VersionBase[self.jar].jar
else:
# ZODB 3 Problem, we make have more than one database! Waaa
jar=Globals.DB.open(transaction=get_transaction(),
version=self.jar or '', temporary=1)
ob=None ob=None
for n in self.ids: for n in self.ids:
o=jar[n] o=jar[n]
......
...@@ -84,9 +84,9 @@ ...@@ -84,9 +84,9 @@
############################################################################## ##############################################################################
__doc__="""Object Manager __doc__="""Object Manager
$Id: ObjectManager.py,v 1.68 1999/04/22 15:55:39 brian Exp $""" $Id: ObjectManager.py,v 1.69 1999/04/29 19:21:30 jim Exp $"""
__version__='$Revision: 1.68 $'[11:-2] __version__='$Revision: 1.69 $'[11:-2]
import App.Management, Acquisition, App.Undo, Globals, CopySupport import App.Management, Acquisition, App.Undo, Globals, CopySupport
import os, App.FactoryDispatcher, ts_regex, Products import os, App.FactoryDispatcher, ts_regex, Products
...@@ -380,13 +380,13 @@ class ObjectManager( ...@@ -380,13 +380,13 @@ class ObjectManager(
if id is None: o=self if id is None: o=self
else: o=self._getOb(id) else: o=self._getOb(id)
f=Globals.data_dir+'/export.bbe' f=Globals.data_dir+'/export.bbe'
o._p_jar.export_file(o,f) o._p_jar.exportFile(o._p_oid,f)
return f return f
def manage_importHack(self, REQUEST=None): def manage_importHack(self, REQUEST=None):
"Imports a previously exported object from /var/export.bbe" "Imports a previously exported object from /var/export.bbe"
f=Globals.data_dir+'/export.bbe' f=Globals.data_dir+'/export.bbe'
o=self._p_jar.import_file(f) o=self._p_jar.importFile(f)
id=o.id id=o.id
if hasattr(id,'im_func'): id=id() if hasattr(id,'im_func'): id=id()
self._setObject(id,o) self._setObject(id,o)
...@@ -403,13 +403,14 @@ class ObjectManager( ...@@ -403,13 +403,14 @@ class ObjectManager(
else: ob=self._getOb(id) else: ob=self._getOb(id)
if download: if download:
f=StringIO() f=StringIO()
ob._p_jar.export_file(ob, f) ob._p_jar.exportFile(ob._p_oid, f)
RESPONSE.setHeader('Content-type','application/data') RESPONSE.setHeader('Content-type','application/data')
RESPONSE.setHeader('Content-Disposition', RESPONSE.setHeader('Content-Disposition',
'inline;filename=%s.bbe' % id) 'inline;filename=%s.bbe' % id)
return f.getvalue() return f.getvalue()
f=Globals.data_dir+'/%s.bbe' % id f=Globals.data_dir+'/%s.bbe' % id
ob._p_jar.export_file(ob, f) ob._p_jar.exportFile(ob._p_oid, f)
if RESPONSE is not None: if RESPONSE is not None:
return MessageDialog( return MessageDialog(
title="Object exported", title="Object exported",
...@@ -427,7 +428,7 @@ class ObjectManager( ...@@ -427,7 +428,7 @@ class ObjectManager(
file=os.path.join(INSTANCE_HOME, 'import', file) file=os.path.join(INSTANCE_HOME, 'import', file)
if not os.path.exists(file): if not os.path.exists(file):
raise 'Bad Request', 'File does not exist: %s' % file raise 'Bad Request', 'File does not exist: %s' % file
ob=self._p_jar.import_file(file) ob=self._p_jar.importFile(file)
if REQUEST: self._verifyObjectPaste(ob, REQUEST) if REQUEST: self._verifyObjectPaste(ob, REQUEST)
id=ob.id id=ob.id
if hasattr(id, 'im_func'): id=id() if hasattr(id, 'im_func'): id=id()
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
# #
############################################################################## ##############################################################################
from ImageFile import ImageFile from App.ImageFile import ImageFile
class misc_: class misc_:
......
##############################################################################
#
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# This license has been certified as Open Source(tm).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Digital Creations requests that attribution be given to Zope
# in any manner possible. Zope includes a "Powered by Zope"
# button that is installed by default. While it is not a license
# violation to remove this button, it is requested that the
# attribution remain. A significant investment has been put
# into Zope, and this effort will continue if the Zope community
# continues to grow. This is one way to assure that growth.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
"""Provide access to Persistent and PersistentMapping """Provide access to Persistent and PersistentMapping
This avoids dependency on the database package name. This avoids dependency on the database package name.
""" """
from BoboPOS import Persistent, PersistentMapping
# install ExternalMethod.py
# install Util.py
# install __init__.py
# install methodAdd.dtml
# install methodEdit.dtml
# install CHANGES.txt
# install www
##############################################################################
#
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# This license has been certified as Open Source(tm).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Digital Creations requests that attribution be given to Zope
# in any manner possible. Zope includes a "Powered by Zope"
# button that is installed by default. While it is not a license
# violation to remove this button, it is requested that the
# attribution remain. A significant investment has been put
# into Zope, and this effort will continue if the Zope community
# continues to grow. This is one way to assure that growth.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
__doc__='''Utility routines that are handy for developers
$Id: Util.py,v 1.3 1999/03/10 00:15:21 klm Exp $'''
__version__='$Revision: 1.3 $'[11:-2]
standard_reload=reload
import Globals, sys
class_map={} # waaaa
def Reload(module):
classes=[]
__import__(module)
m=sys.modules[module]
for k, v in m.__dict__.items():
if (hasattr(v,'__bases__') and hasattr(v,'__name__')
and hasattr(v,'__dict__') and hasattr(v,'__module__')
and v.__module__==module):
# OK, smells like a class
cn="%s.%s" % (module, k)
if class_map.has_key(cn): v=class_map[cn]
else: class_map[cn]=v
classes.append((k,v))
try: reload(m)
except TypeError, v: raise 'spam', v, sys.exc_traceback
m=sys.modules[module]
r=''
for name, klass in classes:
if hasattr(m,name):
c=getattr(m,name)
d=klass.__dict__
for k, v in c.__dict__.items():
d[k]=v
if r: r="%s, %s" % (r, name)
else: r=name
Globals.Bobobase._jar.cache.minimize(0)
return r or 'No classes affected'
...@@ -91,12 +91,10 @@ from operator import truth ...@@ -91,12 +91,10 @@ from operator import truth
import Acquisition, sys, ts_regex, string, types, mimetools import Acquisition, sys, ts_regex, string, types, mimetools
import OFS.SimpleItem, re, quopri, rfc822 import OFS.SimpleItem, re, quopri, rfc822
import Globals import Globals
from Scheduler.OneTimeEvent import OneTimeEvent
from ImageFile import ImageFile
from cStringIO import StringIO from cStringIO import StringIO
#$Id: MailHost.py,v 1.41 1999/03/25 15:50:30 jim Exp $ #$Id: MailHost.py,v 1.42 1999/04/29 19:21:31 jim Exp $
__version__ = "$Revision: 1.41 $"[11:-2] __version__ = "$Revision: 1.42 $"[11:-2]
smtpError = "SMTP Error" smtpError = "SMTP Error"
MailHostError = "MailHost Error" MailHostError = "MailHost Error"
...@@ -172,15 +170,11 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -172,15 +170,11 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
if not headers.has_key(requiredHeader): if not headers.has_key(requiredHeader):
raise MailHostError,"Message missing SMTP Header '%s'"\ raise MailHostError,"Message missing SMTP Header '%s'"\
% requiredHeader % requiredHeader
Globals.Scheduler.schedule(OneTimeEvent( Send(trueself.smtpHost, trueself.smtpPort,
Send,
(trueself.smtpHost, trueself.smtpPort,
trueself.localHost, trueself.timeout, trueself.localHost, trueself.timeout,
headers['from'], headers['to'], headers['from'], headers['to'],
headers['subject'] or 'No Subject', messageText headers['subject'] or 'No Subject', messageText
), )
threadsafe=1
))
if not statusTemplate: return "SEND OK" if not statusTemplate: return "SEND OK"
...@@ -233,14 +227,10 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -233,14 +227,10 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
raise MailHostError,"Message missing SMTP Header '%s'"\ raise MailHostError,"Message missing SMTP Header '%s'"\
% requiredHeader % requiredHeader
messageText=_encode(messageText, encode) messageText=_encode(messageText, encode)
Globals.Scheduler.schedule(OneTimeEvent( Send(self.smtpHost, self.smtpPort, self.localHost, self.timeout,
Send,
(self.smtpHost, self.smtpPort, self.localHost, self.timeout,
headers['from'], headers['to'], headers['from'], headers['to'],
headers['subject'] or 'No Subject', messageText headers['subject'] or 'No Subject', messageText
), )
threadsafe=1
))
def simple_send(self, mto, mfrom, subject, body): def simple_send(self, mto, mfrom, subject, body):
body="subject: %s\n\n%s" % (subject, body) body="subject: %s\n\n%s" % (subject, body)
......
...@@ -83,11 +83,11 @@ ...@@ -83,11 +83,11 @@
# #
############################################################################## ##############################################################################
__doc__='''MailHost Product Initialization __doc__='''MailHost Product Initialization
$Id: __init__.py,v 1.13 1999/04/02 15:40:33 michel Exp $''' $Id: __init__.py,v 1.14 1999/04/29 19:21:31 jim Exp $'''
__version__='$Revision: 1.13 $'[11:-2] __version__='$Revision: 1.14 $'[11:-2]
import MailHost, SendMailTag import MailHost, SendMailTag
from ImageFile import ImageFile from App.ImageFile import ImageFile
classes=('MailHost.MailHost',) classes=('MailHost.MailHost',)
......
...@@ -148,24 +148,62 @@ class Draft(Persistent, Implicit, SimpleItem.Item): ...@@ -148,24 +148,62 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
def __bobo_traverse__(self, REQUEST, name): def __bobo_traverse__(self, REQUEST, name):
if name[-9:]=='__draft__': return getattr(self, name) if name[-9:]=='__draft__': return getattr(self, name)
dself=getdraft(self, self._version)
try: db=self._jar.db()
except:
# BoboPOS 2
jar=Globals.VersionBase[version].jar
else:
# ZODB 3
jar=db.open(self._version)
cleanup=Cleanup()
cleanup.__del__=jar.close
REQUEST[Cleanup]=cleanup
dself=getdraft(self, jar)
ref=getattr(dself.aq_parent.aq_base,dself._refid).aq_base.__of__(dself) ref=getattr(dself.aq_parent.aq_base,dself._refid).aq_base.__of__(dself)
if hasattr(ref, name): return dself, ref, getattr(ref, name) if hasattr(ref, name): return dself, ref, getattr(ref, name)
return getattr(self, name) return getattr(self, name)
def nonempty(self): return Globals.VersionBase[self._version].nonempty() def nonempty(self):
try: db=self._jar.db()
except:
# BoboPOS 2
return Globals.VersionBase[self._version].nonempty()
else:
# ZODB 3
return not db.versionEmpty(self._version)
manage_approve__draft__=Globals.HTMLFile('draftApprove', globals()) manage_approve__draft__=Globals.HTMLFile('draftApprove', globals())
def manage_Save__draft__(self, remark, REQUEST=None): def manage_Save__draft__(self, remark, REQUEST=None):
"""Make version changes permanent""" """Make version changes permanent"""
Globals.VersionBase[self._version].commit(remark) try: db=self._jar.db()
except:
# BoboPOS 2
Globals.VersionBase[self._version].commit(remark)
else:
# ZODB 3
s=self._version
d=self._p_jar.getVersion()
if d==s: d=''
db.commitVersion(s, d)
if REQUEST: if REQUEST:
REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main') REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main')
def manage_Discard__draft__(self, REQUEST=None): def manage_Discard__draft__(self, REQUEST=None):
'Discard changes made during the version' 'Discard changes made during the version'
Globals.VersionBase[self._version].abort() try: db=self._jar.db()
except:
# BoboPOS 2
Globals.VersionBase[self._version].abort()
else:
# ZODB 3
db.abortVersion(self._version)
if REQUEST: if REQUEST:
REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main') REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main')
...@@ -188,10 +226,14 @@ class Draft(Persistent, Implicit, SimpleItem.Item): ...@@ -188,10 +226,14 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
raise 'Copy Error', ( raise 'Copy Error', (
"This object can only be copied through the web.<p>") "This object can only be copied through the web.<p>")
def getdraft(ob, version): def getdraft(ob, jar):
if hasattr(ob,'aq_parent'): if hasattr(ob,'aq_parent'):
return getdraft(ob.aq_self, version).__of__( return getdraft(ob.aq_self, jar).__of__(getdraft(ob.aq_parent, jar))
getdraft(ob.aq_parent, version))
if hasattr(ob,'_p_oid'): if hasattr(ob,'_p_oid'): ob=jar[ob._p_oid]
ob=Globals.VersionBase[version].jar[ob._p_oid]
return ob return ob
class Cleanup: pass
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Version object""" """Version object"""
__version__='$Revision: 1.29 $'[11:-2] __version__='$Revision: 1.30 $'[11:-2]
import Globals, time import Globals, time
from AccessControl.Role import RoleManager from AccessControl.Role import RoleManager
...@@ -133,7 +133,14 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -133,7 +133,14 @@ class Version(Persistent,Implicit,RoleManager,Item):
def title_and_id(self): def title_and_id(self):
r=Version.inheritedAttribute('title_and_id')(self) r=Version.inheritedAttribute('title_and_id')(self)
if Globals.VersionBase[self.cookie].nonempty(): return '%s *' % r try: db=self._jar.db()
except:
# BoboPOS 2
if Globals.VersionBase[self.cookie].nonempty(): return '%s *' % r
else:
# ZODB 3
if not db.versionEmpty(self._version): return '%s *' % r
return r return r
def manage_edit(self, title, REQUEST=None): def manage_edit(self, title, REQUEST=None):
...@@ -186,15 +193,39 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -186,15 +193,39 @@ class Version(Persistent,Implicit,RoleManager,Item):
def save(self, remark, REQUEST=None): def save(self, remark, REQUEST=None):
"""Make version changes permanent""" """Make version changes permanent"""
Globals.VersionBase[self.cookie].commit(remark) try: db=self._jar.db()
except:
# BoboPOS 2
Globals.VersionBase[self.cookie].commit(remark)
else:
# ZODB 3
s=self.cookie
d=self._p_jar.getVersion()
if d==s: d=''
db.commitVersion(s, d)
if REQUEST: return self.manage_main(self, REQUEST) if REQUEST: return self.manage_main(self, REQUEST)
def discard(self, REQUEST=None): def discard(self, REQUEST=None):
'Discard changes made during the version' 'Discard changes made during the version'
Globals.VersionBase[self.cookie].abort() try: db=self._jar.db()
except:
# BoboPOS 2
Globals.VersionBase[self.cookie].abort()
else:
# ZODB 3
db.abortVersion(self.cookie)
if REQUEST: return self.manage_main(self, REQUEST) if REQUEST: return self.manage_main(self, REQUEST)
def nonempty(self): return Globals.VersionBase[self.cookie].nonempty() def nonempty(self):
try: db=self._jar.db()
except:
# BoboPOS 2
return Globals.VersionBase[self.cookie].nonempty()
else:
# ZODB 3
return not db.versionEmpty(self.cookie)
def _notifyOfCopyTo(self, container, isMove=0): def _notifyOfCopyTo(self, container, isMove=0):
if isMove and self.nonempty(): if isMove and self.nonempty():
......
...@@ -84,13 +84,12 @@ ...@@ -84,13 +84,12 @@
############################################################################## ##############################################################################
__doc__='''Database Connection __doc__='''Database Connection
$Id: DABase.py,v 1.7 1999/03/10 00:15:29 klm Exp $''' $Id: DABase.py,v 1.8 1999/04/29 19:21:32 jim Exp $'''
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
from db import manage_DataSources from db import manage_DataSources
import Shared.DC.ZRDB.Connection, sys import Shared.DC.ZRDB.Connection, sys
from Globals import HTMLFile from Globals import HTMLFile
from ImageFile import ImageFile
from ExtensionClass import Base from ExtensionClass import Base
import Acquisition import Acquisition
......
...@@ -84,21 +84,21 @@ ...@@ -84,21 +84,21 @@
############################################################################## ##############################################################################
__doc__='''Generic Database Adapter Package Registration __doc__='''Generic Database Adapter Package Registration
$Id: __init__.py,v 1.9 1999/03/10 00:15:29 klm Exp $''' $Id: __init__.py,v 1.10 1999/04/29 19:21:32 jim Exp $'''
__version__='$Revision: 1.9 $'[11:-2] __version__='$Revision: 1.10 $'[11:-2]
import Globals, ImageFile, os import Globals, os
classes=('DA.Connection',) classes=('DA.Connection',)
database_type='Gadfly' database_type='Gadfly'
misc_={'conn': misc_={'conn':
ImageFile.ImageFile('Shared/DC/ZRDB/www/DBAdapterFolder_icon.gif')} Globals.ImageFile('Shared/DC/ZRDB/www/DBAdapterFolder_icon.gif')}
for icon in ('table', 'view', 'stable', 'what', for icon in ('table', 'view', 'stable', 'what',
'field', 'text','bin','int','float', 'field', 'text','bin','int','float',
'date','time','datetime'): 'date','time','datetime'):
misc_[icon]=ImageFile.ImageFile('icons/%s.gif' % icon, globals()) misc_[icon]=Globals.ImageFile('icons/%s.gif' % icon, globals())
meta_types=( meta_types=(
{'name':'Z %s Database Connection' % database_type, {'name':'Z %s Database Connection' % database_type,
......
...@@ -83,8 +83,8 @@ ...@@ -83,8 +83,8 @@
# #
############################################################################## ##############################################################################
'''$Id: db.py,v 1.6 1999/03/10 00:15:29 klm Exp $''' '''$Id: db.py,v 1.7 1999/04/29 19:21:32 jim Exp $'''
__version__='$Revision: 1.6 $'[11:-2] __version__='$Revision: 1.7 $'[11:-2]
import os import os
from string import strip, split from string import strip, split
...@@ -206,6 +206,7 @@ class DB: ...@@ -206,6 +206,7 @@ class DB:
class _p_jar: class _p_jar:
# This is place holder for new transaction machinery 2pc # This is place holder for new transaction machinery 2pc
# I don't think this is needed.
def __init__(self, db=None): self.db=db def __init__(self, db=None): self.db=db
def begin_commit(self, *args): pass def begin_commit(self, *args): pass
def finish_commit(self, *args): pass def finish_commit(self, *args): pass
...@@ -216,15 +217,25 @@ class DB: ...@@ -216,15 +217,25 @@ class DB:
def _register(self): def _register(self):
if not self._registered: if not self._registered:
try: try:
get_transaction().register(self) get_transaction().register(Surrogate(self))
self._registered=1 self._registered=1
except: pass except: pass
def __inform_commit__(self, *ignored): def tpc_begin(self, *ignored): pass
def tpc_commit(self, *ignored):
self.db.commit() self.db.commit()
self._registered=0 self._registered=0
def __inform_abort__(self, *ignored): def tpc_abort(self, *ignored):
self.db.rollback() self.db.rollback()
self.db.checkpoint() self.db.checkpoint()
self._registered=0 self._registered=0
class Surrogate:
def __init__(self, db):
self._p_jar=db
self.__inform_commit__=db.tpc_commit
self.__inform_abort__=db.tpc_abort
...@@ -91,10 +91,9 @@ from ZPublisher.mapply import mapply ...@@ -91,10 +91,9 @@ from ZPublisher.mapply import mapply
from ExtensionClass import Base from ExtensionClass import Base
from App.FactoryDispatcher import FactoryDispatcher from App.FactoryDispatcher import FactoryDispatcher
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
from ImageFile import ImageFile
from OFS.misc_ import p_ from OFS.misc_ import p_
p_.ZClass_Icon=ImageFile('class.gif', globals()) p_.ZClass_Icon=Globals.ImageFile('class.gif', globals())
class PersistentClass(Base): class PersistentClass(Base):
def __class_init__(self): pass def __class_init__(self): pass
......
...@@ -14,10 +14,9 @@ needed by a product and to define product meta data. ...@@ -14,10 +14,9 @@ needed by a product and to define product meta data.
This sample product publishes a folder-ish and a simple object. This sample product publishes a folder-ish and a simple object.
$Id: __init__.py,v 1.3 1999/03/22 17:45:37 jim Exp $''' $Id: __init__.py,v 1.4 1999/04/29 19:21:34 jim Exp $'''
__version__='$Revision: 1.3 $'[11:-2] __version__='$Revision: 1.4 $'[11:-2]
from ImageFile import ImageFile
import ZClass import ZClass
# Names of objects added by this product: # Names of objects added by this product:
......
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