官术网_书友最值得收藏!

Opening an online Python shell on Plone using Clouseau

If IPython already offers a great add-on for development, Clouseau takes us a step further with an AJAX-based Python shell interface integrated within our Plone site.

Note

Please be advised that Clouseau hasn't been updated since December 2008 and it has not been officially tested in Plone 3. However, it still works like a charm.

How to do it…

  1. Add the Products.Clouseau line in the eggs parameter of [buildout] part:
    [buildout]
    
    ...
    
    # Add additional eggs here 
    eggs = 
        iw.debug 
        Products.DocFinderTab
     Products.Clouseau
    
  2. Auto-install Clouseau during buildout: Add it to the products parameter in [plonesite] part if you want Clouseau to be automatically installed during the buildout process:
    [plonesite] 
    recipe = collective.recipe.plonesite 
    site-id = plone 
    instance = instance 
    products = 
     Clouseau
    
  3. Rebuild and re-start:
    ./bin/buildout
    ./bin/instance fg
    
  4. Open a new Clouseau session and once logged in you'll see at the bottom of any content on your Plone site a new link called python prompt. Click on it to open an online Python shell:
    How to do it…

As you see you can play with local variables bound to context, portal, Zope root, and so on. You can also use the Tab key to let Clouseau autocomplete your code.

Note

Clouseau is available only when running Zope in debug mode.

There's more…

In the site setup of your Plone portal, you can also find a new Clouseau configlet, where you can store or load sessions. Most importantly, however, is the recommendation you'll see to read online help. We want to share with you just a few tips:

  • Regarding security, users with "Manager" role can have access to a Clouseau shell only if the instance is in debug mode (read security is not an issue). Just in case, do not leave a public instance running in debug-mode.
  • Thanks to the already installed DocFinderTab product, Clouseau can show a comprehensive list of available properties and methods when typing commands in its shell.
  • To see other people's changes and to avoid conflict errors, you must run utils.sync().
  • If you plan to make permanent changes in your instance database from inside Clouseau, you must call the utils.commit() method.

For more information, visit the Clouseau help page at: http://localhost:8080/plone/clouseau_help.

Note

More information about Clouseau can be found at at: http://plone.org/products/clouseau.

主站蜘蛛池模板: 昌宁县| 水城县| 新津县| 阿拉善盟| 宜昌市| 城固县| 临沧市| 弥勒县| 甘泉县| 牟定县| 郓城县| 南开区| 南安市| 海林市| 威宁| 马山县| 托克托县| 乌恰县| 乐安县| 达尔| 遂川县| 榕江县| 响水县| 榆中县| 宝丰县| 潼南县| 宿迁市| 姜堰市| 增城市| 玉树县| 南开区| 沧州市| 蕲春县| 电白县| 遂溪县| 汉寿县| 甘洛县| 双牌县| 广州市| 开封县| 依兰县|