How to debug plone under Windows 10?

Is there something similar to bin\client1 debug?

My installation is as follows:

cd C:\Users\username\Plone-5.2.8-UnifiedInstaller-1.0
windows_install.bat 
    --password=admin 
    --target=C:\Users\username\Plone-5.2.8-zeo 
    --instance=zeocluster 
    --clients 2
      zeo

cd /d C:\Users\username\Plone-5.2.8-zeo\zeocluster
.\bin\zeoserver_runzeo.bat
...
.\bin\runwsgi.exe -dv parts/client1/etc/wsgi.ini

I've tried to use zconsole without success:

bin\zconsole debug parts/client1/etc/zeo.conf says Command line too long because Windows command line length limits.

mekell via Plone Community wrote at 2022-6-29 13:09 +0000:

Is there something similar to bin\client1 debug?

I do not see a reason why bin/client1 debug should not work
under Windows.

After installing with Plone-5.2.8-UnifiedInstaller-1.0 as described above there is simply no bin\client1

mekell via Plone Community wrote at 2022-6-29 15:08 +0000:

After installing with Plone-5.2.8-UnifiedInstaller-1.0 as described above there is simply no bin\client1

You can look at plone.recipe.zope2instance.ctl.ZopeCmd.do_debug.
It implements bin/client1 debug.
It essentially starts Python, imports configure_wsgi, applies it
to the configuration file, then import Zope2 and assigns app = Zope2.app().

Thanks for the hint. I'm trying to debug like zconsole which does pretty much the same:

import sys
sys.path=[ ... ] # <- here comes the necesary sys.path
from Zope2.utilities.zconsole import debug, debug_console
app = debug("parts\client1\etc\zope.conf")
debug_console

This also binds app = Zope2.app()

But I still have some problems importing win32file with the pywin32 and pypiwin32 paraphernalia.

@smcmahon: I wonder why bin\client1 is not installed via UnifiedInstaller in Windows?

mekell via Plone Community wrote at 2022-6-29 15:54 +0000:

...
@smcmahon: I wonder why bin\client1 is not installed via UnifiedInstaller in Windows?

It is generated by plone.recipe.zope2instance which depends on zdaemon.
When I remember right, then zdaemon is not available for Windows.

It seems that pywin32 must be pip-installed in Python 3.8 before the UnifiedInstaller creates its venv.

I removed Python 3.8 and installed it again, did pip install pywin32 and then windows_install.bat from UnifiedInstaller.

And then I created a file bin\my-zconsole.py with the following:

#!"c:\users\username\plone-5.2.8-zeo\py-3.8.10.final.0\scripts\python.exe"
import sys
sys.path[0:0] = [ ...  ] # <- put here the same sys.path as in "bin\runwsgi-script.py"
from Zope2.utilities.zconsole import debug, debug_console
if __name__ == '__main__':
    print("binding app ...")
    app = debug("parts\client2\etc\zope.conf")
    print("app bound.")
    debug_console

which I call with

python -i bin\my-zconsole.py

And it debugs like a charm.

I wrote a recipe for using IPython via zconsole to debug Plone (5.2.8) which works for Linux and Windows 10. See Using IPython with Plone. The buildout configation file is as follows:

[buildout]
extends =
    develop.cfg
eggs +=
    ipython
parts +=
    ipython-zconsole2

[ipython-zconsole2]
recipe = zc.recipe.egg
eggs =
    ipython
    ${client2:eggs}
initialization =
    from Zope2.utilities.zconsole import debug
    print('Binding app via "Zope2.utilities.zconsole.debug()" ...')
    app = debug('parts/client2/etc/zope.conf')
    print('Starting "IPython.embed()" ...')
entry-points = ipython-zconsole2=IPython:embed

[versions]
ipython = 8.4.0
prompt-toolkit = 3.0.30

should it be --clients=2 ?

@espenmn: Of course not. It could perfectly be client1 or have one single client (like in a standalone installation). In such a case you should rename client2 and the paths to whatever you need (client1 or instance etc.)

In my case I use client1 for the browser view and client2 for debugging.

This is why my example (see Using IPython with Plone) assumes a zeo Plone installation with 2 clients and client2 will be used for IPython.

Sorry for my ignorance, but what does the line:

--clients 2

in your install script do?

@espenmn: The optional argument --clients is used by the UnifiedInstaller to specify the number of Zope clients you wish to create. This is the default if you create a Plone instance of type zeo. Please refer to the UnifiedInstaller Windows Documentation. This optional parameter is also available in the Linux installation.

Using two clients can be very usefull if you want to debug or run scripts on Plone and want to see the results in the browser. Or when you make changes in the Browser and want to inspect the changes in the backend. In such cases you start a client to serve the browser's requests and a second client to run scripts or debug. This is why my buildout uses client2, leaving client1 "unchanged" for listening to browser's requests.

Please keep in mind that strictly seen you will only actually debug the processes from the client your scripts are running on. Not the processes from the another client!

I thought that the default clients is 2, so no need to specify it.

If you specify it, I thought the syntax would be --clients=2, not --clients 2

@espenmn: Oops. You're right. It's a typo. Of course it should be --clients=2.

It just worked because the default is also 2. :wink: