import functools

from .handler import handler
from .urls import load_urls, resolve


def WSGIApplication(app_settings):
    '''Create main application handler
    '''

    class Application(object):
        settings = app_settings
        urls = load_urls(settings.urls)
        resolve_url = functools.partial(resolve, urls)

    return functools.partial(handler, Application, Application.resolve_url)

@@ -9,16 +9,68 @@
 unctools
+%0Aimport os%0A%0Afrom ..templates.loaders import FSLoader
 %0A%0Afrom .
@@ -135,16 +135,18 @@
 e%0A%0A%0A
-def WSGI
+class Base
 Appl
@@ -157,99 +157,143 @@
 ion(
-app_settings):%0A    '''Create main application handler%0A    '''%0A%0A    class Application(object
+object):%0A    '''Base application class contains obly settings, urls and resolve_url%0A    method%0A    '''%0A%0A    def __init__(self, settings
 ):%0A 
@@ -299,16 +299,21 @@
         
+self.
 settings
@@ -319,12 +319,8 @@
 s = 
-app_
 sett
@@ -332,16 +332,21 @@
         
+self.
 urls = l
@@ -377,16 +377,21 @@
         
+self.
 resolve_
@@ -427,15 +427,940 @@
 ve, 
+self.
 urls)%0A%0A
+%0Aclass ComplexApplication(BaseApplication):%0A    '''Application loads also templates and database connection%0A    '''%0A%0A    def __init__(self, settings):%0A        super(ComplexApplication, self).__init__(settings)%0A        self.apps = settings.section('APPS')%0A        template_dirs = %5B%5D%0A        for app in self.apps:%0A            module = __import__(app, globals(), locals(), app.split('.')%5B-1%5D)%0A            template_dir = os.path.join(module.__path__%5B0%5D, 'templates')%0A            if os.path.exists(template_dir):%0A                template_dirs.append(template_dir)%0A        try:%0A            template_dirs += settings.section('TEMPLATE_DIRS')%0A        except:%0A            pass%0A        self.template_loader = FSLoader(template_dirs)%0A        self.get_template = self.template_loader.get_template%0A%0A%0Adef WSGIApplication(app_settings):%0A    '''Create main application handler%0A    '''%0A    application = ComplexApplication(app_settings)%0A
     
@@ -1393,17 +1393,17 @@
 andler, 
-A
+a
 pplicati
@@ -1406,17 +1406,17 @@
 cation, 
-A
+a
 pplicati

Add ComplexApplication class for WSGI apps that uses not only urls resolving.