[Zope3-dev] Re: Replacing class refs in ZODB
Derrick Hudson
dman at dman13.dyndns.org
Fri Feb 18 12:31:59 EST 2005
On Fri, Feb 18, 2005 at 11:59:04AM -0500, Jim Fulton wrote:
| Garrett Smith wrote:
| >Jim Fulton wrote:
| >>Garrett Smith wrote:
| >>
| >>>Rather than leave aliases around forever, is there a utlity (or other
| >>>means) one can use to update references to renamed/moved classes in
| >>>the ZODB?
| >>
| >>Not currently. We'd like a cleaner mechanism, but haven't come up
| >>with one yet.
| >So I take it this is non-trivial. I was hoping it would boil down to a
| >search-and-release in the Data.fs.
|
| It depends on what "this" is. One could fairly straightforwardly
| write a script that could convert an off-line database. I think we
| really want to be able to do this without taking the database off-line.
I tried to do this as a step to solve a problem I had about two weeks
ago. It didn't work, though.
#!/usr/bin/python2.3 -i
from ZODB import FileStorage, DB
storage = FileStorage.FileStorage( 'Data.fs' )
db = DB(storage)
conn = db.open()
root = conn.root()
app = root['Application']
import zwiki, zwiki.wiki
# setup the alias for the initial load
sys.modules['zope.app.wiki'] = zwiki
the_wiki = app.data['the_wiki']
the_wiki.__class__ = zwiki.wiki.Wiki
the_wiki._p_changed = True
# save the changes:
import transaction ; transaction.commit()
The ZODB (probably pickle, actually) would complain that it didn't
like the object. I think it is because I changed the class, so some
sanity check failed. In hindsight I think it is the same error I had
recently with my singleton pattern and Zope2.
If someone has some pointers for me I'm willing to read (docs, code)
and experiment.
-D
--
"Piracy is not a technological issue. It's a behavior issue."
--Steve Jobs
www: http://dman13.dyndns.org/~dman/ jabber: dman at dman13.dyndns.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20050218/8b106749/attachment.bin
More information about the Zope3-dev
mailing list