[triangle-zpug] IPython-config(s) - for Plone & Zope debugging - Plone 2.5.x

Mark R. Biggers biggers at utsl.com
Tue Feb 12 19:18:26 UTC 2008


 Hi Erik,

 Here''s one way to use IPython, to "discover the API" for Plone
 and Zope -- to help write code for and debug a Plone-site...

 Enjoy!
 ----mark	Tue Feb 12 13:59:37 2008


 ------------ this is a Linux "shell recipe"  -----------------------------

 ## IPython-config(s) - for Plone & Zope debugging - tested for Plone 2.5.x

 # our "cluster" -- a (modified) Plone Unified-Installer buildout
 ZCLUS=/home/clients/myPloneSite

 cd $ZCLUS

 # ... Usually, I buildout a Plone Unif.Inst site with 'virtual-python'
 #     (or, use 'virtualenv')
 bin/easy_install ipython

 bin/ipython  # to test

 # Config IPython for "zope" user - or user doing the debugging
 cd ~/.ipython
 svn co http://svn.plone.org/svn/collective/dotipython/trunk/ .

 # (REF) '~/.ipython/ipy_profile_zope.py' for more details, on 'utils.*'

 # Go-to our Plone-site & run IPy on this Plone-site
 cd $ZCLUS
 client2/bin/zopectl shell
 bin/ipython -p zope

 #(REF) http://plone.org/documentation/how-to/setup-ipython-for-zope
 #
 #(REF) http://plone.org/documentation/how-to/view-an-objects-catalog-information

 ------------ this is a Linux "shell recipe"  -----------------------------


>> Here''s a run of Python on an actual Plone 2.5.5 site:

  /home/clients/dhl_galopp$  bin/ipython -p zope
  Activating auto-logging. Current session state plus future input saved.
  Filename       : /home/zope/.ipython/ipy.log
  Mode           : backup
  Output logging : False
  Raw input log  : False
  Timestamping   : False
  State          : active
  SOFTWARE_HOME=/usr/local/encap/Zope-2.9.8-final/lib/python
  CONFIG_FILE= /home/clients/dhl_galopp/client2/etc/zope.conf
  INSTANCE_HOME= /home/clients/dhl_galopp/client2

  ........ [ Zope/Plone startup stuff edited out] ........

  Permissive security installed
  ZOPE mode iPython shell.

    Bound names:
     app
     portal
     utils.{ cd,commit,cwd,getCatalogInfo,ls,objectInfo,pwd,su,sync }

  Uses the $SOFTWARE_HOME and $CONFIG_FILE environment
  variables.

  ZOPE Py 2.4.4 (#1, Aug 21 2007, 10:14:13)  IPy 0.8.2


  In [1]: portal
  Out[1]: <PloneSite at /QuizService>

  In [2]: from Products.CMFCore.utils import getToolByName

  In [3]: mtool = getToolByName(portal, 'portal_membership')

  In [4]: mtool
  Out[4]: <MembershipTool at /QuizService/portal_membership>

  In [5]: mtool.getMemberById('contentbob')
  Out[5]: <MemberData at /QuizService/portal_memberdata/contentbob used for /QuizService/acl_users>

  In [6]: mtool.getMemberInfo?
  Type:           instancemethod
  Base Class:     <type 'instancemethod'>
  String Form:    <bound method MembershipTool.getMemberInfo of <MembershipTool at /QuizService/portal_membership>>
  Namespace:      Interactive
  File:           /home/clients/dhl_galopp/client1/Products/CMFPlone/MembershipTool.py
  Definition:     mtool.getMemberInfo(self, memberId=None)
  Docstring:
      Return 'harmless' Memberinfo of any member, such as Full name,
      Location, etc




More information about the triangle-zpug mailing list