[Zope-dev] Importing into ZODB AND updating

Grakka jflores@codeit.com
Mon, 17 Apr 2000 13:37:34 -0700


Can anyone provide help about importing an exported  ZODB (ZEXP)  file
and UPDATE any objects that are newer to the existing ones?

Right now, when ZOPE (ObjectManager.py) finds that another record with
the same ID, it raises an exception "Object Is Already In Use", but I
want to update it instead..... In both the ZODB and the ZEXP file, each
object contains the 8-byte serial, which is the TimeStamp of the last
modified date of the object, I can access the TimeStamp of the ID
located in ZODB, but I do not know how to access the TimeStamp serial on
the IMPORTED file, here is a chunk of code from ObjectManager.py

    def _checkId(self, id, object, allow_dup=0):
        # If allow_dup is false, an error will be raised if an object
        # with the given id already exists. If allow_dup is true,
        # only check that the id string contains no illegal chars.
        if not id:
            raise 'Bad Request', 'No id was specified'
        if bad_id(id) != -1:
            raise 'Bad Request', (
            'The id %s contains characters illegal in URLs.' % id)
        if id[0]=='_': raise 'Bad Request', (
            'The id %s  is invalid - it begins with an underscore.'  %
id)
        if not allow_dup:
            if hasattr(self, 'aq_base'):
                self=self.aq_base
----------->>>            if hasattr(self, id):
----------->>>                #self._getOb(id)._p_serial has the ZODB
(not the export) timestamp
----------->>>                #object._p_serial yields the same result
as above..
----------->>>                raise 'Bad Request', (
----------->>>                    'The id %s is invalid - it is already
in use' % id))


-------------snip-------------

On the parameter definition, "object" is defined:

        ob=self._p_jar.importFile(file)

My understanding is that the importFile module first "places" all the
exporte file in the ZODB database, but makes the objects "unreachable
[??]" until it checks for dupes ans so on..

I know this mail is long enough but if you read this far I want to thank
you in advance :)

Julio