def get_list(self, page, sort_field, sort_desc, search, filters): print 'HELLO {}'.format(get_sites()) # `page` is zero-based if not sort_field: sort_field = 'name' page_start = page*SitesView.page_size page_end = page_start + SitesView.page_size slice_unsorted = get_sites()[page_start:page_end] slice_sorted = sorted( slice_unsorted, # Magic to get a specific sort field out of a site key=lambda s: getattr(s, sort_field), reverse=sort_desc) return len(slice_sorted), slice_sorted
def regenerate_config(self): """ Regenerates all configuration files with new settings. """ # Avoid a recursive import from ckan_multisite.site import get_sites self.update_default() for site in get_sites(): self.update_site(site)
def get_one(self, id): # ids come in as strs (unicode) return get_sites()[int(id)] if int(id) < len(get_sites()) else None
def get_pk_value(self, model): sites = get_sites() if model in sites: return sites.index(model) else: return None