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

Applying code changes on-the-fly using plone.reload

When a Zope instance is running in debug mode, most of the changes made in the underlying code (except for templates, Python scripts, and some other resources like CSS) won't be refreshed in the server until it is restarted. This means that if we want to test a new method or if we had detected a problem and solved it, we must restart our Zope server to see the results. At first glance, it doesn't seem to be a big deal. However, in the rush of development or when making lots of little changes in the code, this could really be a pain in the neck. This is especially true if we are working with a production database because they normally take a long time during server launch.

Fortunately , plone.reload can come to our rescue. In a fraction of a second it detects and refreshes all the changes made to the code. Moreover, if we had modified configuration options (not .py files but .zcml, as we'll see in future chapters), we can apply them on-the-fly also.

How to do it…

  1. Add a plone.reload line in the eggs parameter of the [buildout] part.
    [buildout]
    
    ...
    
    # Add additional eggs here 
    eggs = 
     plone.reload
    

How it works…

You just need to point your browser URL to http://localhost:8080/@@reload (notice that @@reload is called on Zope instance root and not on Plone site) and click on the corresponding button to:

  • Reload code (.py files).
  • Reload code and configuration options (.py and .zcml).

After doing this, you'll get a short log about the files that were detected during reload.

Note

plone.reload is available only when Zope is running in debug mode.

Unfortunately, plone.reload does not always work. If you find unexpected error messages (typically ComponentLookupError or could not adapt) in your console, it is most likely that plone.reload couldn't do the whole job properly. In these situations, just restart your instance to continue working.

There's more…

You may want to remember (or save a bookmark in your browser) the URL of the resulting action to speed up your code changes:

  • http://localhost:8080/@@reload?action=code, for code changes
  • http://localhost:8080/@@reload?action=zcml, for code and configuration changes

Note

More information about plone.reload is available at: http://pypi.python.org/pypi/plone.reload.

主站蜘蛛池模板: 遂昌县| 浠水县| 安龙县| 宣恩县| 玛多县| 梅河口市| 合江县| 文登市| 乡城县| 扎兰屯市| 平江县| 巴彦县| 政和县| 梅河口市| 上饶市| 沾化县| 绥棱县| 博客| 金溪县| 宜兰市| 理塘县| 醴陵市| 凤庆县| 乐东| 密云县| 若羌县| 蒙自县| 济宁市| 涟水县| 巧家县| 高安市| 霍城县| 肥城市| 吐鲁番市| 萨迦县| 桂阳县| 土默特左旗| 治县。| 金华市| 开鲁县| 理塘县|