Commit e2c73f8b authored by Evan Simpson's avatar Evan Simpson

Refactor REPLACEABLE constants into Globals, to allow them to be used

without circular import problems.  Factor out manage_importObject's guts.
parent a8be7c02
...@@ -85,7 +85,12 @@ ...@@ -85,7 +85,12 @@
"""Global definitions""" """Global definitions"""
__version__='$Revision: 1.48 $'[11:-2] __version__='$Revision: 1.49 $'[11:-2]
# Global constants: __replaceable__ flags:
NOT_REPLACEABLE = 0
REPLACEABLE = 1
UNIQUE = 2
import Acquisition, ComputedAttribute, App.PersistentExtra, os import Acquisition, ComputedAttribute, App.PersistentExtra, os
import TreeDisplay, string import TreeDisplay, string
......
...@@ -84,15 +84,16 @@ ...@@ -84,15 +84,16 @@
############################################################################## ##############################################################################
__doc__="""Object Manager __doc__="""Object Manager
$Id: ObjectManager.py,v 1.143 2001/10/26 15:11:59 andreasjung Exp $""" $Id: ObjectManager.py,v 1.144 2001/11/13 19:31:50 evan Exp $"""
__version__='$Revision: 1.143 $'[11:-2] __version__='$Revision: 1.144 $'[11:-2]
import App.Management, Acquisition, Globals, CopySupport, Products import App.Management, Acquisition, Globals, CopySupport, Products
import os, App.FactoryDispatcher, re, Products import os, App.FactoryDispatcher, re, Products
from OFS.Traversable import Traversable from OFS.Traversable import Traversable
from Globals import DTMLFile, Persistent from Globals import DTMLFile, Persistent
from Globals import MessageDialog, default__class_init__ from Globals import MessageDialog, default__class_init__
from Globals import REPLACEABLE, NOT_REPLACEABLE, UNIQUE
from webdav.NullResource import NullResource from webdav.NullResource import NullResource
from webdav.Collection import Collection from webdav.Collection import Collection
from Acquisition import aq_base from Acquisition import aq_base
...@@ -111,11 +112,6 @@ customImporters={ ...@@ -111,11 +112,6 @@ customImporters={
bad_id=re.compile(r'[^a-zA-Z0-9-_~,.$\(\)# ]').search #TS bad_id=re.compile(r'[^a-zA-Z0-9-_~,.$\(\)# ]').search #TS
# Global constants: __replaceable__ flags:
NOT_REPLACEABLE = 0
REPLACEABLE = 1
UNIQUE = 2
BadRequestException = 'Bad Request' BadRequestException = 'Bad Request'
def checkValidId(self, id, allow_dup=0): def checkValidId(self, id, allow_dup=0):
...@@ -569,13 +565,23 @@ class ObjectManager( ...@@ -569,13 +565,23 @@ class ObjectManager(
software_home = os.path.join(SOFTWARE_HOME, '..%s..' % os.sep) software_home = os.path.join(SOFTWARE_HOME, '..%s..' % os.sep)
software_home = os.path.normpath(software_home) software_home = os.path.normpath(software_home)
for impath in (instance_home, software_home): for impath in (instance_home, software_home):
filepath = os.path.join(impath, 'import', file) filepath = os.path.join(impath, 'import', file)
if os.path.exists(filepath): if os.path.exists(filepath):
break break
else: else:
raise BadRequestException, 'File does not exist: %s' % file raise BadRequestException, 'File does not exist: %s' % file
self._importObjectFromFile(filepath, verify=not not REQUEST,
set_owner=set_owner)
if REQUEST is not None:
return self.manage_main(self, REQUEST,
manage_tabs_message='<em>%s</em> sucessfully imported' % id,
title = 'Object imported',
update_menu=1)
def _importObjectFromFile(self, filepath, verify=1, set_owner=1):
# locate a valid connection # locate a valid connection
connection=self._p_jar connection=self._p_jar
obj=self obj=self
...@@ -585,9 +591,7 @@ class ObjectManager( ...@@ -585,9 +591,7 @@ class ObjectManager(
connection=obj._p_jar connection=obj._p_jar
ob=connection.importFile( ob=connection.importFile(
filepath, customImporters=customImporters) filepath, customImporters=customImporters)
if REQUEST: self._verifyObjectPaste(ob, validate_src=0) if verify: self._verifyObjectPaste(ob, validate_src=0)
#id=ob.getId()
#can't use above getId() call, it fails on 'old' exported objects
id=ob.id id=ob.id
if hasattr(id, 'im_func'): id=id() if hasattr(id, 'im_func'): id=id()
self._setObject(id, ob, set_owner=set_owner) self._setObject(id, ob, set_owner=set_owner)
...@@ -597,13 +601,6 @@ class ObjectManager( ...@@ -597,13 +601,6 @@ class ObjectManager(
ob=self._getOb(id) ob=self._getOb(id)
ob.manage_changeOwnershipType(explicit=0) ob.manage_changeOwnershipType(explicit=0)
if REQUEST is not None:
return self.manage_main(self, REQUEST,
manage_tabs_message='<em>%s</em> sucessfully imported' % id,
title = 'Object imported',
update_menu=1)
# FTP support methods # FTP support methods
def manage_FTPlist(self, REQUEST): def manage_FTPlist(self, REQUEST):
......
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