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

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.

主站蜘蛛池模板: 郎溪县| 开平市| 田阳县| 吴旗县| 通海县| 正定县| 贺兰县| 桃源县| 股票| 上杭县| 格尔木市| 宜都市| 贡觉县| 财经| 苍溪县| 政和县| 福建省| 徐闻县| 神木县| 宿州市| 双柏县| 施甸县| 晴隆县| 邛崃市| 德安县| 辽阳县| 饶阳县| 芜湖县| 寻乌县| 固安县| 广水市| 庆元县| 临潭县| 泗洪县| 玛多县| 侯马市| 遵义县| 民和| 金阳县| 专栏| 卫辉市|