Package testoob :: Module utils
[show private | hide private]
[frames | no frames]

Module testoob.utils

General utilities used internally
Exceptions
UnpickleableFieldError  

Function Summary
  add_fields_pickling(klass, disable_unpickleable_fields)
Add pickling for 'fields' classes.

Function Details

add_fields_pickling(klass, disable_unpickleable_fields=False)

Add pickling for 'fields' classes.

A 'fields' class is a class who's methods all act as fields - accept no
arguments and for a given class's state always return the same value.

Useful for 'fields' classes that contain unpickleable members.

Used in Testoob, http://testoob.sourceforge.net

A contrived example for a 'fields' class:

  class Titles:
    def __init__(self, name):
      self.name = name
    def dr(self):
      return "Dr. " + self.name
    def mr(self):
      return "Mr. " + self.name

If a method returns an unpickleable value there are two options:
Default:
  Allow the instance to be pickled. If the method is called on the
  unpickled instance, an UnpickleableFieldError exception is raised.
  There is a possible performance concern here: each return value is
  pickled twice when pickling the instance.

With disable_unpickleable_fields=True:
  Disallow pickling of instances with a method returning an unpickleable
  object.

Generated by Epydoc 2.1 on Sun Dec 3 15:27:57 2006 http://epydoc.sf.net