app_list = [item for item in os.listdir(toplevel) if os.path.isdir(os.path.join(toplevel, item)) and '__init__.py' in os.listdir(os.path.join(toplevel, item))]
for module in ['sylk.applications.%s' % item for item in set(app_list).difference(ServerConfig.disabled_applications)]:
app_list = [item for item in os.listdir(toplevel) if os.path.isdir(os.path.join(toplevel, item)) and '__init__.py' in os.listdir(os.path.join(toplevel, item))]
sys.path.append(toplevel)
for module in (item for item in set(app_list).difference(ServerConfig.disabled_applications)):
try:
__import__(module)
except ImportError, e:
log.warning('Error loading extra "%s" application: %s' % (module, e))
def load_applications():
load_builtin_applications()
load_extra_applications()
for app in ApplicationRegistry():
try:
app()
except Exception, e:
log.warning('Error loading application: %s' % e)
log.err()
class ApplicationNotLoadedError(Exception):
pass
class IncomingRequestHandler(object):
"""
Handle incoming requests and match them to applications.
"""
__metaclass__ = Singleton
implements(IObserver)
def __init__(self):
load_applications()
registry = ApplicationRegistry()
self.applications = dict((app.__appname__, app) for app in registry)