# HG changeset patch # User Adrien Di Mascio # Date 1253816749 -7200 # Node ID 3a79fecdd2b40cc7fecb75587e859882b98e8c76 # Parent 8a11aeea4d25cbdadaa82d0ccae23e2fc894aa45 [magicsearch] make tests pass again: base preprocessor must have access to vreg (+ removed some deprecation warnings) diff -r 8a11aeea4d25 -r 3a79fecdd2b4 web/httpcache.py --- a/web/httpcache.py Thu Sep 24 11:06:50 2009 +0200 +++ b/web/httpcache.py Thu Sep 24 20:25:49 2009 +0200 @@ -18,7 +18,7 @@ def __init__(self, view): self.view = view self.req = view._cw - self.cw_rset = view.rset + self.cw_rset = view.cw_rset def set_headers(self): self.req.set_header('Cache-control', 'no-cache') @@ -108,7 +108,7 @@ # XXX check view module's file modification time in dev mod ? ctime = datetime.utcnow() if self.cache_max_age: - mtime = self.req.header_if_modified_since() + mtime = self._cw.header_if_modified_since() if mtime: tdelta = (ctime - mtime) if tdelta.days * 24*60*60 + tdelta.seconds > self.cache_max_age: diff -r 8a11aeea4d25 -r 3a79fecdd2b4 web/test/unittest_application.py --- a/web/test/unittest_application.py Thu Sep 24 11:06:50 2009 +0200 +++ b/web/test/unittest_application.py Thu Sep 24 20:25:49 2009 +0200 @@ -37,25 +37,25 @@ class FakeController(ViewController): def __init__(self, form=None): - self.req = FakeRequest() - self.req.form = form or {} - self._cursor = self.req.cursor = MockCursor() + self._cw = FakeRequest() + self._cw.form = form or {} + self._cursor = self._cw.cursor = MockCursor() def new_cursor(self): - self._cursor = self.req.cursor = MockCursor() + self._cursor = self._cw.cursor = MockCursor() def set_form(self, form): - self.req.form = form + self._cw.form = form class RequestBaseTC(TestCase): def setUp(self): - self.req = FakeRequest() + self._cw = FakeRequest() def test_list_arg(self): """tests the list_arg() function""" - list_arg = self.req.list_form_param + list_arg = self._cw.list_form_param self.assertEquals(list_arg('arg3', {}), []) d = {'arg1' : "value1", 'arg2' : ('foo', INTERNAL_FIELD_VALUE,), @@ -69,8 +69,8 @@ def test_from_controller(self): - self.req.vreg['controllers'] = {'view': 1, 'login': 1} - self.assertEquals(self.req.from_controller(), 'view') + self._cw.vreg['controllers'] = {'view': 1, 'login': 1} + self.assertEquals(self._cw.from_controller(), 'view') req = FakeRequest(url='project?vid=list') req.vreg['controllers'] = {'view': 1, 'login': 1} # this assertion is just to make sure that relative_path can be @@ -123,7 +123,7 @@ self.ctrl.new_cursor() - self.ctrl.req.form = {'__linkto' : 'works_for:12_13_14:object'} + self.ctrl._cw.form = {'__linkto' : 'works_for:12_13_14:object'} self.ctrl.execute_linkto(eid=8) self.assertEquals(self.ctrl._cursor.executed, ['SET Y works_for X WHERE X eid 8, Y eid %s' % i diff -r 8a11aeea4d25 -r 3a79fecdd2b4 web/test/unittest_magicsearch.py --- a/web/test/unittest_magicsearch.py Thu Sep 24 11:06:50 2009 +0200 +++ b/web/test/unittest_magicsearch.py Thu Sep 24 20:25:49 2009 +0200 @@ -70,7 +70,7 @@ self.req = self.request() proc = self.vreg['components'].select('magicsearch', self.req) self.proc = [p for p in proc.processors if isinstance(p, QSPreProcessor)][0] - self.proc.req = self.req + self.proc._cw = self.req def test_entity_translation(self): """tests QSPreProcessor._get_entity_name()""" diff -r 8a11aeea4d25 -r 3a79fecdd2b4 web/views/magicsearch.py --- a/web/views/magicsearch.py Thu Sep 24 11:06:50 2009 +0200 +++ b/web/views/magicsearch.py Thu Sep 24 20:25:49 2009 +0200 @@ -350,7 +350,7 @@ self.by_name = {} for processorcls in self._cw.vreg['components']['magicsearch_processor']: # instantiation needed - processor = processorcls() + processor = processorcls(self._cw) processors.append(processor) if processor.name is not None: assert not processor.name in self.by_name