/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes | Private Member Functions
UserTagging::Manager::ObjectSet Class Reference
Inheritance diagram for UserTagging::Manager::ObjectSet:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def all_dict
def all
def __setattr__
def add
def get

Public Attributes

 classForManaging
 description

Private Member Functions

def __init

Detailed Description

Base (abstract) Manager for a colection of certain classes of objects

Definition at line 6 of file Manager.py.


Member Function Documentation

def UserTagging::Manager::ObjectSet::__init (   self) [private]
Do not call this function in the child class.
This is a boilerPlate for Child class's __init__(). 
Intentionally wrong name to avoid reloading __setattr__().
Child class mush define in its __init__() the following:
    - self.classForManaging : a tuple of classes of the managed objects
    - self.description : an empty dict for bookkeeping the attributes

Definition at line 9 of file Manager.py.

00010                     :
00011         '''
00012         Do not call this function in the child class.
00013         This is a boilerPlate for Child class's __init__(). 
00014         Intentionally wrong name to avoid reloading __setattr__().
00015         Child class mush define in its __init__() the following:
00016             - self.classForManaging : a tuple of classes of the managed objects
00017             - self.description : an empty dict for bookkeeping the attributes
00018         '''
00019         self.classForManaging = (None,)     
00020         # description = {name: class} for bookkeeping the attribute
00021         self.description = {}  

def UserTagging::Manager::ObjectSet::all_dict (   self)
return the dictionary of name:object of the managed classes

Definition at line 23 of file Manager.py.

00024                       :
00025         '''return the dictionary of name:object of the managed classes'''
00026         return dict((name, self.__dict__[name]) for name in self.description)
        
def UserTagging::Manager::ObjectSet::all (   self)
return a list of objects of the managed classes

Definition at line 28 of file Manager.py.

00029                  :
00030         '''return a list of objects of the managed classes'''
00031         return (self.__dict__[name] for name in self.description)
            
def UserTagging::Manager::ObjectSet::__setattr__ (   self,
  name,
  value 
)
hook for caching a name of the Object as the class attribute

Definition at line 33 of file Manager.py.

00033                                       :      
00034         '''hook for caching a name of the Object as the class attribute'''
00035         object.__setattr__(self, name, value)        
00036         if isinstance(value, self.classForManaging):
00037             # The attribute class is intentionally only intialized once.
00038             # This way, one can intialize an attribute with a specific class
00039             # but can later use intrisic python type to represent this class
00040             # see the implemetation of class ParameterSet for an example
00041             self.description.setdefault(name, value.__class__)
00042 
def UserTagging::Manager::ObjectSet::add (   self,
  name,
  anObject 
)
Add one Object

Definition at line 48 of file Manager.py.

00049                                  :
00050         """Add one Object"""
00051         if isinstance(anObject, self.classForManaging):
00052             self.__setattr__(name, anObject)
00053             return anObject
00054         raise AttributeError(str(anObject) 
00055             + ' is not a ' 
00056             + str(self.classForManaging))
        
def UserTagging::Manager::ObjectSet::get (   self,
  name 
)
Get the Object given the name

Definition at line 58 of file Manager.py.

00059                        :
00060         """Get the Object given the name"""
00061         try:
00062             objName = self.description[name]
00063         except KeyError:
00064             raise AttributeError('Object ' + name + ' is not defined yet')
00065         return self.__dict__[name]
00066     

Member Data Documentation


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:02:01 for UserTagging by doxygen 1.7.4