From 7568947d26992aeb535f8a3373b92fcd1192db10 Mon Sep 17 00:00:00 2001 From: luto Date: Sat, 18 Nov 2017 23:25:15 +0100 Subject: [PATCH] allow a derived management command to change the way views are instantiated --- bakery/management/commands/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bakery/management/commands/build.py b/bakery/management/commands/build.py index 3ad2c72..8d1de31 100644 --- a/bakery/management/commands/build.py +++ b/bakery/management/commands/build.py @@ -188,6 +188,12 @@ def build_media(self): os.path.join(self.build_dir, settings.MEDIA_URL.lstrip('/')) ) + def get_view_instance(self, view): + """ + Given a view class, get an instance of it. + """ + return view() + def build_views(self): """ Bake out specified buildable views. @@ -198,7 +204,7 @@ def build_views(self): if self.verbosity > 1: self.stdout.write("Building %s" % view_str) view = get_callable(view_str) - view().build_method() + self.get_view_instance(view).build_method() def copytree_and_gzip(self, source_dir, target_dir): """