diff options
author | Thomas Waldmann <tw AT waldmann-edv DOT de@localhost> | 2011-07-09 21:19:05 +0200 |
---|---|---|
committer | Thomas Waldmann <tw AT waldmann-edv DOT de@localhost> | 2011-07-09 21:19:05 +0200 |
commit | 19cd12f0f9b9a331759e8a2f85a59a2a29468260 (patch) | |
tree | 596b1a5ee73026569fa6f5a62040b5c621aa986d /xstatic | |
parent | 37c3155a233ccae2e2aaa66321e604fdb974c9c3 (diff) | |
download | xstatic-git-19cd12f0f9b9a331759e8a2f85a59a2a29468260.tar.gz |
use a module for metadata, not a class, solves import/dependency issue0.0.2
Diffstat (limited to 'xstatic')
-rw-r--r-- | xstatic/main.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/xstatic/main.py b/xstatic/main.py index 1ea94bf..b0a2bd2 100644 --- a/xstatic/main.py +++ b/xstatic/main.py @@ -10,18 +10,19 @@ class XStatic(object): minimal support code to access resources from xstatic.pkg.* files or CDN locations. """ - name = None # lowercase short name - base_dir = None # fs path to the files - locations = {} # CDN/remote locations - - def __init__(self, root_url='/xstatic', provider='local', protocol='http'): + def __init__(self, module, root_url='/xstatic', provider='local', protocol='http'): """ + :arg module: xstatic resource package/module, has metadata as attributes :arg root_url: the common root url path for all local xstatic resources :arg provider: 'local' to get it from local server or a name of another source (e.g. CDN) :arg protocol: 'http' (default) or 'https' """ + self.__dict__.update([(name.lower(), getattr(module, name)) + for name in dir(module) + if name.isupper() + ]) self.provider = provider if provider == 'local': self.base_url = "%s/%s" % (root_url, self.name) |