a lightweight object

A Lightweight Approach to Aspect-Oriented Programming in Python

Introduction
Features
Examples
Documentation
Download
(Old pages)

Download

Latest version: python-aspects-1.3.tar.gz

You may find it more convenient to install the python-aspects from

(If you know some other sources, please let me know so I can update the list)

Aspects library is released under LGPL 2.1.

Installing

Download the package, extract it and run

python setup.py install

Using the library in your software

It is recommended that your software depends on the aspects library and uses the library that is installed to the system. However, if you need to distribute your software in a self-contained package, just add aspects.py to your libraries. Remember to include the LGPL license in the package and prepare to provide the aspects.py library source code (as required by the license).

Version history

python-aspects-1.3.tar.gz released in October, 2008. What's new:

  • with_wrap(w, instance.method) wraps the execution of the method only when it is bound to the instance. That is, the result is equal to wrapping
    
    	with_wrap(w, class_of_instance.method, instances=[instance])
          
    Thanks to Leandro Rodrigo Saad Cruz for pointing out a bug in the handling of bound methods.
  • GNUmakefile uses the PYTHON environment variable. That is, you can run the unit tests and install the aspects library to different Pythons as follows:
    	PYTHON=python2.4 make check
    	PYTHON=python2.5 make check
    	PYTHON=python2.6 make check
    
    	PYTHON=python2.5 make install
    	PYTHON=python2.6 make install
          

python-aspects-1.2.tar.gz released in October, 2008. What's new:

  • without_wrap() function for removing arbitrary wraps around functions or methods. This works for new-style wraps only. So far, only the topmost wraps could be peeled.

aspects-1.1.tar.gz released in April, 2008. What's new:

  • Built-in function wrapping improved (fixes a bug in finding a built-in module)

aspects-1.0.tar.gz released in September, 2007. What's new:

  • with_wrap() function for new-style wraps.
Furthermore, package was changed to be more friendly for both users and developers
  • GNUmakefile included for
    • execution of unit tests (make check)
    • creation of distribution package (make dist)
    • installation (make install)
    • clean-up (make clean)
  • New unit tests
  • setup.py included for standard installation and distribution package creation.

aspects-0.6.tar.gz released in June, 2007. What's new:

  • Thread safety. Multithreading was not considered in __proceed, wrap_around and peel_around functions before this release. For thread safety, it was necessary to replace a single class variable __proceed_stack with a separate stack for every thread. Thus, self.__proceed_stack is no more a list, but it is a function that returns the stack (of list type) of the thread in which it was called. Therefore, those advices that use the stack do not work anymore (like the tracer example). However, everything should work again if you substitute __proceed_stack for __proceed_stack(). I'm grateful to Miguel Branco at CERN for his contribution!
  • Updated examples.
  • Performance of disabled advices optimized.

aspects-0.5.tar.gz released in April, 2007. What's new:

  • wrap_around(method, advice, instances=[]) can be given a list of instances whose method calls will be wrapped. The advice is omitted if the method is called for other instances. (In the implementation, the instance is identified with id() function.)

aspects-0.4.tar.gz released in March, 2007. What's new:

  • wrap_around(method, advice) returns the number of the new wrap made from the advice on the method. Numbering starts from zero.
  • enable_wrap(method, wrapnum) and disable_wrap(method, wrapnum) switch wraps on and off. If a wrap is disabled when the method is called, the associated advice is not executed.
  • wrap_is_enabled(method, wrapnum) returns 1 (0) when the wrap is enabled (disabled).
  • wrap_count(method) returns the number of wraps on the method. You can, for example, disable all wraps by executing: for i in range(wrap_count(m)): disable_wrap(m,i)
  • unit tests have been moved to aspects_test.py file. Tests passed with Python ("CPython") versions 2.1, 2.3, 2.4 and 2.5. Other versions have not been tested.

aspects-0.3.tar.gz released in May, 2006. Nothing is changed in the library itself, but the type checking example is extended to support also checking the types of keyword arguments. (Thanks to Pedro Salgado for his contribution on this.)

New version, 0.2, of the aspects library, aspects-0.2.tar.gz has been released in November, 2004. Changes:

  • the new version of the library has been released under GNU Lesser General Public License. LGPL will be used in the later releases.
  • wrap_around_re(class, method-name-regexp, advice) has been added to the library. (Thanks to Tiago Cogumbreiro!)
  • an example of implementing type checking with aspects has been added to the package
  • now private methods can be wrapped

The first release in August, 2003: aspects.tar.gz.


Python logo CC-GNU LGPL Valid HTML 4.01 Transitional
Hosted by Tampere University of Technology / Department of Software Systems. Thank you!
Updated 2009-08-01 15:03, Antti Kervinen, ask@cs.tut.fi