Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: cms/sources.py

Issue 5703725486178304: Issue 2563 - [cms] Cache filters and globals during page generation (Closed)
Patch Set: Created May 20, 2015, 3:51 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cms/converters.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 path = "/%s/%s" % (locale, page) 61 path = "/%s/%s" % (locale, page)
62 return locale, urlparse.urlunparse(parsed[0:2] + (path,) + parsed[3:]) 62 return locale, urlparse.urlunparse(parsed[0:2] + (path,) + parsed[3:])
63 63
64 def read_config(self): 64 def read_config(self):
65 configdata = self.read_file("settings.ini") 65 configdata = self.read_file("settings.ini")
66 config = ConfigParser.SafeConfigParser() 66 config = ConfigParser.SafeConfigParser()
67 config.readfp(StringIO(configdata)) 67 config.readfp(StringIO(configdata))
68 return config 68 return config
69 69
70 def import_symbol(self, filename, symbol):
71 code = self.read_file(filename)
72 namespace = {}
Sebastian Noack 2015/05/20 16:01:39 Note that I refactored this logic while moving it
73 exec code in namespace
74
75 try:
76 return namespace[symbol]
77 except KeyError:
78 raise Exception("Expected symbol %s not found in %s" % (symbol, filename))
79
70 # 80 #
71 # Page helpers 81 # Page helpers
72 # 82 #
73 83
74 @staticmethod 84 @staticmethod
75 def page_filename(page, format): 85 def page_filename(page, format):
76 return "pages/%s.%s" % (page, format) 86 return "pages/%s.%s" % (page, format)
77 87
78 def list_pages(self): 88 def list_pages(self):
79 for filename in self.list_files("pages"): 89 for filename in self.list_files("pages"):
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 path = os.path.join(dir, filename) 287 path = os.path.join(dir, filename)
278 if os.path.isfile(path): 288 if os.path.isfile(path):
279 result.append(relpath + filename) 289 result.append(relpath + filename)
280 elif os.path.isdir(path): 290 elif os.path.isdir(path):
281 do_list(path, relpath + filename + "/") 291 do_list(path, relpath + filename + "/")
282 do_list(self.get_path(subdir), "") 292 do_list(self.get_path(subdir), "")
283 return result 293 return result
284 294
285 def get_cache_dir(self): 295 def get_cache_dir(self):
286 return os.path.join(self._dir, "cache") 296 return os.path.join(self._dir, "cache")
OLDNEW
« no previous file with comments | « cms/converters.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld