-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added routeloader, changed bootstrap to be global, added multiple tem…
…plate dir lookup support
- Loading branch information
1 parent
3569a4f
commit 7956581
Showing
5 changed files
with
61 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
#!/usr/bin/env python | ||
|
||
from bootstrap import Bootstrap | ||
from whirlwind.core.bootstrap import Bootstrap | ||
import os | ||
|
||
#main app entry point | ||
if __name__ == "__main__": | ||
Bootstrap.run() | ||
Bootstrap.run(os.path.dirname(__file__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class RouteLoader(object): | ||
|
||
@staticmethod | ||
def load(package_name,include_routes_file=True): | ||
loader = RouteLoader() | ||
return loader.init_routes(package_name,include_routes_file) | ||
|
||
def init_routes(self,package_name,include_routes_file=True): | ||
import pkgutil,sys,inspect | ||
from whirlwind.view.decorators import route | ||
|
||
package = __import__(package_name) | ||
controllers_module = sys.modules[package_name] | ||
|
||
prefix = controllers_module.__name__ + "." | ||
|
||
for importer, modname, ispkg in pkgutil.iter_modules(controllers_module.__path__, prefix): | ||
module = __import__(modname) | ||
|
||
#grab the routes defined via the route decorator | ||
url_routes = route.get_routes() | ||
|
||
#add the routes from our route file | ||
if include_routes_file: | ||
from config.routes import route_list | ||
url_routes.extend(route_list) | ||
|
||
|
||
return url_routes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters