[Zope-Checkins] CVS: Packages/OFS - Application.py:1.160.12.2
Evan Simpson
evan@zope.com
Mon, 26 Nov 2001 10:47:31 -0500
Update of /cvs-repository/Packages/OFS
In directory cvs.zope.org:/tmp/cvs-serv15878/OFS
Modified Files:
Tag: evan-examples-branch
Application.py
Log Message:
Don't commit a transaction unless we wrote something.
=== Packages/OFS/Application.py 1.160.12.1 => 1.160.12.2 ===
# Install the replaceable standard objects
std_dir = os.path.join(Globals.package_home(globals()), 'standard')
+ wrote = 0
for fn in os.listdir(std_dir):
base, ext = os.path.splitext(fn)
if ext == '.dtml':
ob = Globals.DTMLFile(base, std_dir)
fn = base
- if not hasattr(app, fn):
- app.manage_addProduct['OFSP'].manage_addDTMLMethod(
- id=fn, file=open(ob.raw))
+ if hasattr(app, fn):
+ continue
+ app.manage_addProduct['OFSP'].manage_addDTMLMethod(
+ id=fn, file=open(ob.raw))
elif ext in ('.pt', '.zpt'):
ob = PageTemplateFile(fn, std_dir, __name__=fn)
- if not hasattr(app, fn):
- app.manage_addProduct['PageTemplates'].manage_addPageTemplate(
- id=fn, title='', text=open(ob.filename))
-
+ if hasattr(app, fn):
+ continue
+ app.manage_addProduct['PageTemplates'].manage_addPageTemplate(
+ id=fn, title='', text=open(ob.filename))
+ wrote = 1
ob.__replaceable__ = Globals.REPLACEABLE
setattr(Application, fn, ob)
-
- get_transaction().note('Installed standard objects')
- get_transaction().commit()
+ if wrote:
+ get_transaction().note('Installed standard objects')
+ get_transaction().commit()
def reinstall_product(app, product_name):
folder_permissions = get_folder_permissions()