/usr/share/pyshared/zope/app/appsetup/debug.txt is in python-zope.app.appsetup 3.16.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | Debug console
=============
The debug console lets you have a Python prompt with the full Zope
environment loaded (which includes the ZCML configuration, as well as an open
database connection).
Let's define a helper to run the debug script and trap SystemExit exceptions
that would otherwise hide the output
>>> import sys
>>> from zope.app.appsetup import debug
>>> def run(*args):
... sys.argv[0] = 'debug'
... sys.stderr = sys.stdout
... try:
... debug.main(args)
... except SystemExit, e:
... print "(exited with status %d)" % e.code
If you call the script with no arguments, it displays a brief error message
on stderr
>>> run()
Error: please specify a configuration file
For help, use debug -h
(exited with status 2)
We need to pass a ZConfig configuration file as an argument
>>> run('-C', 'test.conf')
The application root is known as `root`.
Now you have the root object from the open database available as a global
variable named 'root' in the __main__ module:
>>> main_module = sys.modules['__main__']
>>> main_module.root # doctest: +ELLIPSIS
<zope.site.folder.Folder object at ...>
and we have asked Python to enter interactive mode by setting the
PYTHONINSPECT environment variable
>>> import os
>>> os.environ.get('PYTHONINSPECT')
'true'
We have to do extra work to honor the PYTHONSTARTUP environment variable:
>>> pythonstartup = os.path.join(os.path.dirname(debug.__file__),
... 'testdata', 'pythonstartup')
>>> os.environ['PYTHONSTARTUP'] = pythonstartup
>>> run('-C', 'test.conf')
The application root is known as `root`.
You can see that our pythonstartup file was executed because it changed
the prompt
>>> sys.ps1
'debug> '
|