From 0e3b0468c349f849457b4156a2a623593525ee7d Mon Sep 17 00:00:00 2001 From: Raymond Yee Date: Thu, 4 Dec 2014 14:40:30 -0800 Subject: [PATCH 1/2] rewrite some classes in facets.py to use instance variables instead of class variables...will matter if we have more than one Facet/FacetGroup at a time --- core/facets.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/core/facets.py b/core/facets.py index 4485769d..e071fec7 100644 --- a/core/facets.py +++ b/core/facets.py @@ -3,11 +3,12 @@ from regluit.core import cc class BaseFacet(object): - facet_name = 'all' - outer_facet = None - model = get_model('core', 'Work') def __init__(self, outer_facet): + self.facet_name = 'all' + self.outer_facet = None + self.model = get_model('core', 'Work') + if outer_facet: self.outer_facet = outer_facet @@ -81,8 +82,12 @@ class NamedFacet(BaseFacet): self.set_name() class FormatFacetGroup(FacetGroup): - title = 'Format' - facets = ['pdf', 'epub', 'mobi'] + + def __init__(self): + super(FacetGroup,self).__init__() + self.title = 'Format' + self.facets = ['pdf', 'epub', 'mobi'] + def get_facet_class(self, facet_name): class FormatFacet(NamedFacet): @@ -96,9 +101,13 @@ class FormatFacetGroup(FacetGroup): class LicenseFacetGroup(FacetGroup): - title = 'License' - licenses = cc.LICENSE_LIST_ALL - facets = cc.FACET_LIST + + def __init__(self): + super(FacetGroup,self).__init__() + self.title = 'License' + self.licenses = cc.LICENSE_LIST_ALL + self.facets = cc.FACET_LIST + def get_facet_class(self, facet_name): class LicenseFacet(NamedFacet): From f689bcf6bd7c2021f24b92f3af287c0f5a76de90 Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 5 Dec 2014 09:39:48 -0500 Subject: [PATCH 2/2] I learned something --- core/facets.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/facets.py b/core/facets.py index e071fec7..13d3e484 100644 --- a/core/facets.py +++ b/core/facets.py @@ -3,14 +3,11 @@ from regluit.core import cc class BaseFacet(object): + facet_name = 'all' def __init__(self, outer_facet): - self.facet_name = 'all' - self.outer_facet = None + self.outer_facet = outer_facet if outer_facet else None self.model = get_model('core', 'Work') - - if outer_facet: - self.outer_facet = outer_facet def _get_query_set(self): if self.outer_facet: