Reorganized site and blog views and helpers to use LazyView

This increases the speed of the site by not requiring the site and blog code to
be imported on every request - just those that are relevant. It also splits the
code into modules which are easier to work with.
This commit is contained in:
str4d
2012-12-19 06:53:59 +00:00
parent 8f9e8fb178
commit 785f627d7a
5 changed files with 157 additions and 162 deletions

View File

@@ -1,6 +1,18 @@
from math import ceil
from werkzeug import import_string, cached_property
########################
# General helper methods
def get_for_page(items, page, per_page):
from_item = (page-1)*per_page
to_item = page*per_page
return items[from_item:to_item]
########################
# General helper classes
class LazyView(object):
def __init__(self, import_name):
self.__module__, self.__name__ = import_name.rsplit('.', 1)