[Zope] Tip: do scheduled site imports using load_site.py
Maarten Slaets
maarten.slaets@kpnqwest.com
Mon, 07 Feb 2000 11:06:23 +0100
This is a multi-part message in MIME format.
--------------826187E260EF3BA68E2AF423
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Problem:
--------
You have a certain directory structure that needs to be imported into zope
every day. If you just put
python z-load_site.py -p /usr/local/Zope/lib/python/ZPublisher -u
user:password -v http://zope.site/dir /localdir/*
in your crontab, it will fail the second time it runs, because it tries to
import objects with id names that are already existing.
Solution:
---------
One solution could be to wrap the manage_add calls to catch these exceptions
(Oleg-way:-). I didn't succeed in doing that, but I found another solution
already built into Zope:
modify 'def _checkId(self, id, allow_dup=0)' in
'/lib/python/OFS/ObjectManager.py' to 'def _checkId(self, id, allow_dup=1)'
This auto-overwrites existing objects with the same name.
Only drawback: if you upload a directory that way, the existing one is
removed + all its contents at that time.
Hope this can be useful.
PS: I've attached a patch for ObjectManager.py for Zope 2.0.1 (yeah I know,
it's old). To use it:
patch -iObjectManager.py.diff ObjectManager.py
you may need to modify '-iObjectManager.py.diff' to point to another
directory...
--
Maarten Slaets
Web Developer
KPNQwest Belgium
http://www.fonky.com/vcard/MaartenSlaets/
--------------826187E260EF3BA68E2AF423
Content-Type: text/plain; charset=us-ascii;
name="ObjectManager.py.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ObjectManager.py.diff"
194c194
< def _checkId(self, id, allow_dup=0):
---
> def _checkId(self, id, allow_dup=1):
--------------826187E260EF3BA68E2AF423--