def roundup_opendb(self): '''Open the roundup instance database for a transaction. ''' tracker = roundup.instance.open(self.instance_home) request = RequestWrapper(self.REQUEST['RESPONSE']) env = self.REQUEST.environ # figure out the path components to set url = urlparse.urlparse(self.absolute_url()) path = url[2] path_components = path.split('/') # special case when roundup is '/' in this virtual host, if path == "/": env['SCRIPT_NAME'] = "/" env['TRACKER_NAME'] = '' else: # all but the last element is the path env['SCRIPT_NAME'] = '/'.join(path_components[:-1]) # the last element is the name env['TRACKER_NAME'] = path_components[-1] form = FormWrapper(self.REQUEST.form) if hasattr(tracker, 'Client'): return tracker.Client(tracker, request, env, form) return client.Client(tracker, request, env, form)
def parseForm(self, form, classname='test', nodeid=None): cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, makeForm(form)) cl.classname = classname cl.nodeid = nodeid cl.language = ('en',) cl.db = self.db return cl.parsePropsFromForm(create=1)
def _make_client(self, form, classname='user', nodeid='2', userid='2'): cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, makeForm(form)) cl.classname = 'user' cl.nodeid = '1' cl.db = self.db cl.userid = '2' cl.language = ('en',) return cl
def testMixedMultilink(self): form = cgi.FieldStorage() form.list.append(cgi.MiniFieldStorage('nosy', '1,2')) form.list.append(cgi.MiniFieldStorage('nosy', '3')) cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) cl.classname = 'issue' cl.nodeid = None cl.db = self.db cl.language = ('en',) self.assertEqual(cl.parsePropsFromForm(create=1), ({('issue', None): {'nosy': ['1','2', '3']}}, []))
def testStringLinkId(self): self.db.status.set('1', name='2') self.db.status.set('2', name='1') issue = self.db.issue.create(title='i1-status1', status='1') self.assertEqual(self.db.issue.get(issue,'status'),'1') self.assertEqual(self.db.status.lookup('1'),'2') self.assertEqual(self.db.status.lookup('2'),'1') form = cgi.FieldStorage() cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) cl.classname = 'issue' cl.nodeid = issue cl.db = self.db cl.language = ('en',) item = HTMLItem(cl, 'issue', issue) self.assertEqual(item.status.id, '1') self.assertEqual(item.status.name, '2')
def _make_client(self, form, classname='user', nodeid='1', userid='2', template='item'): cl = client.Client(self.instance, None, { 'PATH_INFO': '/', 'REQUEST_METHOD': 'POST' }, makeForm(form)) cl.classname = classname if nodeid is not None: cl.nodeid = nodeid cl.db = self.db cl.userid = userid cl.language = ('en', ) cl._error_message = [] cl.template = template return cl
def testStringMultilinkId(self): id = self.db.keyword.create(name='2') self.assertEqual(id,'1') id = self.db.keyword.create(name='1') self.assertEqual(id,'2') issue = self.db.issue.create(title='i1-status1', keyword=['1']) self.assertEqual(self.db.issue.get(issue,'keyword'),['1']) self.assertEqual(self.db.keyword.lookup('1'),'2') self.assertEqual(self.db.keyword.lookup('2'),'1') form = cgi.FieldStorage() cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) cl.classname = 'issue' cl.nodeid = issue cl.db = self.db cl.language = ('en',) cl.userid = '1' item = HTMLItem(cl, 'issue', issue) for keyword in item.keyword: self.assertEqual(keyword.id, '1') self.assertEqual(keyword.name, '2')