Added LazyView from http://flask.pocoo.org/docs/patterns/lazyloading/ to helpers
This commit is contained in:
@@ -1,4 +1,17 @@
|
||||
from math import ceil
|
||||
from werkzeug import import_string, cached_property
|
||||
|
||||
class LazyView(object):
|
||||
def __init__(self, import_name):
|
||||
self.__module__, self.__name__ = import_name.rsplit('.', 1)
|
||||
self.import_name = import_name
|
||||
|
||||
@cached_property
|
||||
def view(self):
|
||||
return import_string(self.import_name)
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self.view(*args, **kwargs)
|
||||
|
||||
class Pagination(object):
|
||||
def __init__(self, page, per_page, total_count):
|
||||
|
Reference in New Issue
Block a user