def test_likert_html_output(self): """Failing test for #225, AttributeError: __len__" in Plone 2.5.5""" rating_req_val = record() rating_req_val.__dict__ = {'1':'2','2':'3'} request = FakeRequest(topic = 'test subject', replyto='*****@*****.**', comments='test comments', lf=rating_req_val) self.failUnless("1: 2, 2: 3" in self.ff1.lf.htmlValue(request))
def gl_add_site_language_custom(self, language): # this is called to handle other types of multilanguage objects catalog_tool = self.getCatalogTool() for b in self.getCatalogedBrains(meta_type=[METATYPE_NYPHOTOFOLDER, METATYPE_NYPHOTO]): x = catalog_tool.getobject(b.data_record_id_) try: x.add_language(language) except: pass for r in self.objectValues(METATYPE_NYNETREPOSITORY): try: r.add_language(language) except: pass for gloss in self.objectValues(NAAYAGLOSSARY_CENTRE_METATYPE): try: language_name = self.gl_get_language_name(language) catalog_obj = gloss.getGlossaryCatalog() index_extra = record() index_extra.default_encoding = "utf-8" try: catalog_obj.manage_addIndex(language_name, "TextIndexNG2", index_extra) except: pass gloss.set_languages_list(language, language_name) gloss.updateObjectsByLang(language_name) gloss._p_changed = 1 except: pass
def test_len(self): from ZPublisher.HTTPRequest import record record = record() record.a = 1 record.b = 2 record.c = 3 self.assertEqual(len(record), 3)
def gl_add_site_language_custom(self, language): #this is called to handle other types of multilanguage objects catalog_tool = self.getCatalogTool() for b in self.getCatalogedBrains( meta_type=[METATYPE_NYPHOTOFOLDER, METATYPE_NYPHOTO]): x = catalog_tool.getobject(b.data_record_id_) try: x.add_language(language) except: pass for r in self.objectValues(METATYPE_NYNETREPOSITORY): try: r.add_language(language) except: pass for gloss in self.objectValues(NAAYAGLOSSARY_CENTRE_METATYPE): try: language_name = self.gl_get_language_name(language) catalog_obj = gloss.getGlossaryCatalog() index_extra = record() index_extra.default_encoding = 'utf-8' try: catalog_obj.manage_addIndex(language_name, 'TextIndexNG2', index_extra) except: pass gloss.set_languages_list(language, language_name) gloss.updateObjectsByLang(language_name) gloss._p_changed = 1 except: pass
def test_likert_html_output(self): """Failing test for #225, AttributeError: __len__" in Plone 2.5.5""" rating_req_val = record() rating_req_val.__dict__ = {"1": "2", "2": "3"} request = FakeRequest( topic="test subject", replyto="*****@*****.**", comments="test comments", lf=rating_req_val ) self.assertTrue("1: 2, 2: 3" in self.ff1.lf.htmlValue(request))
def test_iter(self): from ZPublisher.HTTPRequest import record record = record() record.a = 1 record.b = 2 record.c = 3 for k in record: self.assertTrue(k in ('a', 'b', 'c'))
def test_repr(self): from ZPublisher.HTTPRequest import record rec = record() rec.a = 1 rec.b = 'foo' r = repr(rec) d = eval(r) self.assertEqual(d, rec.__dict__)
def test_iter(self): from ZPublisher.HTTPRequest import record record = record() record.a = 1 record.b = 2 record.c = 3 for k in record: self.assertTrue(k in ('a','b','c'))
def test_likert_html_output(self): """Failing test for #225, AttributeError: __len__" in Plone 2.5.5""" rating_req_val = record() rating_req_val.__dict__ = {'1': '2', '2': '3'} request = FakeRequest(topic='test subject', replyto='*****@*****.**', comments='test comments', lf=rating_req_val) self.assertTrue('1: 2, 2: 3' in self.ff1.lf.htmlValue(request))
def add_language(glossary, lang, english_name): glossary.set_languages_list(lang, english_name) glossary.updateObjectsByLang(english_name) catalog_obj = glossary.getGlossaryCatalog() from ZPublisher.HTTPRequest import record index_extra = record() index_extra.default_encoding = 'utf-8' catalog_obj.manage_addIndex(glossary.cookCatalogIndex(english_name), 'TextIndexNG3', index_extra)
def add_language(glossary, lang, english_name): glossary.set_languages_list(lang, english_name) glossary.updateObjectsByLang(english_name) catalog_obj = glossary.getGlossaryCatalog() from ZPublisher.HTTPRequest import record index_extra = record() index_extra.default_encoding = 'utf-8' catalog_obj.manage_addIndex(glossary.cookCatalogIndex(english_name), 'TextIndexNG3',index_extra)
def handle_search(self, action, data): if 'form.created' in self.request.form: del self.request.form['form.created'] if 'created' in data and data['created']: created = record() created.query = DateTime(str(data['created'])) created.range = 'min' self.request.form['form.created'] = created return self._setRedirect('portal_actions', 'global/search', 'review_state,SearchableText,Title,Subject,' 'Description,created,portal_type,' 'listCreators')
def __generateDefaultIndexes(self): available_indexes = self.indexes() available_metadata = self.schema() #create indexes for index in self._getDefaultIndexes(): if not (index in available_indexes): if self._getIndexById(index) == 'TextIndexNG3': p_extras = record() p_extras.default_encoding = 'utf-8' p_extras.splitter_single_chars = 1 else: p_extras = None self.addIndex(index, self._getIndexById(index), p_extras) if not (index in available_metadata): self.addColumn(index)
def test_referenceField(self): name = 'refField' self.container.atse_addField(self.target1.portal_type, 'default', '', name) field_data = {'type': 'ReferenceField', 'schemata': 'default', 'name': name, 'widget': 'ReferenceBrowserWidget', 'label': 'refField', 'storage': 'Attribute', 'relationship': 'testRelation'} fd = record() for key, value in field_data.items(): setattr(fd, key, value) self.container.atse_update(self.target1.portal_type, '', fd, self.container.REQUEST) self.container.atse_updateManagedSchema(self.target1.portal_type, '', update_all=True) self.target1.addReference(self.target2, relationship='testRelation') field = self.target1.getField(name) self.failUnless(field.getAccessor(self.target1)() == self.target2) self.failUnless(field.getEditAccessor(self.target1)() == \ self.target2.UID())
newSecurityManager(app, user) from Testing.makerequest import makerequest app=makerequest(app) portal_id = 'openplans' portal = app._getOb(portal_id) # !!! YOU MUST SPECIFY 'FROM' AND 'TO' HOSTS HERE OR THIS SCRIPT WON'T # DO ANYTHING !!! old_hosts = [] new_host = '' cat = portal.portal_catalog if not 'text' in cat.Indexes: extra = record() extra.doc_attr = 'getText' extra.index_type = 'Cosine Measure' extra.lexicon_id = 'plaintext_lexicon' cat.addIndex('text', 'ZCTextIndex', extra=extra) cat.reindexIndex('text', app.REQUEST) transaction.get().note("Added and indexed 'text' index") transaction.commit() pathmap = dict() for old_host in old_hosts: matches = cat(text='href="%s' % old_host, Type='Page') for match in matches: path = match.getPath() if path not in pathmap: pathmap[path] = match
def test_contains(self): from ZPublisher.HTTPRequest import record record = record() record.a = 1 self.assertTrue('a' in record)
def _deserialize(kls, data): rec = record() for key, value in data.items(): setattr(rec, key, value) return rec
def _deserialize(cls, data): rec = record() for key, value in data.items(): setattr(rec, key, value) return rec
('none','No structuring'), ('publication_year', 'Publication Year'), ('portal_type', 'Reference Type'), ('AuthorItems', 'Single (Co)Authors'), ] + BIBLIOTOPIC_EXTENDEDSCHEMATA_STRUCTURAL_LAYOUT )) # monkey patch section BIBLIOGRAPHY_EXTENDED_SCHEMATA = True # do not touch this variable structure!!! unless you know what you are doing!!! actually do not touch anything in this file try: import Products.TextIndexNG2 # extra args for the TextIndexNG2 index to be added to portal_catalog, do not touch!!! ting2_extra = record() ting2_extra.indexed_fields = '' ting2_extra.default_encoding = 'utf-8' ting2_extra.use_converters = 0 text_index_type = { 'type': 'TextIndexNG2', 'extra': ting2_extra, } except ImportError: # do not at all touch zcti_extra, it is needed to created ZCTextIndex catalog indexes zcti_extra = record() zcti_extra.lexicon_id = 'plone_lexicon' zcti_extra.index_type = 'Okapi BM25 Rank' zcti_extra.doc_attr = None text_index_type = { 'type': 'ZCTextIndex', 'extra': zcti_extra, } try: from Products.CMFBibliographyAT_extended_schemata.config import BIBLIOTOPIC_EXTENDEDSCHEMATA_CRITERIAFIELDS
def _makeOne(self): from ZPublisher.HTTPRequest import record return record()