[ZCM] [ZC] 1471/ 3 Reject "Attempt to store an object from a
foreign database connection"
Collector: Zope Bugs, Features,
and Patches ...
zope-coders-admin at zope.org
Thu Aug 19 02:41:20 EDT 2004
Issue #1471 Update (Reject) "Attempt to store an object from a foreign database connection"
Status Rejected, Zope/bug medium
To followup, visit:
http://zope.org/Collectors/Zope/1471
==============================================================
= Reject - Entry #3 by chrisw on Aug 19, 2004 2:41 am
Status: Pending => Rejected
The collector is not the place for discussions.
That error message is telling you your scripts are doing something bad.
Please ask on the zope at zope.org mailing list.
________________________________________
= Comment - Entry #2 by Goyvaerts on Aug 18, 2004 8:18 am
This problem happen on Zope 2.7.2 installed in Windows XP
________________________________________
= Request - Entry #1 by Goyvaerts on Aug 18, 2004 8:12 am
Hello,
In the previous version of Zope (like : 2.4.2), I used two
external methods to make entire backup and restore of all the
Zope documents, see : the source script and procedure below.
I install Zope 2.7.2 and then add my two external methods as
usual to restore all my application from the previous version (2.4.2).
It works very well but when I try to use the backup method I
receive the following error :
Attempt to store an object from a foreign database connection
Is it a bug or some modified functionality of Zope ?
At your service for more information.
Thierry
Thierry.Goyvaerts at skynet.be
Procedure to install and use the full backup/restore methods :
Create a module, backup.py, with the contents of the source
(given in the tied code file) within the Extensions directory of your
e-Solution instance.
Create two external methods, "restore" and "backup" in your root
folder by pointing them at Extensions/backup.py -> restore
and Extensions/backup.py -> backup.
After creating the two external methods, protect each of them
with a management-level permission.
To back up your e-Solution, visit the "test" tab of the backup
external method. A file named "e-Solution_backup.zexp" will be
downloaded to your local machine via your browser.
To restore your e-solution, place the "e-Solution_backup.zexp"
file in the "import" directory of your e-Solution instance, and
press the "test" tab of the restore external method. Be careful,
this overwrites anything that exists with the same name.
Note that the "zexp" file created by 'backup' may not successfully
be imported using the standard import feature, it needs to be
imported via the "restore" external method.
Source file Extensions\backup.py :
import Globals
import os
from Acquisition import aq_base
from cStringIO import StringIO
from Globals import MessageDialog
from ZODB.PersistentMapping import PersistentMapping
def backup(self, REQUEST=None, download=1, filename='e-Solution_backup.zexp'):
""" saves backup file to var or allows download of backup file"""
if download: f = StringIO()
else: f = os.path.join(Globals.data_dir, filename)
self.c = PersistentMapping()
for k, v in self.objectItems(): self.c[k] = aq_base(v)
get_transaction().commit()
self.c._p_jar.exportFile(self.c._p_oid, f)
del self.c
if download:
REQUEST.RESPONSE.setHeader('Content-type', 'application/data')
REQUEST.RESPONSE.setHeader('Content-Disposition',
'inline;filename=%s' % filename)
return f.getvalue()
else:
return MessageDialog(
title="e-Solution backed up successfully",
message="<EM>All items in root</EM> sucessfully\
exported to <pre>%s</pre>." % f,
action="manage_main")
def restore(self, REQUEST=None, filename='e-Solution_backup.zexp'):
""" restores backup file from 'import' """
dirname, file=os.path.split(filename)
if dirname:
raise 'Bad Request', 'Invalid file name %s' % filename
instance_home = INSTANCE_HOME
software_home = os.path.join(SOFTWARE_HOME, '..%s..' % os.sep)
software_home = os.path.normpath(software_home)
for impath in (instance_home, software_home):
filepath = os.path.join(impath, 'import', filename)
if os.path.exists(filepath):
break
else:
raise 'Bad Request', 'File does not exist: %s' % filename
conn = self._p_jar
ob = conn.importFile(filepath)
for k, v in ob.items():
try: self._delObject(k)
except AttributeError: pass
self._setObject(k, v)
return MessageDialog(
title="e-Solution restored successfully",
message="All items from <EM>%s</EM> sucessfully\
imported into <pre>root</pre>." % filepath,
action="manage_main")
==============================================================
More information about the Zope-Collector-Monitor
mailing list