Changeset 7e639860f58c8c25ebe5ce1b714a54a6d668112a
- Timestamp:
- 30.07.2013 02:50:28 (7 years ago)
- Branches:
- b66903eafbcb1d49112014abc82c8bf683413db0
- Children:
- a87b728b31cead3ea82bed5a282b3b730df56491
- Parents:
- ea93e3cf09ad21475511b78b6daa2e16669788c2
- git-author:
- Stanislaw Klekot <dozzie@…> (30.07.2013 02:49:26)
- git-committer:
- Stanislaw Klekot <dozzie@…> (30.07.2013 02:50:28)
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
dashwiki/macros/models.py
r65833c r7e6398 33 33 from dashwiki.plugins import load_plugin 34 34 plugin_instance = load_plugin(self) 35 result = plugin_instance.call(args) 35 36 from django.conf import settings 37 from django.core.urlresolvers import reverse 38 from dashwiki.resource_cache import ResourceCache 39 cache = ResourceCache( 40 settings.DASHWIKI_CACHE_ROOT, 41 reverse('cached_files'), 42 ) 43 44 result = plugin_instance.call(args, cache) 36 45 return result 37 46 -
dashwiki/plugins/FlatFile.py
rbc6a4f r7e6398 6 6 7 7 class FlatFile(ProtocolPlugin): 8 def call(self, args ):8 def call(self, args, cache): 9 9 # args: [...] 10 10 self.set_args(args) -
dashwiki/plugins/HTTP.py
r3c1e8b r7e6398 5 5 import os 6 6 7 from dashwiki.logging import getLogger, message as log 8 9 logger = getLogger(__name__) 10 7 11 #----------------------------------------------------------------------------- 8 12 9 13 class HTTP(ProtocolPlugin): 10 def call(self, args): 14 @staticmethod 15 def fetch(url, filename): 16 logger.info(log( 17 'fetching file', 18 url = url, 19 filename = filename, 20 )) 21 urlfetcher = urllib.URLopener() 22 urlfetcher.retrieve(url, filename) 23 24 def call(self, args, cache): 11 25 # args: [...] 12 26 self.set_args(args) 13 27 14 # TODO: remove when DashWiki serves images by itself (a cache) 15 if self.result_type == 'graph': 16 return self.make_image() 17 18 urlfetcher = urllib.URLopener() 19 (tempfilename, headers) = urlfetcher.retrieve(self.url) 20 data = open(tempfilename).read() 21 os.unlink(tempfilename) 28 # FIXME: how to choose filename? 29 filename = 'foo' 22 30 23 31 if self.result_type == 'list': 32 data = cache.get(filename, lambda(g): HTTP.fetch(self.url, g.path())) 24 33 return data.split('\n') 25 34 elif self.result_type == 'graph': 26 return self.make_image() 35 url = cache.get_url(filename, lambda(g): HTTP.fetch(self.url, g.path())) 36 return { 37 'image': { 'image_target': url } 38 } 27 39 else: 40 data = cache.get(filename, lambda(g): HTTP.fetch(self.url, g.path())) 28 41 return data 29 42 -
dashwiki/plugins/XMLRPC.py
rf9e4bb r7e6398 7 7 8 8 class XMLRPC(ProtocolPlugin): 9 def call(self, args ):9 def call(self, args, cache): 10 10 # args: [...] 11 11 self.set_args(args) -
dashwiki/settings.py
rb2817c r7e6398 60 60 # Example: "/home/media/media.lawrence.com/" 61 61 MEDIA_ROOT = '%s/static' % (app_root_dir) 62 63 # Absolute path to the directory that holds media. 64 # Example: "/home/media/media.lawrence.com/" 65 DASHWIKI_CACHE_ROOT = '%s/cache' % (app_root_dir) 62 66 63 67 # URL that handles the media served from MEDIA_ROOT. Make sure to use a -
dashwiki/urls.py
r8298e0 r7e6398 31 31 name = "static_files" 32 32 ), 33 url( 34 r'^cache/(?P<path>.+)?$', 35 'django.views.static.serve', { 'document_root': settings.DASHWIKI_CACHE_ROOT }, 36 name = "cached_files" 37 ), 33 38 ) 34 39 … … 38 43 39 44 #----------------------------------------------------------------------------- 40 # vim:ft=python: foldmethod=marker45 # vim:ft=python:nowrap:foldmethod=marker
Note: See TracChangeset
for help on using the changeset viewer.