def respond(request, template, params=None): if params is None: params = {} if request.LANGUAGE_CODE != 'en': params['is_foreign'] = request.LANGUAGE_CODE if not template.endswith('.html'): template += '.html' params['skin'] = settings.SKIN params['app_id'] = settings.APP_ID session_token = None user = users.get_current_user() if user: params['user'] = user params['author'] = db.Query(Author).filter('email = ', user.email()).get() if users.IsCurrentUserAdmin(): params['authsub_url'], session_token, client = check_auth(request, user) params['is_admin'] = True # users.IsCurrentUserAdmin() # global params['developer'] = ('Dev' in os.getenv('SERVER_SOFTWARE')) params['sign_out'] = users.CreateLogoutURL('/') else: params['sign_in'] = users.CreateLoginURL(request.path) params['session_token'] = session_token # Events startTime = datetime.datetime.now() + datetime.timedelta(weeks=-2) endTime = datetime.datetime.now() + datetime.timedelta(weeks=2) urlparams = 'start-min=%s&start-max=%s' % (startTime.strftime("%Y-%m-%dT%H:%M:%S"), endTime.strftime("%Y-%m-%dT%H:%M:%S")) url = 'http://www.google.com/calendar/feeds/%s/public/basic?' % settings.GOOGLE_ACCOUNT url = url + urlparams feed = urlfetch.fetch(url) calendar = feedparser.parse(feed.content) events = calendar['entries'] params['events'] = events # sidebar categories & page links categories = Category.all() categories.order("sequence") params['categories'] = categories pages = Page.all() pages.order("sequence") params['pages'] = pages return shortcuts.render_to_response(template, params)
def _load_templates(self, directory): self.templates = {} suffix = '.html' for template in sorted(os.listdir(directory)): if not template.endswith(suffix): continue path = os.path.join(directory, template) with open(path, 'r') as f: text = f.read() name = template[:-len(suffix)] self.templates[name] = (path, text)
def _load_templates(self, directory): self.templates = {} suffix = '.template.html' for template in sorted(os.listdir(directory)): if not template.endswith(suffix): continue path = os.path.join(directory, template) with open(path, 'r') as f: text = f.read() name = template[:-len(suffix)] self.templates[name] = (path, text) self.partials = dict(((k, v[1]) for k, v in self.templates.iteritems())) logs.debug("[%s] loaded %d custom templates" % (self, len(self.templates)))