Commits

Anonymous committed 75241a8

moved modules into app setup

Comments (0)

Files changed (2)

newsmeme/application.py

 from flaskext.principal import Principal, identity_loaded
 
 from newsmeme import helpers
+from newsmeme import views
 from newsmeme.config import DefaultConfig
 from newsmeme.models import User, Tag
 from newsmeme.helpers import render_template
 __all__ = ["create_app"]
 
 DEFAULT_APP_NAME = "newsmeme"
+    
+DEFAULT_MODULES = (
+    (views.frontend, ""),
+    (views.post, "/post"),
+    (views.user, "/user"),
+    (views.comment, "/comment"),
+    (views.account, "/acct"),
+    (views.feeds, "/feeds"),
+    (views.openid, "/openid"),
+    (views.api, "/api"),
+)
 
-def create_app(config=None, app_name=None):
+
+def create_app(config=None, app_name=None, modules=None):
 
     if app_name is None:
         app_name = DEFAULT_APP_NAME
 
+    if modules is None:
+        modules = DEFAULT_MODULES
+
     app = Flask(app_name)
 
     configure_app(app, config)
     configure_filters(app)
     configure_context_processors(app)
     # configure_after_handlers(app)
-    configure_modules(app)
+    configure_modules(app, modules)
 
     return app
 
     app.config.from_envvar('APP_CONFIG', silent=True)
 
 
-def configure_modules(app):
+def configure_modules(app, modules):
     
-    for module, url_prefix in app.config['MODULES']:
+    for module, url_prefix in modules:
         app.register_module(module, url_prefix=url_prefix)
 
 

newsmeme/config.py

     :license: BSD, see LICENSE for more details.
 """
 
-from newsmeme import views
 
 class DefaultConfig(object):
     """
     CACHE_TYPE = "simple"
     CACHE_DEFAULT_TIMEOUT = 300
 
-    MODULES = (
-        (views.frontend, ""),
-        (views.post, "/post"),
-        (views.user, "/user"),
-        (views.comment, "/comment"),
-        (views.account, "/acct"),
-        (views.feeds, "/feeds"),
-        (views.openid, "/openid"),
-        (views.api, "/api"),
-    )
 
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.