Package pyforms :: Package web :: Package django :: Module Applications |
[hide private]
[frames] | no frames]

# Source Code for Module pyforms.web.django.Applications

     1  import inspect, sys
     2
     3 -class ApplicationsLoader:
     4
     5 -        def __init__(self, applicationsPath):
     6                  sys.path.append(applicationsPath)
     7                  self._storage = {}
     8
     9
    10 -        def __getitem__(self, moduleclassname):
    11                  if moduleclassname not in self._storage:
    12                          modulename = '.'.join( [moduleclassname.lower(), moduleclassname] )
    13                          moduleclass = __import__(modulename, fromlist=[moduleclassname])
    14                          moduleclass =  getattr(moduleclass, moduleclassname)
    15                          self._storage[moduleclassname] = moduleclass
    16                  else:
    17                          moduleclass = self._storage[moduleclassname]
    18                  return moduleclass
    19
    20 -        def createInstance(self, moduleclassname):
    21                  app = self[moduleclassname]()
    22                  #app.initForm()
    23                  return app
    24
    25 -        def moduleClassPath(self, moduleclassname):
    26                  return inspect.getfile(self[moduleclassname])
    27