-# Copyright (C) 2013 Simo Sorce <simo@redhat.com>
-#
-# see file 'COPYING' for use and warranty information
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# Copyright (C) 2013 Ipsilon project Contributors, for license see COPYING
import cherrypy
from ipsilon.util.endpoint import Endpoint
self.basepath = cherrypy.config.get('base.mount', "")
self.user = None
self._is_form_page = form
- self.default_headers = dict()
self.auth_protect = False
def get_url(self):
return False
def __call__(self, *args, **kwargs):
- # pylint: disable=star-args
cherrypy.response.headers.update(self.default_headers)
self.user = UserSession().get_user()
return op(*args[1:], **kwargs)
else:
if self._is_form_page:
- self._debug("method: %s" % cherrypy.request.method)
+ self.debug("method: %s" % cherrypy.request.method)
op = getattr(self, cherrypy.request.method, None)
if callable(op):
# Basic CSRF protection
if cherrypy.request.method != 'GET':
url = self.get_url()
if 'referer' not in cherrypy.request.headers:
- self._debug("Missing referer in %s request to %s"
- % (cherrypy.request.method, url))
+ self.debug("Missing referer in %s request to %s"
+ % (cherrypy.request.method, url))
raise cherrypy.HTTPError(403)
referer = cherrypy.request.headers['referer']
if not self._check_referer(referer, url):
- self._debug("Wrong referer %s in request to %s"
- % (referer, url))
+ self.debug("Wrong referer %s in request to %s"
+ % (referer, url))
raise cherrypy.HTTPError(403)
return op(*args, **kwargs)
else:
return model
def _template(self, *args, **kwargs):
- # pylint: disable=star-args
t = self._site['template_env'].get_template(args[0])
m = self._template_model()
m.update(kwargs)