Matthew X. Economou, on 2007-06-12:
> I have a very simple script that copies my production Zope instance to
> a fresh test instance. I have some Python code that I need to execute
> when the test instance starts for the first time (it only needs to
> execute once, but it won't hurt Zope if it executes every time the
> test instance starts. I usually execute this code interactively, from
> the Zope debugger:
> Is there any way to execute this code (or something similar)
> automatically? I guess the alternative is that I could script the
> process of entering the Zope debugger and running the above using
> Expect or something.
The first approach that spring to mind is hackish.
In your script that copies your production instance, add a line that
copies an extra product to the Products directory. That product
should probably be named 'ZZZHack' so that it gets loaded only at the
very end after all other products have been loaded.
Then you add a line like the above in the __init__.py of that product.
Second, probably better, approach that comes to mind: forget about
that Product. After you copied the instance, call:
bin/zopectl run setcache.py
where setcache.py only contains that line above I think. Maybe add
"import transaction; transaction.commit()" after that.
Maurits van Rees | http://maurits.vanrees.org/ [NL]
Work | http://zestsoftware.nl/
"Do not worry about your difficulties in computers,
I can assure you mine are still greater."
Zope maillist - Zope@zope.org
** No cross posts or HTML encoding! **
(Related lists -