[Zope] Using IPython for debugging Zope

Jean Jordaan jean at upfrontsystems.co.za
Tue Sep 28 04:40:49 EDT 2004


Hi all

I just figured this out a couple of days ago. It is VERY cool.

"""
  $ ./bin/zopectl debug
Starting debugger (the name "app" is bound to the top-level Zope object)
[...]
 >>>
 >>> import IPython
 >>> IPython.Shell.IPShell().mainloop(sys_exit=1)
Python 2.3.3 (#1, Mar 17 2004, 01:31:20)
Type "copyright", "credits" or "license" for more information.

IPython 0.6.3 -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
@magic  -> Information about IPython's 'magic' @ functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [3]: @autocall
Automatic calling is: OFF

In [4]: app = __IP.internal_ns['app']

In [5]: app
Out[5]: <Application instance at 411d1470>

In [14]: app.plone.object  # Tab-completion ... rooooocks!
app.plone.objectIds              app.plone.objectMap
app.plone.objectIds__roles__     app.plone.objectMap_d
app.plone.objectIds_d            app.plone.objectValues
app.plone.objectItems            app.plone.objectValues__roles__
app.plone.objectItems__roles__   app.plone.objectValues_d
app.plone.objectItems_d

In [14]: app.plone.object

In [15]: app.plone.objectIds??
Type:           Python Method
Base Class:     <type 'function'>
String Form:    <bound method PloneSite.objectIds of <PloneSite instance 
at 411bdd70>>
Namespace:      Interactive
File:           /home/jean/Zope-2.7.1-0/lib/python/OFS/ObjectManager.py
Definition:     app.plone.objectIds(self, spec=None)
Source:
def objectIds(self, spec=None):
         # Returns a list of subobject ids of the current object.
         # If 'spec' is specified, returns objects whose meta_type
         # matches 'spec'.
         if spec is not None:
             if type(spec)==type('s'):
                 spec=[spec]
             set=[]
             for ob in self._objects:
                 if ob['meta_type'] in spec:
                     set.append(ob['id'])
             return set
         return [ o['id']  for o in self._objects ]
"""

Is anyone else using this?

-- 
Jean Jordaan
http://www.upfrontsystems.co.za


More information about the Zope mailing list