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 @@
##############################################################################
"""Access control support"""
__version__='$Revision: 1.27 $'[11:-2]
__version__='$Revision: 1.28 $'[11:-2]
from Globals import HTMLFile, MessageDialog, Dictionary
......@@ -92,7 +92,7 @@ from string import join, strip, split, find
from Acquisition import Implicit
import Globals, ExtensionClass
from Permission import Permission
from Common import aq_base
from App.Common import aq_base
ListType=type([])
......
......@@ -84,7 +84,7 @@
##############################################################################
"""Access control package"""
__version__='$Revision: 1.73 $'[11:-2]
__version__='$Revision: 1.74 $'[11:-2]
import Globals, App.Undo, socket, regex
from Globals import HTMLFile, MessageDialog, Persistent, PersistentMapping
......@@ -93,7 +93,7 @@ from App.Management import Navigation, Tabs
from Acquisition import Implicit
from OFS.SimpleItem import Item
from base64 import decodestring
from ImageFile import ImageFile
from App.ImageFile import ImageFile
from Role import RoleManager
from string import split, join
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 @@
"""Global definitions"""
__version__='$Revision: 1.40 $'[11:-2]
__version__='$Revision: 1.41 $'[11:-2]
import sys, os
from DateTime import DateTime
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
import Acquisition, ComputedAttribute, App.PersistentExtra, os
import TreeDisplay, string
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 ImageFile import ImageFile
VersionNameName='Zope-Version'
# 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:
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
from App.ImageFile import ImageFile
DevelopmentMode=None
def getitems(o,names):
r=[]
for name in names:
v=o[name]
r.append(v)
return r
data_dir = INSTANCE_HOME+'/var'
def Dictionary(**kw): return kw # Sorry Guido
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: DevelopmentMode=1
from ImageFile import ImageFile # So we can import from here
opened=[]
......@@ -84,13 +84,13 @@
##############################################################################
"""Help system implementation"""
__version__='$Revision: 1.6 $'[11:-2]
__version__='$Revision: 1.7 $'[11:-2]
import sys, os, string, Globals, Acquisition
from HelpUtil import HelpBase
from ObjectRef import ObjectRef
from ImageFile import ImageFile
from App.ImageFile import ImageFile
from Globals import HTMLFile
......
......@@ -84,67 +84,14 @@
##############################################################################
"""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
from DateTime import DateTime
from time import time
from os import stat
import Acquisition
class ImageFile(Acquisition.Explicit):
"""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
############################################################
#
# Eventually this module will go away!
#
############################################################
def __str__(self):
return '<IMG SRC="%s" ALT="%s">' % (self.__name__, self.title_or_id())
from App.ImageFile import ImageFile
......@@ -82,26 +82,55 @@
# 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
from BoboPOS import SimpleDB, TJar, SingleThreadedTransaction
import Globals
- Configure and open the database
- Establish the top-level object for ZPublisher
- Perform very high-level configuration tasks
"""
import OFS.Application
# We import BoboPOS before importing any other application
# modules. This is needed to assure that the right
# versions of Persistent etc get registered.
from BoboPOS import SimpleDB, TJar, SingleThreadedTransaction
import TreeDisplay.TreeTag
import Scheduler.Scheduler
import sys, os, string, Globals, OFS.Application
Globals.BobobaseName = '%s/Data.bbb' % Globals.data_dir
Globals.VersionNameName='Zope-Version'
# Setup support for broken objects:
import OFS.Uninstalled, BoboPOS.PickleJar
BoboPOS.PickleJar.PickleJar.Broken=OFS.Uninstalled.Broken
# 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)
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'):
quota=string.atoi(os.environ['ZOPE_DATABASE_QUOTA'])
......@@ -112,17 +141,5 @@ if os.environ.has_key('ZOPE_DATABASE_QUOTA'):
lambda x, quota=quota, otherdb=Bobobase._jar.db:
x + otherdb.pos > quota)
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 @@
__doc__='''Application support
$Id: Application.py,v 1.101 1999/04/27 23:49:46 amos Exp $'''
__version__='$Revision: 1.101 $'[11:-2]
$Id: Application.py,v 1.102 1999/04/29 19:21:29 jim Exp $'''
__version__='$Revision: 1.102 $'[11:-2]
import Globals,Folder,os,regex,sys,App.Product, App.ProductRegistry, misc_
......@@ -205,7 +205,7 @@ class Application(Globals.ApplicationDefaultPermissions, Folder.Folder,
__allow_groups__=UserFolder()
def _init(self):
def __init__(self):
# Initialize users
self.__allow_groups__=UserFolder()
self._setObject('acl_users', self.__allow_groups__)
......@@ -248,6 +248,8 @@ class Application(Globals.ApplicationDefaultPermissions, Folder.Folder,
Redirect=ZopeRedirect=PrincipiaRedirect
def __bobo_traverse__(self, REQUEST, name=None):
if hasattr(Globals,'VersionBase'):
# BoboPOS 2
if name is None and REQUEST.has_key(Globals.VersionNameName):
pd=Globals.VersionBase[REQUEST[Globals.VersionNameName]]
alternate_self=pd.jar[self._p_oid]
......@@ -257,6 +259,7 @@ class Application(Globals.ApplicationDefaultPermissions, Folder.Folder,
try: self._p_jar.cache.incrgc() # Perform incremental GC
except: pass
try: return getattr(self, name)
except AttributeError: pass
try: return self[name]
......@@ -264,6 +267,7 @@ class Application(Globals.ApplicationDefaultPermissions, Folder.Folder,
method=REQUEST.get('REQUEST_METHOD', 'GET')
if not method in ('GET', 'POST'):
return NullResource(self, name, REQUEST).__of__(self)
REQUEST.RESPONSE.notFoundError("%s\n%s" % (name, method))
def PrincipiaTime(self, *args):
......@@ -314,33 +318,11 @@ class Expired(Globals.Persistent):
__inform_commit__=__save__
def open_bobobase():
def initialize(app):
# 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')
__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
# which make sure that expected system objects are added to the
# bobobase. This is required because the bobobase in use may pre-
......@@ -376,8 +358,6 @@ def open_bobobase():
get_transaction().note('Product installations')
get_transaction().commit()
return Bobobase
def import_products(_st=type('')):
# Try to import each product, checking for and catching errors.
path_join=os.path.join
......
......@@ -83,7 +83,7 @@
#
##############################################################################
__doc__="""Copy interface"""
__version__='$Revision: 1.32 $'[11:-2]
__version__='$Revision: 1.33 $'[11:-2]
import sys, string, Globals, Moniker, tempfile, ExtensionClass
from marshal import loads, dumps
......@@ -383,9 +383,9 @@ class CopySource:
def _getCopy(self, container):
# Ask an object for a new copy of itself.
f=tempfile.TemporaryFile()
self._p_jar.export_file(self,f)
self._p_jar.exportFile(self._p_oid,f)
f.seek(0)
ob=container._p_jar.import_file(f)
ob=container._p_jar.importFile(f)
f.close()
return ob
......
......@@ -84,7 +84,7 @@
##############################################################################
"""DTML Document objects."""
__version__='$Revision: 1.22 $'[11:-2]
__version__='$Revision: 1.23 $'[11:-2]
from DocumentTemplate.DT_Util import InstanceDict, TemplateDict
from ZPublisher.Converters import type_converters
from Globals import HTML, HTMLFile, MessageDialog
......@@ -181,9 +181,17 @@ class DTMLDocument(DTMLMethod, PropertyManager):
return self.raise_standardErrorMessage(client, REQUEST)
if RESPONSE is None: return r
RESPONSE.setHeader('Last-Modified', rfc1123_date(self._p_mtime))
# Try to handle content types intelligently...
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)
return r
# We don't allow document to set headers
return decapitate(r, RESPONSE)
......
......@@ -90,7 +90,7 @@
and aquisition relationships via a simple interface.
"""
__version__='$Revision: 1.10 $'[11:-2]
__version__='$Revision: 1.11 $'[11:-2]
import Globals
......@@ -103,7 +103,7 @@ class Moniker:
def __init__(self, ob=None):
if ob is None: return
self.jar=ob._p_jar.name
self.jar=ob._p_jar.getVersion()
self.ids=[]
while 1:
if not hasattr(ob, '_p_oid'):
......@@ -122,8 +122,15 @@ class Moniker:
def bind(self):
"Return the real object named by this moniker"
if self.jar is None: jar=Globals.Bobobase._jar
if hasattr(Globals,'VersionBase'):
# 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
for n in self.ids:
o=jar[n]
......
......@@ -84,9 +84,9 @@
##############################################################################
__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 os, App.FactoryDispatcher, ts_regex, Products
......@@ -380,13 +380,13 @@ class ObjectManager(
if id is None: o=self
else: o=self._getOb(id)
f=Globals.data_dir+'/export.bbe'
o._p_jar.export_file(o,f)
o._p_jar.exportFile(o._p_oid,f)
return f
def manage_importHack(self, REQUEST=None):
"Imports a previously exported object from /var/export.bbe"
f=Globals.data_dir+'/export.bbe'
o=self._p_jar.import_file(f)
o=self._p_jar.importFile(f)
id=o.id
if hasattr(id,'im_func'): id=id()
self._setObject(id,o)
......@@ -403,13 +403,14 @@ class ObjectManager(
else: ob=self._getOb(id)
if download:
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-Disposition',
'inline;filename=%s.bbe' % id)
return f.getvalue()
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:
return MessageDialog(
title="Object exported",
......@@ -427,7 +428,7 @@ class ObjectManager(
file=os.path.join(INSTANCE_HOME, 'import', file)
if not os.path.exists(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)
id=ob.id
if hasattr(id, 'im_func'): id=id()
......
......@@ -83,7 +83,7 @@
#
##############################################################################
from ImageFile import ImageFile
from App.ImageFile import ImageFile
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
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
import Acquisition, sys, ts_regex, string, types, mimetools
import OFS.SimpleItem, re, quopri, rfc822
import Globals
from Scheduler.OneTimeEvent import OneTimeEvent
from ImageFile import ImageFile
from cStringIO import StringIO
#$Id: MailHost.py,v 1.41 1999/03/25 15:50:30 jim Exp $
__version__ = "$Revision: 1.41 $"[11:-2]
#$Id: MailHost.py,v 1.42 1999/04/29 19:21:31 jim Exp $
__version__ = "$Revision: 1.42 $"[11:-2]
smtpError = "SMTP Error"
MailHostError = "MailHost Error"
......@@ -172,15 +170,11 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
if not headers.has_key(requiredHeader):
raise MailHostError,"Message missing SMTP Header '%s'"\
% requiredHeader
Globals.Scheduler.schedule(OneTimeEvent(
Send,
(trueself.smtpHost, trueself.smtpPort,
Send(trueself.smtpHost, trueself.smtpPort,
trueself.localHost, trueself.timeout,
headers['from'], headers['to'],
headers['subject'] or 'No Subject', messageText
),
threadsafe=1
))
)
if not statusTemplate: return "SEND OK"
......@@ -233,14 +227,10 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
raise MailHostError,"Message missing SMTP Header '%s'"\
% requiredHeader
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['subject'] or 'No Subject', messageText
),
threadsafe=1
))
)
def simple_send(self, mto, mfrom, subject, body):
body="subject: %s\n\n%s" % (subject, body)
......
......@@ -83,11 +83,11 @@
#
##############################################################################
__doc__='''MailHost Product Initialization
$Id: __init__.py,v 1.13 1999/04/02 15:40:33 michel Exp $'''
__version__='$Revision: 1.13 $'[11:-2]
$Id: __init__.py,v 1.14 1999/04/29 19:21:31 jim Exp $'''
__version__='$Revision: 1.14 $'[11:-2]
import MailHost, SendMailTag
from ImageFile import ImageFile
from App.ImageFile import ImageFile
classes=('MailHost.MailHost',)
......
......@@ -148,24 +148,62 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
def __bobo_traverse__(self, REQUEST, 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)
if hasattr(ref, name): return dself, ref, getattr(ref, 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())
def manage_Save__draft__(self, remark, REQUEST=None):
"""Make version changes permanent"""
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:
REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main')
def manage_Discard__draft__(self, REQUEST=None):
'Discard changes made during the version'
try: db=self._jar.db()
except:
# BoboPOS 2
Globals.VersionBase[self._version].abort()
else:
# ZODB 3
db.abortVersion(self._version)
if REQUEST:
REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main')
......@@ -188,10 +226,14 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
raise 'Copy Error', (
"This object can only be copied through the web.<p>")
def getdraft(ob, version):
def getdraft(ob, jar):
if hasattr(ob,'aq_parent'):
return getdraft(ob.aq_self, version).__of__(
getdraft(ob.aq_parent, version))
if hasattr(ob,'_p_oid'):
ob=Globals.VersionBase[version].jar[ob._p_oid]
return getdraft(ob.aq_self, jar).__of__(getdraft(ob.aq_parent, jar))
if hasattr(ob,'_p_oid'): ob=jar[ob._p_oid]
return ob
class Cleanup: pass
......@@ -84,7 +84,7 @@
##############################################################################
"""Version object"""
__version__='$Revision: 1.29 $'[11:-2]
__version__='$Revision: 1.30 $'[11:-2]
import Globals, time
from AccessControl.Role import RoleManager
......@@ -133,7 +133,14 @@ class Version(Persistent,Implicit,RoleManager,Item):
def title_and_id(self):
r=Version.inheritedAttribute('title_and_id')(self)
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
def manage_edit(self, title, REQUEST=None):
......@@ -186,15 +193,39 @@ class Version(Persistent,Implicit,RoleManager,Item):
def save(self, remark, REQUEST=None):
"""Make version changes permanent"""
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)
def discard(self, REQUEST=None):
'Discard changes made during the version'
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)
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):
if isMove and self.nonempty():
......
......@@ -84,13 +84,12 @@
##############################################################################
__doc__='''Database Connection
$Id: DABase.py,v 1.7 1999/03/10 00:15:29 klm Exp $'''
__version__='$Revision: 1.7 $'[11:-2]
$Id: DABase.py,v 1.8 1999/04/29 19:21:32 jim Exp $'''
__version__='$Revision: 1.8 $'[11:-2]
from db import manage_DataSources
import Shared.DC.ZRDB.Connection, sys
from Globals import HTMLFile
from ImageFile import ImageFile
from ExtensionClass import Base
import Acquisition
......
......@@ -84,21 +84,21 @@
##############################################################################
__doc__='''Generic Database Adapter Package Registration
$Id: __init__.py,v 1.9 1999/03/10 00:15:29 klm Exp $'''
__version__='$Revision: 1.9 $'[11:-2]
$Id: __init__.py,v 1.10 1999/04/29 19:21:32 jim Exp $'''
__version__='$Revision: 1.10 $'[11:-2]
import Globals, ImageFile, os
import Globals, os
classes=('DA.Connection',)
database_type='Gadfly'
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',
'field', 'text','bin','int','float',
'date','time','datetime'):
misc_[icon]=ImageFile.ImageFile('icons/%s.gif' % icon, globals())
misc_[icon]=Globals.ImageFile('icons/%s.gif' % icon, globals())
meta_types=(
{'name':'Z %s Database Connection' % database_type,
......
......@@ -83,8 +83,8 @@
#
##############################################################################
'''$Id: db.py,v 1.6 1999/03/10 00:15:29 klm Exp $'''
__version__='$Revision: 1.6 $'[11:-2]
'''$Id: db.py,v 1.7 1999/04/29 19:21:32 jim Exp $'''
__version__='$Revision: 1.7 $'[11:-2]
import os
from string import strip, split
......@@ -206,6 +206,7 @@ class DB:
class _p_jar:
# 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 begin_commit(self, *args): pass
def finish_commit(self, *args): pass
......@@ -216,15 +217,25 @@ class DB:
def _register(self):
if not self._registered:
try:
get_transaction().register(self)
get_transaction().register(Surrogate(self))
self._registered=1
except: pass
def __inform_commit__(self, *ignored):
def tpc_begin(self, *ignored): pass
def tpc_commit(self, *ignored):
self.db.commit()
self._registered=0
def __inform_abort__(self, *ignored):
def tpc_abort(self, *ignored):
self.db.rollback()
self.db.checkpoint()
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
from ExtensionClass import Base
from App.FactoryDispatcher import FactoryDispatcher
from ComputedAttribute import ComputedAttribute
from ImageFile import ImageFile
from OFS.misc_ import p_
p_.ZClass_Icon=ImageFile('class.gif', globals())
p_.ZClass_Icon=Globals.ImageFile('class.gif', globals())
class PersistentClass(Base):
def __class_init__(self): pass
......
......@@ -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.
$Id: __init__.py,v 1.3 1999/03/22 17:45:37 jim Exp $'''
__version__='$Revision: 1.3 $'[11:-2]
$Id: __init__.py,v 1.4 1999/04/29 19:21:34 jim Exp $'''
__version__='$Revision: 1.4 $'[11:-2]
from ImageFile import ImageFile
import ZClass
# 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