Thursday, April 9, 2009

Creating a separate instance for debugging

Make debugging Zope/Plone more fun using a live environment!

Update: A separate config file for a two-instance setup



You may want to use the file below to create a two-instances setup from a very basic config file. In this case, my config extends dvl.cfg, which is a single-instance, non-cluster setup. It's important that this buildout have an [instance] section. (Almost all simple buildouts, notably those created by paster, do.)

Contents of dvl-debug.cfg:

# Development setup with separate instance for debugging

[buildout]
extends = dvl.cfg

parts +=
zeoserver
debug-instance

[zeoserver]
recipe = plone.recipe.zope2zeoserver
zope2-location = ${zope2:location}
zeo-address = 127.0.0.1:8000

[instance]
recipe = collective.recipe.zope2cluster
instance-clone = instance
zeo-client = true
zeo-address = ${zeoserver:zeo-address}

[debug-instance]
recipe = collective.recipe.zope2cluster
instance-clone = instance
http-address = 8081


Original post



I recently modified my buildout-dvl.config to read
[buildout]
# I have some base configuration in another file
extends = buildout-base.cfg

eggs +=
plone.reload
Products.DocFinderTab

parts +=
zeoserver
instance0
instance1

[zeoserver]
recipe = plone.recipe.zope2zeoserver
zope2-location = ${instance-settings:zope2-location}
zeo-address = ${instance-settings:zeo-address}

[instance-settings]
# Most instance-settings are defined in my buildout-base.cfg
zeo-address = 127.0.0.101:8000

[instance0]
# My development instance
recipe = collective.recipe.zope2cluster
instance-clone = instance-settings
http-address = 5432

debug-mode = on
verbose-security = on

zcml =
plone.reload

[instance1]
# My debugging instance
recipe = collective.recipe.zope2cluster
instance-clone = instance-settings
http-address = 8101

Where buildout-base.cfg contains, among other things:
[instance-settings]
recipe = plone.recipe.zope2instance
zope2-location = ${zope2:location}
user = zope-prd:secret
effective-user = zope-prd
zeo-client = True
zeo-address = 192.168.62.39:8000

Just fire up your debugging instance: ./bin/instance1 debug. Change something, using only Python code, save it by doing import transaction; transaction.commit() and watch your changes take effect in your live environment.

No comments: