[Zope] Tip: do scheduled site imports using load_site.py
Maarten Slaets
zope@zope.org, maarten@slaets.net
Mon, 07 Feb 2000 16:04:41 +0100
Maarten Slaets wrote:
>
> 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/
>
> ----------------------------------------------------------------------------
>
> ObjectManager.py.diffName: ObjectManager.py.diff
> Type: Plain Text (text/plain)
--
Maarten Slaets
Web Developer
KPNQwest Belgium
http://www.fonky.com/vcard/MaartenSlaets/