def __call__(self): fieldname = self.request.get('fieldname') #field = self.context.schema[fieldname] # TODO: This is hardcoded, Incredibly stupid, needs to change. atv = NamedVocabulary('staralliance.productcategories') tree = atv.getVocabularyDict(self.context) selected = self.request.get('selected', []).split('|') return JSONWriter().write(dict2dynatree(tree, selected, True, False))
def get_parliamentary_term(self, val): """ Return legislative type label for a given value """ vocabulary = NamedVocabulary("org.bungeni.metadata.vocabularies.parliamentarytypes") returnVal = None try: if vocabulary.getVocabularyDict(self)[val][0]: returnVal = vocabulary.getVocabularyDict(self)[val][0] except: returnVal = None return returnVal
def get_parliamentary_types(self): """ Fetch the Legislative Types from the vocabulary and return them back as a list """ legislative_types = [] legislative_vocab = NamedVocabulary("org.bungeni.metadata.vocabularies.parliamentarytypes") legislative_terms = legislative_vocab.getDisplayList(self).items() for term in legislative_terms: legislative_types.append( (term[0], term[1]) ) return legislative_types
def rows(self, names): output = [] wftool = self.wftool checkPermission = getSecurityManager().checkPermission credit_utils = self.context.unrestrictedTraverse('@@credit_utils') atvm = api.portal.get_tool(name='portal_vocabularies') nv = NamedVocabulary('ancient-name-languages') lang_vocab = nv.getVocabularyDict(atvm) for score, ob, nrefs in sorted(names, key=lambda k: k[1].Title() or ''): nameAttested = ob.getNameAttested() or None title = ob.Title() or "Untitled" if nameAttested: label, label_class = unicode( nameAttested, "utf-8"), "nameAttested" else: label, label_class = unicode( title, "utf-8"), "nameUnattested" labelLang = ob.getNameLanguage() or "und" review_state = wftool.getInfoFor(ob, 'review_state') item = u'<span lang="%s">%s</span>' % ( labelLang, label + u" (copy)" * ("copy" in ob.getId()), ) if checkPermission('View', ob): link = '<a class="state-%s %s" href="%s">%s</a>' % ( review_state, label_class, ob.absolute_url(), item) else: link = '<span class="state-%s %s">%s</span>' % ( review_state, label_class, item) if review_state != 'published': user = credit_utils.user_in_byline(ob.Creator()) status = u' [%s by %s]' % (review_state, user['fullname'].decode('utf-8')) else: status = u'' if labelLang != "und": lang_title = lang_vocab[labelLang] else: lang_title = None innerHTML = [ u'<li id="%s" class="placeChildItem" title="%s">' % ( ob.getId(), self.snippet(ob)), self.prefix(ob), link, self.postfix(ob, lang_title), status, u'</li>', ] output.append(u"\n".join(innerHTML)) return output
widget=atapi.StringWidget( label="Ordem de Serviço", description="Informe o número da ordem de serviço.", ), searchable=True, ), atapi.LinesField( 'tipo', storage=atapi.AnnotationStorage(), widget=atapi.SelectionWidget( label="Tipo da OS", description="Selecione o tipo da ordem de serviço.", ), required=False, vocabulary=NamedVocabulary("""TipoOS"""), ), atapi.LinesField( 'politica', storage=atapi.AnnotationStorage(), widget=atapi.InAndOutWidget( label="Política pública", description="Selecione uma ou mais política pública.", ), enforceVocabulary=True, vocabulary=NamedVocabulary("""PoliticaPublica"""), required=True, searchable=True, ),
label_msgid="label_body_text", rows=25, i18n_domain="plone", allow_file_upload=zconf.ATDocument.allow_document_upload), ), StringField( name='soerCountry', required=False, mode='r', widget=SelectionWidget( label='Country', label_msgid='eea.soer_label_country', i18n_domain='eea.soer', format='select', ), vocabulary=NamedVocabulary('eea.soer.vocab.european_countries'), enforceVocabulary=False, ), StringField( name='geoCoverage', required=True, widget=SelectionWidget( label='Geographic coverage', label_msgid='eea.soer_label_geocoverage', description='Required', i18n_domain='eea.soer', format='select', ), vocabulary="getGeoCoverageVocabulary", enforceVocabulary=False, ),
def __call__(self, context): atv = NamedVocabulary('NACE') vocab = atv.getVocabularyDict(getSite()) tree = _createTermTree(TreeVocabulary.terms_factory(), vocab) return TreeVocabulary(tree)
def __call__(self): self.request.response.setHeader('Content-Type', 'text/xml') now = datetime.datetime.now() year_start = datetime.datetime(year=now.year, month=1, day=1) year_end = datetime.datetime(year=now.year, month=12, day=31) #maybe it should be done as timedelta of 1sec from previous year def getTextKeepHTML(value): """ Retrieve text content from html input while keeping the html """ value = escapeSpecialChars(value) return _toUnicode("<![CDATA[{0}]]>".format((value))) def getTextStripHTML(value): """ Retrieve text content from html input removing the html """ value = escapeSpecialChars(value) return BeautifulSoup(value, 'lxml').get_text() getText = getTextKeepHTML \ if self.request.get("keepHTML", "false") == "true"\ else getTextStripHTML #we extract some info here to simplify code down below spec = self.context.aq_parent effective = self.context.getEffectiveDate() if effective: publish_date = effective.asdatetime().date().strftime("%d/%m/%Y") else: publish_date = "" spec_modified = spec.modified().asdatetime().date().strftime( "%d/%m/%Y") latest_version = IGetVersions(self.context).latest_version() ref_area = u", ".join( [c.decode('utf-8') for c in self.context.getLocation()]) manager_id = spec.getManager_user_id() mtool = getToolByName(spec, 'portal_membership') manager_name = (mtool.getMemberInfo(manager_id) or {}).get('fullname', 'Missing') manager_name = manager_name.decode('utf-8') dpsir_vocab = NamedVocabulary('indicator_dpsir').getVocabularyDict( spec) typology_vocab = NamedVocabulary( 'indicator_typology').getVocabularyDict(spec) dpsir = dpsir_vocab.get(spec.getDpsir()) typology = typology_vocab.get(spec.getTypology()) dpsir_typology = "DPSIR: %s - Typology: %s" % (dpsir, _toUnicode(typology)) themes_vocab = dict(spec._getMergedThemes()) themes = ", ".join([themes_vocab.get(l) for l in spec.getThemes()]) #let's use the already well-formatted temporal coverage browser view temporal_coverage = getMultiAdapter((self.context, self.request), name=u'formatTempCoverage')() units = getText(spec.getUnits()) or u'Not available' data_sets = [ rel for rel in spec.getRelatedItems() if rel.portal_type == 'Data' ] ext_data_sets = [ rel for rel in spec.getRelatedItems() if rel.portal_type == 'ExternalDataSpec' ] out = "" for dataowner in data_sets: out += u" ".join( (_toUnicode(dataowner.Title()), dataowner.absolute_url())) out += u" " for provider_url in dataowner.getDataOwner(): org = spec.getOrganisationName(provider_url) if org: out += u" ".join((_toUnicode(org.Title), provider_url)) out += u" " for eds in ext_data_sets: out += u" ".join((_toUnicode(eds.Title()), eds.absolute_url())) out += u" " org = spec.getOrganisationName(eds.getProvider_url()) if org: out += u" ".join( (_toUnicode(org.Title), eds.getProvider_url())) out += u" " mrefs = [ b.getObject() for b in spec.getFolderContents( contentFilter={'portal_type': 'MethodologyReference'}) ] methodology_reference = getText("\n".join([ (o.Title() + "\n" + o.getDescription()) for o in mrefs ])) uncertainties = getText('Methodology uncertainty: ' +\ spec.getMethodology_uncertainty() +\ '\nData uncertainty: ' +\ spec.getData_uncertainty() +\ '\nRationale uncertainty: ' +\ spec.getRationale_uncertainty()) questions = [ b.getObject() for b in spec.getFolderContents( contentFilter={'portal_type': 'PolicyQuestion'}) ] qpart = "" if questions: main_q = None for q in questions: if q.getIs_key_question(): main_q = q if main_q is not None: qpart += "Key policy question: %s\n" % main_q.Title() for q in questions: if q == main_q: continue qpart += "Specific policy question: %s\n" % q.Title() user_needs = getText('Justification for indicator selection: '+\ spec.getRationale_justification()+ "\n" + qpart) methodology = getText(spec.getMethodology()) methodology_gapfilling = getText(spec.getMethodology_gapfilling()) indicator_definition = getText(spec.Title() + ". " + \ spec.getDefinition()) frequency_of_updates = getText(spec.get_frequency_of_updates()) #The xml construction E = ElementMaker(nsmap=NAMESPACES) header = E.Header( E.ID("DMBB_ESMSIPEEA_A"), E.Prepared(now.replace(microsecond=0).isoformat()), E.Sender(id="4D0"), E.DataSetID("DMBB_ESMSIPEEA_A_1353407791410"), E.DataSetAction("Append"), E.Extracted(now.replace(microsecond=0).isoformat()), E.ReportingBegin(year_start.replace(microsecond=0).isoformat()), E.ReportingEnd(year_end.replace(microsecond=0).isoformat()), ) M = ElementMaker(namespace=NAMESPACES['GenericMetadata'], nsmap=NAMESPACES) metadata = M.MetadataSet( M.MetadataStructureRef('ESMSIPEEA_MSD'), M.MetadataStructureAgencyRef("ESTAT"), M.ReportRef('ESMS_REPORT_FULL'), M.AttributeValueSet( M.TargetRef("FULL_ESMS"), M.TargetValues( M.ComponentValue("2013-A0", component="TIME_PERIOD", object="TimeDimension"), M.ComponentValue("4D0", component="DATA_PROVIDER", object="DataProvider"), M.ComponentValue("DMBB_ESMSIPEEA_A", component="DATAFLOW", object="DataFlow"), ), M.ReportedAttribute( #CONTACT M.Value(), M.ReportedAttribute( M.Value('European Environment Agency (EEA)'), conceptID="CONTACT_ORGANISATION", ), M.ReportedAttribute( M.Value('Not available'), conceptID="ORGANISATION_UNIT", ), M.ReportedAttribute( M.Value(manager_name), conceptID="CONTACT_NAME", ), M.ReportedAttribute( M.Value('Not available'), conceptID="CONTACT_FUNC", ), M.ReportedAttribute( M.Value('Kongens Nytorv 6, 1050, ' 'Copenhagen K, Denmark'), conceptID="CONTACT_MAIL", ), M.ReportedAttribute( M.Value('Not available'), conceptID="CONTACT_EMAIL", ), M.ReportedAttribute( M.Value('Not available'), conceptID="CONTACT_PHONE", ), M.ReportedAttribute( M.Value('Not applicable'), conceptID="CONTACT_FAX", ), conceptID="CONTACT", ), M.ReportedAttribute( #META_UPDATE M.Value(), M.ReportedAttribute( M.Value(publish_date), conceptID="META_CERTIFIED", ), M.ReportedAttribute( M.Value(publish_date), conceptID="META_POSTED", ), M.ReportedAttribute( M.Value(spec_modified), conceptID="META_LAST_UPDATE", ), conceptID="META_UPDATE", ), M.ReportedAttribute( #STAT_PRES M.Value(), M.ReportedAttribute( M.Value(indicator_definition), conceptID="DATA_DESCR", ), M.ReportedAttribute( M.Value(dpsir_typology), conceptID="CLASS_SYSTEM", ), M.ReportedAttribute( M.Value(themes), conceptID="COVERAGE_SECTOR", ), M.ReportedAttribute( M.Value("Not available"), conceptID="STAT_CONC_DEF", ), M.ReportedAttribute( M.Value("Not applicable"), conceptID="STAT_UNIT", ), M.ReportedAttribute( M.Value("Not available"), conceptID="STAT_POP", ), M.ReportedAttribute( M.Value(ref_area), conceptID="REF_AREA", ), M.ReportedAttribute( M.Value(temporal_coverage), conceptID="COVERAGE_TIME", ), M.ReportedAttribute( M.Value("Not available"), conceptID="BASE_PER", ), conceptID="STAT_PRES"), M.ReportedAttribute( M.Value(units), conceptID="UNIT_MEASURE", ), M.ReportedAttribute( M.Value("Not available"), conceptID="REF_PERIOD", ), M.ReportedAttribute( #INST_MANDATE M.Value(), M.ReportedAttribute( M.Value( "Regulation (EC) No 401/2009 of the European " "Parliament and of the Council of 23 April 2009 (available at " "http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=" "CELEX:32009R0401:EN:NOT)"), conceptID="INST_MAN_LA_OA", ), M.ReportedAttribute( M.Value( "Regulation (EC) No 401/2009 of the European " "Parliament and of the Council of 23 April 2009 (available at " "http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=" "CELEX:32009R0401:EN:NOT)"), conceptID="INST_MAN_SHAR", ), conceptID="INST_MANDATE", ), M.ReportedAttribute( #CONF M.Value(), M.ReportedAttribute( M.Value("Not applicable"), conceptID="CONF_DATA_TR", ), M.ReportedAttribute( M.Value("Not applicable"), conceptID="CONF_POLICY", ), conceptID="CONF", ), M.ReportedAttribute( #REL_POLICY M.Value(), M.ReportedAttribute( M.Value("Not available"), conceptID="REL_CAL_POLICY", ), M.ReportedAttribute( M.Value("Not available"), conceptID="REL_CAL_ACCESS", ), M.ReportedAttribute( M.Value("All EEA indicators are public"), conceptID="REL_POL_US_AC", ), conceptID="REL_POLICY", ), M.ReportedAttribute( M.Value("Not available"), M.ReportedAttribute( M.Value("Not available"), conceptID="NEWS_REL", ), M.ReportedAttribute( M.Value(latest_version.absolute_url()), conceptID="PUBLICATIONS", ), M.ReportedAttribute( M.Value( "https://www.eea.europa.eu/data-and-maps/indicators" ), conceptID="ONLINE_DB", ), M.ReportedAttribute( M.Value("Not available"), conceptID="MICRO_DAT_ACC", ), M.ReportedAttribute( M.Value( "Twitter: Indicators are automatically " "announced via EEA's Twitter channel (https://twitter.com/euenvironment), " "which users can follow. RSS feed: Indicators are automatically " "announced in a dedicated EEA indicators RSS feed " "(https://www.eea.europa.eu/data-and-maps/indicators/RSS2), which users can " "subscribe to. A catalogue of all indicators is available " "(https://www.eea.europa.eu/data-and-maps/indicators)." ), conceptID="DISS_OTHER", ), conceptID="DISS_FORMAT", ), M.ReportedAttribute( #ACCESS_DOC M.Value(), M.ReportedAttribute( M.Value(methodology_reference), conceptID="DOC_METHOD", ), M.ReportedAttribute( M.Value("Not available"), conceptID="QUALITY_DOC", ), conceptID="ACCESS_DOC", ), M.ReportedAttribute( #QUALITY_MGMNT M.Value(), M.ReportedAttribute( M.Value("Not available"), conceptID="QUALITY_ASSURE", ), M.ReportedAttribute( M.Value(uncertainties), conceptID="QUALITY_ASSMNT", ), conceptID="QUALITY_MGMNT", ), M.ReportedAttribute( #RELEVANCE M.Value(), M.ReportedAttribute( M.Value(user_needs), conceptID="USER_NEEDS", ), M.ReportedAttribute( M.Value("Not applicable"), conceptID="USER_SAT", ), M.ReportedAttribute( M.Value("Not available"), conceptID="COMPLETENESS", ), conceptID="RELEVANCE", ), M.ReportedAttribute( #ACCURACY M.Value(), M.ReportedAttribute( M.Value("Not available"), conceptID="ACCURACY_OVERALL", ), M.ReportedAttribute( M.Value("Not applicable"), conceptID="SAMPLING_ERR", ), M.ReportedAttribute( M.Value("Not applicable"), conceptID="NONSAMPLING_ERR", ), conceptID="ACCURACY", ), M.ReportedAttribute( #TIMELINESS_PUNCT M.Value(), M.ReportedAttribute( M.Value("Not available"), conceptID="TIMELINESS", ), M.ReportedAttribute( M.Value("Not available"), conceptID="PUNCTUALITY", ), conceptID="TIMELINESS_PUNCT", ), M.ReportedAttribute( #COMPARABILITY M.Value(), M.ReportedAttribute( M.Value("Not available"), M.ReportedAttribute( M.Value("Not available"), conceptID="COMPAR_GEO_COVER", ), M.ReportedAttribute( M.Value("Not available"), conceptID="COMPAR_GEO_COMMENT", ), conceptID="COMPAR_GEO", ), M.ReportedAttribute( M.Value("Not available"), M.ReportedAttribute( M.Value("Not available"), conceptID="COMPAR_TIME_COVER", ), M.ReportedAttribute( M.Value("Not available"), conceptID="COMPAR_TIME_COMMENT", ), conceptID="COMPAR_TIME", ), conceptID="COMPARABILITY", ), M.ReportedAttribute( #COHERENCE M.Value(), M.ReportedAttribute( M.Value("Not applicable"), conceptID="COHER_X_DOM", ), M.ReportedAttribute( M.Value("Not available"), conceptID="COHER_INTERNAL", ), conceptID="COHERENCE", ), M.ReportedAttribute( M.Value("Not applicable"), conceptID="COST_BURDEN", ), M.ReportedAttribute( #DATA_REV M.Value(), M.ReportedAttribute( M.Value( "Indicator assessments are peer reviewed and " "CSIs go under extended country review process. Previous versions of " "indicators are available. Data coming from EEA's data flows have their own " "QA procedure. The quality of third part data is under responsibily of " "respective data providers."), conceptID="REV_POLICY", ), M.ReportedAttribute( M.Value( "Indicator assessments are peer reviewed and " "CSIs go under extended country review process. Previous versions of " "indicators are available. Data coming from EEA's data flows have their own " "QA procedure. The quality of third part data is under responsibily of " "respective data providers."), conceptID="REV_PRACTICE", ), conceptID="DATA_REV", ), M.ReportedAttribute( #STAT_PROCESS M.Value(), M.ReportedAttribute( M.Value(out), conceptID="SOURCE_TYPE", ), M.ReportedAttribute( M.Value("Not available"), conceptID="FREQ_COLL", ), M.ReportedAttribute( M.Value("Not available"), conceptID="COLL_METHOD", ), M.ReportedAttribute( M.Value("Not available"), conceptID="DATA_VALIDATION", ), M.ReportedAttribute( M.Value(methodology), conceptID="DATA_COMP", ), M.ReportedAttribute( M.Value(methodology_gapfilling), conceptID="ADJUSTMENT", ), M.ReportedAttribute( M.Value(frequency_of_updates), conceptID="FREQ_DISS", ), conceptID="STAT_PROCESS", ), M.ReportedAttribute( M.Value( "Please note that more metadata and additional " "information about this indicator is available online at %s. For technical " "issues contact EEA web team at https://www.eea.europa.eu/help/contact-info. " "Metadata extracted automatically by EEA IMS at %s." % (self.context.absolute_url(), now.isoformat())), conceptID="COMMENT_DSET", ), ), ) xsi = "http://www.w3.org/2001/XMLSchema-instance" schemaLocation = "http://www.SDMX.org/resources/SDMXML/schemas/v2_0/genericmetadata SDMXGenericMetadata.xsd " \ "http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message SDMXMessage.xsd" root = lxml.etree.Element( nsel("GenericMetadata"), attrib={"{" + xsi + "}schemaLocation": schemaLocation}, nsmap=NAMESPACES) root.append(header) root.append(metadata) return lxml.etree.tostring(root, pretty_print=True, xml_declaration=True, encoding='UTF-8', standalone="yes")
from Products.Archetypes.atapi import * from Products.Archetypes.config import PKG_NAME from AccessControl import ClassSecurityInfo from Products.ATVocabularyManager import NamedVocabulary from collective.dynatree.atwidget import DynatreeWidget schema = BaseSchema + Schema(( StringField('single_leafs', required=0, vocabulary=NamedVocabulary('ch.scb.disposition'), widget=DynatreeWidget( description="Select one option of tree. Only leafs allowed", leafsOnly=True, selectMode=1), ), StringField('single_all', required=0, vocabulary=NamedVocabulary('ch.scb.disposition'), widget=DynatreeWidget( description="""Select one option of tree. Nodes allowed too. Autocollapse is switched on.""", selectMode=1, rootVisible=True, autoCollapse=True), ), LinesField('multiple_leafs', required=0, vocabulary=NamedVocabulary('ch.scb.disposition'), widget=DynatreeWidget( description="""Select multiple options of tree. Leafs only.""", leafsOnly=True,
def __call__(self): self.request.response.setHeader('Content-Type', 'text/xml') now = datetime.datetime.now() year_start = datetime.datetime(year=now.year, month=1, day=1) year_end = datetime.datetime(year=now.year, month=12, day=31) #maybe it should be done as timedelta of 1sec from previous year def getTextKeepHTML(value): """ Retrieve text content from html input while keeping the html """ value = escapeSpecialChars(value) return _toUnicode("<![CDATA[{0}]]>".format((value))) def getTextStripHTML(value): """ Retrieve text content from html input removing the html """ value = escapeSpecialChars(value) return BeautifulSoup(value, 'lxml').get_text() getText = getTextKeepHTML \ if self.request.get("keepHTML", "false") == "true"\ else getTextStripHTML #we extract some info here to simplify code down below spec = self.context.aq_parent effective = self.context.getEffectiveDate() if effective: publish_date = effective.asdatetime().date().strftime("%d/%m/%Y") else: publish_date = "" spec_modified = spec.modified().asdatetime().date().strftime("%d/%m/%Y") latest_version = IGetVersions(self.context).latest_version() ref_area = u", ".join([c.decode('utf-8') for c in self.context.getLocation()]) manager_id = spec.getManager_user_id() mtool = getToolByName(spec, 'portal_membership') manager_name = (mtool.getMemberInfo(manager_id) or {}).get('fullname', 'Missing') manager_name = manager_name.decode('utf-8') dpsir_vocab = NamedVocabulary('indicator_dpsir' ).getVocabularyDict(spec) typology_vocab = NamedVocabulary('indicator_typology' ).getVocabularyDict(spec) dpsir = dpsir_vocab.get(spec.getDpsir()) typology = typology_vocab.get(spec.getTypology()) dpsir_typology = "DPSIR: %s - Typology: %s" % (dpsir, _toUnicode(typology)) themes_vocab = dict(spec._getMergedThemes()) themes = ", ".join([themes_vocab.get(l) for l in spec.getThemes()]) #let's use the already well-formatted temporal coverage browser view temporal_coverage = getMultiAdapter( (self.context, self.request), name=u'formatTempCoverage')() units = getText(spec.getUnits()) or u'Not available' data_sets = [rel for rel in spec.getRelatedItems() if rel.portal_type == 'Data'] ext_data_sets = [rel for rel in spec.getRelatedItems() if rel.portal_type == 'ExternalDataSpec'] out = "" for dataowner in data_sets: out += u" ".join((_toUnicode(dataowner.Title()), dataowner.absolute_url())) out += u" " for provider_url in dataowner.getDataOwner(): org = spec.getOrganisationName(provider_url) if org: out += u" ".join((_toUnicode(org.Title), provider_url)) out += u" " for eds in ext_data_sets: out += u" ".join((_toUnicode(eds.Title()), eds.absolute_url())) out += u" " org = spec.getOrganisationName(eds.getProvider_url()) if org: out += u" ".join((_toUnicode(org.Title), eds.getProvider_url())) out += u" " mrefs = [b.getObject() for b in spec.getFolderContents( contentFilter={'portal_type':'MethodologyReference'})] methodology_reference = getText( "\n".join( [(o.Title() + "\n" + o.getDescription()) for o in mrefs])) uncertainties = getText('Methodology uncertainty: ' +\ spec.getMethodology_uncertainty() +\ '\nData uncertainty: ' +\ spec.getData_uncertainty() +\ '\nRationale uncertainty: ' +\ spec.getRationale_uncertainty()) questions = [b.getObject() for b in spec.getFolderContents( contentFilter={'portal_type':'PolicyQuestion'})] qpart = "" if questions: main_q = None for q in questions: if q.getIs_key_question(): main_q = q if main_q is not None: qpart += "Key policy question: %s\n" % main_q.Title() for q in questions: if q == main_q: continue qpart += "Specific policy question: %s\n" % q.Title() user_needs = getText('Justification for indicator selection: '+\ spec.getRationale_justification()+ "\n" + qpart) methodology = getText(spec.getMethodology()) methodology_gapfilling = getText(spec.getMethodology_gapfilling()) indicator_definition = getText(spec.Title() + ". " + \ spec.getDefinition()) frequency_of_updates = getText(spec.get_frequency_of_updates()) #The xml construction E = ElementMaker(nsmap=NAMESPACES) header = E.Header( E.ID("DMBB_ESMSIPEEA_A"), E.Prepared(now.replace(microsecond=0).isoformat()), E.Sender(id="4D0"), E.DataSetID("DMBB_ESMSIPEEA_A_1353407791410"), E.DataSetAction("Append"), E.Extracted(now.replace(microsecond=0).isoformat()), E.ReportingBegin(year_start.replace(microsecond=0).isoformat()), E.ReportingEnd(year_end.replace(microsecond=0).isoformat()), ) M = ElementMaker(namespace=NAMESPACES['GenericMetadata'], nsmap=NAMESPACES) metadata = M.MetadataSet( M.MetadataStructureRef('ESMSIPEEA_MSD'), M.MetadataStructureAgencyRef("ESTAT"), M.ReportRef('ESMS_REPORT_FULL'), M.AttributeValueSet( M.TargetRef("FULL_ESMS"), M.TargetValues( M.ComponentValue("2013-A0", component="TIME_PERIOD", object="TimeDimension"), M.ComponentValue("4D0", component="DATA_PROVIDER", object="DataProvider"), M.ComponentValue("DMBB_ESMSIPEEA_A", component="DATAFLOW", object="DataFlow"), ), M.ReportedAttribute( #CONTACT M.Value(), M.ReportedAttribute( M.Value('European Environment Agency (EEA)'), conceptID="CONTACT_ORGANISATION", ), M.ReportedAttribute( M.Value('Not available'), conceptID="ORGANISATION_UNIT", ), M.ReportedAttribute( M.Value(manager_name), conceptID="CONTACT_NAME", ), M.ReportedAttribute( M.Value('Not available'), conceptID="CONTACT_FUNC", ), M.ReportedAttribute( M.Value('Kongens Nytorv 6, 1050, ' 'Copenhagen K, Denmark'), conceptID="CONTACT_MAIL", ), M.ReportedAttribute( M.Value('Not available'), conceptID="CONTACT_EMAIL", ), M.ReportedAttribute( M.Value('Not available'), conceptID="CONTACT_PHONE", ), M.ReportedAttribute( M.Value('Not applicable'), conceptID="CONTACT_FAX", ), conceptID="CONTACT", ), M.ReportedAttribute( #META_UPDATE M.Value(), M.ReportedAttribute( M.Value(publish_date), conceptID="META_CERTIFIED", ), M.ReportedAttribute( M.Value(publish_date), conceptID="META_POSTED", ), M.ReportedAttribute( M.Value(spec_modified), conceptID="META_LAST_UPDATE", ), conceptID="META_UPDATE", ), M.ReportedAttribute( #STAT_PRES M.Value(), M.ReportedAttribute( M.Value(indicator_definition), conceptID="DATA_DESCR", ), M.ReportedAttribute( M.Value(dpsir_typology), conceptID="CLASS_SYSTEM", ), M.ReportedAttribute( M.Value(themes), conceptID="COVERAGE_SECTOR", ), M.ReportedAttribute( M.Value("Not available"), conceptID="STAT_CONC_DEF", ), M.ReportedAttribute( M.Value("Not applicable"), conceptID="STAT_UNIT", ), M.ReportedAttribute( M.Value("Not available"), conceptID="STAT_POP", ), M.ReportedAttribute( M.Value(ref_area), conceptID="REF_AREA", ), M.ReportedAttribute( M.Value(temporal_coverage), conceptID="COVERAGE_TIME", ), M.ReportedAttribute( M.Value("Not available"), conceptID="BASE_PER", ), conceptID="STAT_PRES" ), M.ReportedAttribute( M.Value(units), conceptID="UNIT_MEASURE", ), M.ReportedAttribute( M.Value("Not available"), conceptID="REF_PERIOD", ), M.ReportedAttribute( #INST_MANDATE M.Value(), M.ReportedAttribute( M.Value("Regulation (EC) No 401/2009 of the European " "Parliament and of the Council of 23 April 2009 (available at " "http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=" "CELEX:32009R0401:EN:NOT)"), conceptID="INST_MAN_LA_OA", ), M.ReportedAttribute( M.Value("Regulation (EC) No 401/2009 of the European " "Parliament and of the Council of 23 April 2009 (available at " "http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=" "CELEX:32009R0401:EN:NOT)"), conceptID="INST_MAN_SHAR", ), conceptID="INST_MANDATE", ), M.ReportedAttribute( #CONF M.Value(), M.ReportedAttribute( M.Value("Not applicable"), conceptID="CONF_DATA_TR", ), M.ReportedAttribute( M.Value("Not applicable"), conceptID="CONF_POLICY", ), conceptID="CONF", ), M.ReportedAttribute( #REL_POLICY M.Value(), M.ReportedAttribute( M.Value("Not available"), conceptID="REL_CAL_POLICY", ), M.ReportedAttribute( M.Value("Not available"), conceptID="REL_CAL_ACCESS", ), M.ReportedAttribute( M.Value("All EEA indicators are public"), conceptID="REL_POL_US_AC", ), conceptID="REL_POLICY", ), M.ReportedAttribute( M.Value("Not available"), M.ReportedAttribute( M.Value("Not available"), conceptID="NEWS_REL", ), M.ReportedAttribute( M.Value(latest_version.absolute_url()), conceptID="PUBLICATIONS", ), M.ReportedAttribute( M.Value( "https://www.eea.europa.eu/data-and-maps/indicators"), conceptID="ONLINE_DB", ), M.ReportedAttribute( M.Value("Not available"), conceptID="MICRO_DAT_ACC", ), M.ReportedAttribute( M.Value("Twitter: Indicators are automatically " "announced via EEA's Twitter channel (https://twitter.com/euenvironment), " "which users can follow. RSS feed: Indicators are automatically " "announced in a dedicated EEA indicators RSS feed " "(https://www.eea.europa.eu/data-and-maps/indicators/RSS2), which users can " "subscribe to. A catalogue of all indicators is available " "(https://www.eea.europa.eu/data-and-maps/indicators)."), conceptID="DISS_OTHER", ), conceptID="DISS_FORMAT", ), M.ReportedAttribute( #ACCESS_DOC M.Value(), M.ReportedAttribute( M.Value(methodology_reference), conceptID="DOC_METHOD", ), M.ReportedAttribute( M.Value("Not available"), conceptID="QUALITY_DOC", ), conceptID="ACCESS_DOC", ), M.ReportedAttribute( #QUALITY_MGMNT M.Value(), M.ReportedAttribute( M.Value("Not available"), conceptID="QUALITY_ASSURE", ), M.ReportedAttribute( M.Value(uncertainties), conceptID="QUALITY_ASSMNT", ), conceptID="QUALITY_MGMNT", ), M.ReportedAttribute( #RELEVANCE M.Value(), M.ReportedAttribute( M.Value(user_needs), conceptID="USER_NEEDS", ), M.ReportedAttribute( M.Value("Not applicable"), conceptID="USER_SAT", ), M.ReportedAttribute( M.Value("Not available"), conceptID="COMPLETENESS", ), conceptID="RELEVANCE", ), M.ReportedAttribute( #ACCURACY M.Value(), M.ReportedAttribute( M.Value("Not available"), conceptID="ACCURACY_OVERALL", ), M.ReportedAttribute( M.Value("Not applicable"), conceptID="SAMPLING_ERR", ), M.ReportedAttribute( M.Value("Not applicable"), conceptID="NONSAMPLING_ERR", ), conceptID="ACCURACY", ), M.ReportedAttribute( #TIMELINESS_PUNCT M.Value(), M.ReportedAttribute( M.Value("Not available"), conceptID="TIMELINESS", ), M.ReportedAttribute( M.Value("Not available"), conceptID="PUNCTUALITY", ), conceptID="TIMELINESS_PUNCT", ), M.ReportedAttribute( #COMPARABILITY M.Value(), M.ReportedAttribute( M.Value("Not available"), M.ReportedAttribute( M.Value("Not available"), conceptID="COMPAR_GEO_COVER", ), M.ReportedAttribute( M.Value("Not available"), conceptID="COMPAR_GEO_COMMENT", ), conceptID="COMPAR_GEO", ), M.ReportedAttribute( M.Value("Not available"), M.ReportedAttribute( M.Value("Not available"), conceptID="COMPAR_TIME_COVER", ), M.ReportedAttribute( M.Value("Not available"), conceptID="COMPAR_TIME_COMMENT", ), conceptID="COMPAR_TIME", ), conceptID="COMPARABILITY", ), M.ReportedAttribute( #COHERENCE M.Value(), M.ReportedAttribute( M.Value("Not applicable"), conceptID="COHER_X_DOM", ), M.ReportedAttribute( M.Value("Not available"), conceptID="COHER_INTERNAL", ), conceptID="COHERENCE", ), M.ReportedAttribute( M.Value("Not applicable"), conceptID="COST_BURDEN", ), M.ReportedAttribute( #DATA_REV M.Value(), M.ReportedAttribute( M.Value("Indicator assessments are peer reviewed and " "CSIs go under extended country review process. Previous versions of " "indicators are available. Data coming from EEA's data flows have their own " "QA procedure. The quality of third part data is under responsibily of " "respective data providers."), conceptID="REV_POLICY", ), M.ReportedAttribute( M.Value("Indicator assessments are peer reviewed and " "CSIs go under extended country review process. Previous versions of " "indicators are available. Data coming from EEA's data flows have their own " "QA procedure. The quality of third part data is under responsibily of " "respective data providers."), conceptID="REV_PRACTICE", ), conceptID="DATA_REV", ), M.ReportedAttribute( #STAT_PROCESS M.Value(), M.ReportedAttribute( M.Value(out), conceptID="SOURCE_TYPE", ), M.ReportedAttribute( M.Value("Not available"), conceptID="FREQ_COLL", ), M.ReportedAttribute( M.Value("Not available"), conceptID="COLL_METHOD", ), M.ReportedAttribute( M.Value("Not available"), conceptID="DATA_VALIDATION", ), M.ReportedAttribute( M.Value(methodology), conceptID="DATA_COMP", ), M.ReportedAttribute( M.Value(methodology_gapfilling), conceptID="ADJUSTMENT", ), M.ReportedAttribute( M.Value(frequency_of_updates), conceptID="FREQ_DISS", ), conceptID="STAT_PROCESS", ), M.ReportedAttribute( M.Value("Please note that more metadata and additional " "information about this indicator is available online at %s. For technical " "issues contact EEA web team at https://www.eea.europa.eu/help/contact-info. " "Metadata extracted automatically by EEA IMS at %s." % (self.context.absolute_url(), now.isoformat())), conceptID="COMMENT_DSET", ), ), ) xsi = "http://www.w3.org/2001/XMLSchema-instance" schemaLocation = "http://www.SDMX.org/resources/SDMXML/schemas/v2_0/genericmetadata SDMXGenericMetadata.xsd " \ "http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message SDMXMessage.xsd" root = lxml.etree.Element(nsel("GenericMetadata"), attrib={ "{" + xsi + "}schemaLocation": schemaLocation}, nsmap=NAMESPACES) root.append(header) root.append(metadata) return lxml.etree.tostring(root, pretty_print=True, xml_declaration=True, encoding='UTF-8', standalone="yes")
multiValued=True, widget=ReferenceBrowserWidget(label='Affected registered services', description='All registered services and components unavailable during downtime', allow_browse=1, startup_directory_method='getStartupDirectory', ), ), ateapi.UrlField('reason', widget=ateapi.UrlWidget(label='Reason', description='Optional URL to the change management document providing the reason for this downtime.', ), ), atapi.StringField('severity', searchable=1, default='warning', vocabulary=NamedVocabulary('severity_levels'), widget=atapi.SelectionWidget(label='Severity', ), ), atapi.StringField('classification', searchable=1, default='scheduled', vocabulary=NamedVocabulary('downtime_classes'), widget=atapi.SelectionWidget(label='Classification', ), ), )) schemata.finalizeATCTSchema(DowntimeSchema, moveDiscussion=False)
from rendereasy.cna.interfaces import ICNADestaque from rendereasy.cna.config import PROJECTNAME from Products.ATVocabularyManager import NamedVocabulary from DateTime.DateTime import * from Products.CMFPlone.utils import getToolByName from string import join CNADestaqueSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema(( # -*- Your Archetypes field definitions here ... -*- atapi.LinesField( 'veiculo', storage=atapi.AnnotationStorage(), widget=atapi.SelectionWidget(label=_(u"Veículo"), ), vocabulary=NamedVocabulary("veiculos"), required=True, ), atapi.DateTimeField( 'data', storage=atapi.AnnotationStorage(), widget=atapi.CalendarWidget( label=_(u"Data"), starting_year='2017', show_hm=False, ), required=True, validators=('isValidDate'), default_method='getDefaultTime', ), atapi.TextField(
# atapi.LinesField( # name='recebedor', # widget=atapi.InAndOutWidget( # label="Entregue para", # ), # vocabulary='getListaProgramacao', # ), )) # Set storage on fields copied from ATFolderSchema, making sure # they work well with the python bridge properties. ChamadaSchema['title'].storage = atapi.AnnotationStorage() ChamadaSchema["title"].widget = atapi.SelectionWidget() ChamadaSchema['title'].widget.label = "Programa" ChamadaSchema['title'].vocabulary = NamedVocabulary("""programa""") ChamadaSchema['description'].storage = atapi.AnnotationStorage() ChamadaSchema['description'].widget.label = "Observações" ChamadaSchema['description'].widget.description = "" ChamadaSchema['location'].widget.visible = { "edit": "invisible", "view": "invisible" } ChamadaSchema['language'].widget.visible = { "edit": "invisible", "view": "invisible" } ChamadaSchema['effectiveDate'].widget.visible = { "edit": "invisible", "view": "invisible"
def getServiceType(self, component): serviceType = component.getService_type() vocabulary = NamedVocabulary('service_types') vocabulary = vocabulary.getVocabularyDict(component) return vocabulary[serviceType]
atapi.StringField( 'ticketid', widget=atapi.StringWidget( label="Ticket ID", description="Once a ticket in EUDAT's Trouble Ticket " "System (TTS) has been created its ID can be entered " "here for easy reference.", ), ), )) ConditionsFields = atapi.Schema(( atapi.LinesField( 'scopes', required=1, vocabulary=NamedVocabulary('scope_vocabulary'), widget=atapi.MultiSelectionWidget( description='Tick all that apply. ' 'If in doubt, select "EUDAT".', format='checkbox', ), ), ateapi.CommentField( 'conditions', comment='Any constraints that need to be satisfied by the ' 'customer:', ), atapi.StringField( 'regional_constraints', searchable=True, widget=atapi.StringWidget(label='Regional constraints'),
def testNamedVocab(self): self.setupSimpleVocabulary() svtest = self.atvm.svtest nv = NamedVocabulary(self.vname) # vocabs are the same self.assertEqual(nv.getVocabulary(self.atvm), svtest) vocab = svtest.getVocabularyDict() # dict vocab are the same self.assertEqual(nv.getVocabularyDict(self.atvm), vocab) # 5 items in place self.assertEqual(len(svtest), len(nv.getVocabulary(self.atvm)), 5) # in display list too self.assertEqual(len(nv.getDisplayList(self.atvm)), 5) # let's test `empty_first_item` option nv1 = NamedVocabulary(self.vname, empty_first_item=1) # vocab are still the same self.assertEqual(nv1.getVocabulary(self.atvm), svtest) # 5 items in place self.assertEqual(len(nv1.getVocabulary(self.atvm)), 5) # but 6 items in display list dlist = nv1.getDisplayList(self.atvm) self.assertEqual(len(dlist), 6) # and we have an empty item on top empty_item = (u'', u'--') self.failUnless(empty_item in dlist.items()) self.assertEqual(empty_item, dlist.items()[0]) # now use a `custom_empty_first_item` custom_item = (u'foo', u'Foo') nv2 = NamedVocabulary(self.vname, empty_first_item=1, custom_empty_first_item=[custom_item]) # vocab are still the same self.assertEqual(nv2.getVocabulary(self.atvm), svtest) # 5 items in place self.assertEqual(len(nv2.getVocabulary(self.atvm)), 5) # but 6 items in display list dlist = nv2.getDisplayList(self.atvm) self.assertEqual(len(dlist), 6) # and we have an empty item on top self.failUnless(custom_item in dlist.items()) self.assertEqual(custom_item, dlist.items()[0])
ComputedField( 'studentemplid', searchable=0, expression='context._computeStudentEmplid()', accessor='getStudentemplid', ), atapi.StringField( 'psterm', storage=atapi.AnnotationStorage(), widget=atapi.SelectionWidget( label=_(u"Academic term"), description= _(u"Please select the academic term for the class you would like to add" ), ), vocabulary=NamedVocabulary("PSSemesters"), # vocabulary="getPSSemesters", default_method="setDefaultPsterm", required=True, ), atapi.StringField( 'creditaudit', storage=atapi.AnnotationStorage(), widget=atapi.SelectionWidget( label=_(u"Credit or Audit"), description=_( u"Please select if the added class will be for Credit or Audit" ), ), vocabulary=( "Credit",
name='topic', required=False, default=u'country introduction', widget=StringWidget(label='Topics', label_msgid='eea.soer_label_topics', i18n_domain='eea.soer', visible={ 'view': 'invisible', 'edit': 'invisible' }, description='country introduction'), ), ), ) schema = SOERReportSchema.copy() + ThemeTaggable_schema.copy() + schema schema['question'].vocabulary = \ NamedVocabulary('eea.soer.vocab.diversity_questions') class DiversityReport(SOERReport, ThemeTaggable): """ Diversity Report """ security = ClassSecurityInfo() implements(IDiversityReport) meta_type = 'DiversityReport' portal_type = 'DiversityReport' schema = schema default_view = 'diversity_report_view' def getLongSoerQuestion(self):
def getPsterm(self): vocab = NamedVocabulary("PSSemesters") try: displayval = vocab.getVocabularyDict(self)[self.psterm] except KeyError, e: retstr = ""
name='apresentador', widget=atapi.InAndOutWidget( label="Apresentador", ), vocabulary='getListaApresentadores', ), atapi.LinesField( name='politica', widget=atapi.InAndOutWidget( label="Política Publica", description="Selecione uma ou mais política publica.", ), enforceVocabulary=True, vocabulary=NamedVocabulary("""PoliticaPublica"""), required=True, searchable=True, ), atapi.LinesField( name='midias', widget=atapi.InAndOutWidget( label="Mídias", description="Selecione uma ou mais mídia.", ), enforceVocabulary=True, vocabulary=NamedVocabulary("""Midias"""), required=True, searchable=True,
def archive(self, context, initiator=None, reason=None, custom_message=None, archive_date=None): """Archive the object :param context: given object that should be archived :param initiator: the user id or name which commissioned the archival :param reason: reason id for which the object was archived :param custom_message: Custom message explaining why the object was archived :param archive_date: DateTime object which sets the expiration date of the object """ initiator = safe_unicode(initiator) reason = safe_unicode(reason) custom_message = safe_unicode(custom_message) wftool = getToolByName(context, 'portal_workflow') has_workflow = wftool.getChainFor(context) if not has_workflow: # NOP return date = archive_date if archive_date else DateTime() alsoProvides(context, IObjectArchived) context.setExpirationDate(date) # refactor this setting from here, without these assignments to self # the test for is_archived fails self.archive_date = date self.initiator = initiator self.custom_message = custom_message self.reason = reason state = wftool.getInfoFor(context, 'review_state') mtool = getToolByName(context, 'portal_membership') actor = mtool.getAuthenticatedMember().getId() rv = NamedVocabulary('eea.workflow.reasons') vocab = rv.getVocabularyDict(context) reason = vocab.get(reason, "Other") if custom_message: reason += u" (%s)" % custom_message comments = (u"Archived by %(actor)s on %(date)s by request " u"from %(initiator)s with reason: %(reason)s" % { 'actor': actor, 'initiator': initiator, 'reason': reason, 'date': date.ISO8601() }) for wfname in context.workflow_history.keys(): history = context.workflow_history[wfname] history += ({ 'action': 'Archive', 'review_state': state, 'actor': actor, 'comments': comments, 'time': date, },) context.workflow_history[wfname] = history context.workflow_history._p_changed = True context.reindexObject() notify(ObjectModifiedEvent(context))
from bungenicms.repository.interfaces import IRepositoryItem, IRepositoryItemBrowser from bungenicms.repository.config import PROJECTNAME GROUPS_VOCAB = u"bungenicms_repository_groups_vocab" YEARS_VOCAB = u"bungenicms_repository_years_vocab" MONTHS_VOCAB = u"bungenicms_repository_months_vocab" DAYS_VOCAB = u"bungenicms_repository_days_vocab" #RepositoryItemSchema = ATFile.schema.copy() + atapi.Schema(( RepositoryItemSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema(( # -*- Your Archetypes field definitions here ... -*- atapi.StringField( 'legislative_type', required=1, vocabulary=NamedVocabulary( 'org.bungeni.metadata.vocabularies.parliamentarytypes'), widget=atapi.SelectionWidget( label=_('Type'), description=_('Choose the applicable document type'), ), ), atapi.LinesField( 'item_authors', required=1, multiValued=True, searchable=True, widget=atapi.LinesWidget( label=_('Source'), description=_('List the authors/sponsors of this item.'), cols=5, rows=2,
##/code-section module-header schema = Schema(( StringField( name='researchQuestionOrCreativeGoal', widget=SelectionWidget( label="Intellectual or Creative Merit**", description= "The proposal should clearly explain the project’s intellectual or creative merit, how the project is grounded in the theory and/or literature of the discipline, and the significance/importance/contribution of the project to the discipline", label_msgid='uwosh_grants_label_researchQuestionOrCreativeGoal', description_msgid= 'uwosh_grants_help_researchQuestionOrCreativeGoal', i18n_domain='uwosh_grants', ), required=1, vocabulary=NamedVocabulary("""ReviewFormResponse"""), ), StringField( name='methodologyAndDesign', widget=SelectionWidget( label="Methodology/Design", description= "The proposal should clearly explain the project’s research design; e.g. the hypotheses to be tested, questions to be explored, or creative activity to be undertaken, and the processes that will be used. This description should also spell out the roles of both the graduate student and mentors in the project.", label_msgid='uwosh_grants_label_methodologyAndDesign', description_msgid='uwosh_grants_help_methodologyAndDesign', i18n_domain='uwosh_grants', ), required=1, vocabulary=NamedVocabulary("""ReviewFormResponse"""), ), StringField(
read_permission='View internals', write_permission='Modify internals', relationship='contact_for', allowed_types=('Person', ), multiValued=True, widget=ReferenceBrowserWidget( label='Contact(s)', description='Contact person(s) for this specific component.', allow_browse=1, startup_directory='/people', ), ), atapi.StringField( 'service_type', searchable=1, vocabulary=NamedVocabulary('service_types'), widget=atapi.SelectionWidget(label='Service component type', ), ), atapi.StringField( 'service_url', searchable=1, widget=atapi.StringWidget( label='Service URL', description='[http|https|irods|gsiftp|ssh]://URL:port', ), ), BackReferenceField( 'parent_services', relationship='service_components', multiValued=True, widget=BackReferenceWidget(