Package slum :: Module collectClasses :: Class collectSlumClasses
[hide private]
[frames] | no frames]

Class collectSlumClasses

source code

low level class (shouldn't be directly used - refer to high level functions/classes) class responsible for deal with slum files and classes initializing a new class object will trigger the search of *.slum files in the local search path and online repositories. a cache system is in place to avoid un-necessary re-caching by clients. clients dont need to care about it. just re-create the class and the new object will pick up the data from the cache automatically, unless refresh parameter is True.

Instance Methods [hide private]
 
__init__(self, refresh=None, searchPath=None, onlineRepositories=None)
gathers slum classes from local disk/network and online repositories
source code
 
_refresh(self) source code
 
_registerSlumFile(self, slumCode, path)
based on a string with slum code on it, registers all class names in it into a temp db for each name, it adds a "code" key with the source code, so later a client can execute it and retrieve the class object at runtime.
source code
 
online(self)
same as local, but for online repositories.
source code
 
readSlumFile(self, path) source code
 
local(self)
returns a dictionary with all classes found in the searchpath the dictionary is organized as:
source code
Method Details [hide private]

__init__(self, refresh=None, searchPath=None, onlineRepositories=None)
(Constructor)

source code 

gathers slum classes from local disk/network and online repositories

this class stores the gathered classes and search paths as global variables, so if the class is re-created, it will retain the data from a previous object. (a sort of cache)

this is very useful when using this class in clients, so a call for the class in a initialization context will store the data, and the data can be quickly retrieve later in a diferent context, even whitout the original search paths.

also, a call to _refresh method (or creating the class object using the refresh parameter = True) will refresh the class caches using the cached search paths. This way, the search paths only need to be defined in the initialization context. As the class caches are global, even the _refresh method can be called from a totally separated context.

This cache mechanism frees the client from the tedious and error prone tasks of store all this data so it can be accessed in diferent contexts. It also speeds up the whole proccess, avoiding multiple un-necessary disk/network accesses.

_registerSlumFile(self, slumCode, path)

source code 

based on a string with slum code on it, registers all class names in it into a temp db for each name, it adds a "code" key with the source code, so later a client can execute it and retrieve the class object at runtime.

this class is a support class for local and online methods!

online(self)

source code 

same as local, but for online repositories. returns data in the same format as local

local(self)

source code 

returns a dictionary with all classes found in the searchpath
the dictionary is organized as:

        { 'class name' :
                {'code' : 'code for the class'}
        }