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:
> app.restrictedTraverse("/irtnog/portal_cache_settings").setCacheConfig
> ('zope')
> 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 of that product.

Second, probably better, approach that comes to mind: forget about
that Product.  After you copied the instance, call:

  bin/zopectl run

where only contains that line above I think.  Maybe add
"import transaction; transaction.commit()" after that.

Maurits van Rees | [NL]
            Work |
"Do not worry about your difficulties in computers,
 I can assure you mine are still greater."

Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to