April 24, 2021How to Test Log Output With zope.testrunnerHow to test log output with zope.testrunner? While pytest makes it very easy to work with log files via the caplog fixture, I was not aware how to test them with zope.testrunner, which is used for almost all Zope repositories. When I asked during yesterday’s Zope sprint, I got no answer. But coincidentally, I stumbled upon a broken doctest which… tests the log output of a function! So… thanks for failing… I guess :-)...
April 19, 2021How Many Zope Repositories Are Compatible With Pypy?Today, Johannes Raggam asked on the Plone/Zope community forum whether Zope is able to run on PyPy. While I am not entirely sure, and I have some vague memories about potential problems with RestrictedPython, I can certainly grep the almost 300 Zope repositories for signs of PyPy support. The best sign of PyPy support is IMHO that we run tests for it :-) In order to grep in all repositories I use all-repos written by Anthony Sottile....
February 15, 2021What Is the Difference Between Transaction Abort and Transaction DoomZope is using the transaction package to manage - you guess - transactions. More specifically, a transaction starts when Zope receives a request, and the transaction succeeds when the action triggered by the request works out. When the action causes an exception, the transaction will be rolled back. This means, usually you very rarely have to interfere with the transaction management manually. Last week I was implementing a new XML-RPC API, which basically looks like the following code:...
October 28, 2020How to Update All Zope Repositories at OnceMost or even all zopefoundation repositories use Travis for CI (As of May 2021, this is no longer true: we use GitHub Actions now). While Travis offered Python 3.9 as a dev version (3.9-dev) for quite some time, support for 3.9 final took a while. That’s why we decided to run Travis with Python 3.9-dev. Meanwhile Travis finally offers support for Python 3.9 final, so we have to update all repositories, which would be super tedious by hand....
October 9, 2020How to Access via WebDavWebDav is a protocol, based on top of HTTP, that allows clients remote content authoring, such as creating, editing and deleting content. The protocol itself is pretty old, dating back to the late 90ies. While not really popular, even modern systems like NextCloud, OwnCloud, and also the widely-used NAS systems by Synology do support this standard - and also Zope! How to activate WebDav support in Zope? The WebDav support in Zope had been temporarily removed, as Zope switched from the legacy ZServer to the standard WSGI approach, and WebDav was coupled to the ZServer, for no obvious reasons....
October 5, 2020How to Develop Dependencies With BuildoutGiven you have a decent sized project, with some dependencies… How can you develop and test a dependency against your main project, when it is not yet published on PyPi? Well, until recently, I relied on a strong test suite and mostly developed “blindly”. When I wanted to see the result, I used Vim to directly edit the dependency in my virtual env. There must be a better way And actually, there is and has been for more than a decade....
September 29, 2020How to Setup Zope in Dev ModeHow to setup Zope in development mode? git clone git@github.com:zopefoundation/Zope.git cd Zope python3.8 -m venv .venv . .venv/bin/activate pip install -U pip pip install -e .[wsgi] -c https://zopefoundation.github.io/Zope/releases/master/constraints.txt … where -e means editable, ie. developer mode the dot in .[wsgi] means here (similar to cd .. in bash) and [wsgi] means install the wsgi extras, which turns out to be Paste -c adds a constraints file, ie the versions of dependencies get pinned there After the installation, you need to configure Zope before you can run it, cf https://zope....
September 28, 2020How to Run a Single TestWhile this seems to be no Zope specific question, as we all know how to narrow down the test selection with pytest (e.g. pytest -k pattern), Zope does not use pytest, but zope.testrunner. Similar to pytest, also zope.testrunner offers some command line options, see https://zopetestrunner.readthedocs.io/en/latest/getting-started.html#some-useful-command-line-options-to-get-you-started This means, in order to run a specific test, you can use the -t flag, which takes one or more regex expressions as input, e.g. -t some_test....
July 23, 2020Why Is Setuptools a Runtime Dependency… or in other words… Why is this snippet part of setup.py in all Zope projects? install_requires = 'setuptools', This sounds weird at first, but there is good reason. setuptools provides pkg_resources, and the latter is used in __init__.py, in order to declare a namespace package. __import__('pkg_resources').declare_namespace(__name__) Still confused? While pkg_resources-style namespace packages are no longer recommended for new projects, this approach was used to split large packages, and retrieve the contents from more than one location....
April 11, 2020How to Replace the Old With the New Decorator Syntax for Zope's Security DeclarationsZope’s security architecture is built upon security declarations, which scope can be either a method, several methods or even a complete class. Until recently you usually declared the security for a method like this… from AccessControl import getSecurityManager class Suggestions(SomeBaseClass): security = ClassSecurityInfo() security.declareProtected("View", "all_suggestions") def all_suggestions(): ... Then, when accessing this method, e.g. the logged in user’s role or group was checked against the security declaration. One big disadvantage was that you could easily introduce typos....