Personal tools
Skip to content. | Skip to navigation
An easy way to create custom Zope 3 sources.
Programmable web browser for functional black-box testing of web applications
The zc.testbrowser package provides web user agents (browsers) with programmatic interfaces designed to be used for testing web applications, especially in conjunction with doctests. There are currently two type of testbrowser provided. One for accessing web sites via HTTP (zc.testbrowser.browser) and one that controls a Firefox web browser (zc.testbrowser.real). All flavors of testbrowser have the same API.
The thread-creation API provided by the Python threading module is annoying. :) This package provides a very simple thread-creation API that: Makes threads daemonic and allows daemonicity to be passed to the constructor. For example: zc.thread.Thread(mythreadfunc) Starts a daemonic thread named 'mythreadfunc' running mythreadfunc. Allows threads to be defined via decorators, as in: import zc.thread @zc.thread.Thread def mythread(): ... In the example above, a daemonic thread named mythread is created and started. The thread is also assigned to the variable mythread. You can control whether threads are daemonic and wether they are started by default: import zc.thread @zc.thread.Thread(daemon=False, start=False) def mythread(): ... After a thread finishes, you can get the return value of the target function from the thread's value attribute, or, if the function raises an exception, you can get the exception object from the thread's exception attribute. (This feature was inspired by the same feature in gevent greenlets.) There's also a Process constructor/decorator that works like Thread, but with multi-processing processes, and without the value and exception attributes.
Twist: Talking to the ZODB in Twisted Reactor Calls The twist package contains a few functions and classes, but primarily a helper for having a deferred call on a callable persistent object, or on a method on a persistent object. This lets you have a Twisted reactor call or a Twisted deferred callback affect the ZODB. Everything can be done within the main thread, so it can be full-bore Twisted usage, without threads. There are a few important "gotchas": see the Gotchas section below for details. The main API is Partial. You can pass it a callable persistent object, a method of a persistent object, or a normal non-persistent callable, and any arguments or keyword arguments of the same sort. DO NOT use non-persistent data structures (such as lists) of persistent objects with a database connection as arguments. This is your responsibility. If nothing is persistent, the partial will not bother to get a connection, and will behave normally.