def get_title_from_context(context): title = None if IAlchemistContent.providedBy(context): if IDCDescriptiveProperties.providedBy(context): title = context.title else: props = IDCDescriptiveProperties(context, None) if props is not None: title = props.title else: title = context.short_name elif IAlchemistContainer.providedBy(context): domain_model = context._class try: descriptor = queryModelDescriptor(domain_model) except: descriptor = None name = "" if descriptor: name = getattr(descriptor, 'container_name', None) if name is None: name = getattr(descriptor, 'display_name', None) if not name: name = getattr(context, '__name__', None) title = name elif ILocation.providedBy(context) and \ IDCDescriptiveProperties.providedBy(context): title = context.title return title
def _get_title_from_context(context): title = None if IAlchemistContent.providedBy(context): if IDCDescriptiveProperties.providedBy(context): title = context.title else: props = IDCDescriptiveProperties(context, None) if props is not None: title = props.title else: ''' !+ AttributeError: 'GroupAddress' object has no attribute 'short_name': File "/home/undesa/bungeni/cap_installs/bungeni_install/bungeni/releases/20100305100101/src/bungeni.main/bungeni/ui/viewlets/navigation.py", line 59, in _get_title_from_context #title = context.short_name So, we temporarily default the above to the context.__class__.__name__: ''' title = getattr(context, "short_name", context.__class__.__name__) elif IAlchemistContainer.providedBy(context): domain_model = context._class try: descriptor = queryModelDescriptor(domain_model) except: descriptor = None name = "" if descriptor: name = getattr(descriptor, 'container_name', None) if name is None: name = getattr(descriptor, 'display_name', None) if not name: name = getattr(context, '__name__', None) title = name elif ILocation.providedBy(context) and \ IDCDescriptiveProperties.providedBy(context): title = context.title return title
def changeTitle(self): """Given a sequence of tuples of old, new ids we rename""" request = self.request id = request.get("retitle_id") new = request.get("new_value") item = self.context[id] dc = IDCDescriptiveProperties(item) dc.title = new notify(ObjectModifiedEvent(item, Attributes(IZopeDublinCore, 'title')))
def form_name(self): if IVersion.providedBy(self.context): context = self.context.head else: context = self.context props = IDCDescriptiveProperties.providedBy(context) and context or IDCDescriptiveProperties(context) if self.is_translation: language = get_language_by_name(self.context.language)["name"] return _( u"edit_translation_legend", default=u"Editing $language translation of '$title'", mapping={"title": translate(props.title, context=self.request), "language": language}, ) elif IVersion.providedBy(self.context): return _( u"edit_version_legend", default=u'Editing "$title" (version $version)', mapping={"title": translate(props.title, context=self.request), "version": self.context.version_id}, ) return _( u"edit_item_legend", default=u'Editing "$title"', mapping={"title": translate(props.title, context=self.request)}, )
def add_container_menu_items(self, context, container): request = self.request _url = url.absoluteURL(container, request) if IReadContainer.providedBy(container): #XXX should be the same in all containers ? container=proxy.removeSecurityProxy(container) for name, item in container.items(): if context is None: selected = False else: selected = url.same_path_names(context.__name__, name) item = proxy.removeSecurityProxy(item) if IDCDescriptiveProperties.providedBy(item): title = item.title else: props = IDCDescriptiveProperties(item) title = props.title # only items with valid title if title is not None: self.items.append(url.get_menu_item_descriptor( title, selected, _url, name)) default_view_name = queryDefaultViewName(container, self.request) default_view = component.queryMultiAdapter( (container, self.request), name=default_view_name) if hasattr(default_view, "title") and default_view.title is not None: self.items.insert(0, url.get_menu_item_descriptor( default_view.title, sameProxiedObjects(container, self.context), _url))
def _get_title_from_context(context): title = None if IAlchemistContent.providedBy(context): if IDCDescriptiveProperties.providedBy(context): title = context.title else: props = IDCDescriptiveProperties(context, None) if props is not None: title = props.title else: """ !+ AttributeError: 'GroupAddress' object has no attribute 'short_name': File "/home/undesa/bungeni/cap_installs/bungeni_install/bungeni/releases/20100305100101/src/bungeni.main/bungeni/ui/viewlets/navigation.py", line 59, in _get_title_from_context #title = context.short_name So, we temporarily default the above to the context.__class__.__name__: """ title = getattr(context, "title", context.__class__.__name__) elif IWorkspaceContainer.providedBy(context): # WorkspaceContainer._class is not set (and not unique) and it breaks the # connection between Container -> ContentClass title = context.__name__ elif IAlchemistContainer.providedBy(context): domain_model = context._class try: descriptor = utils.get_descriptor(domain_model) except KeyError, e: log.warn("TYPE_INFO: no descriptor for model %s " "[container=%s] [error=%s]" % (domain_model, context, e)) descriptor = None name = "" if descriptor: name = getattr(descriptor, "container_name", None) if name is None: name = getattr(descriptor, "display_name", None) if not name: name = getattr(context, "__name__", None) title = name
def get_sitting_items(sitting, request, include_actions=False): items = [] if sitting.status in get_states("groupsitting", keys=["draft_agenda", "published_agenda"]): order = "planned_order" else: order = "real_order" schedulings = map(removeSecurityProxy, sitting.items.batch(order_by=order, limit=None)) site_url = url.absoluteURL(getSite(), request) for scheduling in schedulings: item = ProxyFactory(location_wrapped(scheduling.item, sitting)) props = IDCDescriptiveProperties.providedBy(item) and item or IDCDescriptiveProperties(item) discussions = tuple(scheduling.discussions.values()) discussion = discussions and discussions[0] or None truncated_discussion = None if (discussion is not None) and (discussion.body_text is not None): # truncate discussion to first hundred characters t_discussion = discussion.body_text[0:100] try: # truncate discussion to first two lines index = t_discussion.index("<br>") index2 = t_discussion.index("<br>", index + 4) truncated_discussion = t_discussion[0:index2] + "..." except ValueError: truncated_discussion = t_discussion + "..." info = IWorkflowInfo(item, None) state_title = info.workflow().workflow.states[item.status].title record = { "title": props.title, "description": props.description, "name": stringKey(scheduling), "status": item.status, "type": item.type.capitalize, "t": item.type, "state_title": state_title, #'category_id': scheduling.category_id, #'category': scheduling.category, "discussion": discussion, "truncated_discussion": truncated_discussion, "delete_url": "%s/delete" % url.absoluteURL(scheduling, request), "url": url.set_url_context(site_url + ("/business/%ss/obj-%s" % (item.type, item.parliamentary_item_id))), } if include_actions: record["actions"] = get_scheduling_actions(scheduling, request) record["workflow"] = get_workflow_actions(item, request) discussion_actions = get_discussion_actions(discussion, request) if discussion_actions: assert len(discussion_actions) == 1 record["discussion_action"] = discussion_actions[0] else: record["discussion_action"] = None items.append(record) return items
def get_sitting_items(sitting, request, include_actions=False): items = [] if sitting.status in IWorkflow(sitting).get_state_ids(keys=["draft_agenda", "published_agenda"]): order = "planned_order" else: order = "real_order" schedulings = map(removeSecurityProxy, sitting.items.batch(order_by=order, limit=None)) for scheduling in schedulings: item = ProxyFactory(location_wrapped(scheduling.item, sitting)) props = IDCDescriptiveProperties.providedBy(item) and item or IDCDescriptiveProperties(item) discussions = tuple(scheduling.discussions.values()) discussion = discussions and discussions[0] or None truncated_discussion = None if (discussion is not None) and (discussion.body is not None): # truncate discussion to first hundred characters t_discussion = discussion.body[0:100] try: # truncate discussion to first two lines index = t_discussion.index("<br>") index2 = t_discussion.index("<br>", index + 4) truncated_discussion = t_discussion[0:index2] + "..." except ValueError: truncated_discussion = t_discussion + "..." state_title = IWorkflow(item).get_state(item.status).title item = removeSecurityProxy(item) record = { "title": props.title, "description": props.description, "name": stringKey(scheduling), "status": item.status, "type": item.type.capitalize, "state_title": state_title, "heading": True if item.type == "heading" else False, # "category_id": scheduling.category_id, # "category": scheduling.category, "discussion": discussion, "truncated_discussion": truncated_discussion, "delete_url": "%s/delete" % url.absoluteURL(scheduling, request), "url": url.absoluteURL(item, request), } if include_actions: record["actions"] = get_scheduling_actions(scheduling, request) record["workflow"] = get_workflow_actions(item, request) discussion_actions = get_discussion_actions(discussion, request) if discussion_actions: assert len(discussion_actions) == 1 record["discussion_action"] = discussion_actions[0] else: record["discussion_action"] = None items.append(record) return items
def update(self): self.path = self._get_path(self.context) # if the view is a location, append this to the breadcrumbs if ILocation.providedBy(self.__parent__) and \ IDCDescriptiveProperties.providedBy(self.__parent__): self.path.append({ "name": self.__parent__.title, "url": None, }) self.chamber = get_chamber_for_context(self.context)
def add_container_menu_items(self, context, container): request = self.request # add a menu item for each user workspace, if we are in an # IWorkspaceSectionLayer # !+ if user is logged in or if request.layer_data if interfaces.IWorkspaceSectionLayer.providedBy(request): try: workspaces = IAnnotations(request)["layer_data"].get( "workspaces") except: workspaces = [] log.info("%s got user workspaces: %s" % (self, workspaces)) base_url_path = "/workspace" for workspace in workspaces: log.info("appending menu item for user workspace: %s" % str(workspace)) self.items.append( url.get_menu_item_descriptor( workspace.full_name, pos_action_in_url( "/workspace/obj-%s" % workspace.group_id, request.getURL()), base_url_path, "obj-%s" % workspace.group_id)) _url = url.absoluteURL(container, request) if IReadContainer.providedBy(container): #XXX should be the same in all containers ? container = proxy.removeSecurityProxy(container) for name, item in container.items(): if context is None: selected = False else: selected = url.same_path_names(context.__name__, name) item = proxy.removeSecurityProxy(item) if IDCDescriptiveProperties.providedBy(item): title = item.title else: props = IDCDescriptiveProperties(item) title = props.title # only items with valid title if title is not None: self.items.append( url.get_menu_item_descriptor(title, selected, _url, name)) default_view_name = queryDefaultViewName(container, self.request) default_view = component.queryMultiAdapter((container, self.request), name=default_view_name) if hasattr(default_view, "title") and default_view.title is not None: self.items.insert( 0, url.get_menu_item_descriptor( default_view.title, sameProxiedObjects(container, self.context), _url))
def update(self): self.path = self._get_path(self.context) # if the view is a location, append this to the breadcrumbs if ILocation.providedBy(self.__parent__) and IDCDescriptiveProperties.providedBy(self.__parent__): self.path.append({"name": self.__parent__.title, "url": None}) try: self.user_name = self.request.principal.login except: pass
def get_sitting_items(sitting, request, include_actions=False): items = [] if sitting.status in get_states("groupsitting", keys=["draft_agenda", "published_agenda"]): order = "planned_order" else: order = "real_order" schedulings = map( removeSecurityProxy, sitting.items.batch(order_by=order, limit=None)) site_url = url.absoluteURL(getSite(), request) for scheduling in schedulings: item = ProxyFactory(location_wrapped(scheduling.item, sitting)) props = IDCDescriptiveProperties.providedBy(item) and item or \ IDCDescriptiveProperties(item) discussions = tuple(scheduling.discussions.values()) discussion = discussions and discussions[0] or None info = IWorkflowInfo(item, None) state_title = info.workflow().workflow.states[item.status].title record = { 'title': props.title, 'description': props.description, 'name': stringKey(scheduling), 'status': item.status, 'type': item.type.capitalize, 't':item.type, 'state_title': state_title, #'category_id': scheduling.category_id, #'category': scheduling.category, 'discussion': discussion, 'delete_url': "%s/delete" % url.absoluteURL(scheduling, request), 'url': url.set_url_context(site_url+('/business/%ss/obj-%s' % (item.type, item.parliamentary_item_id)))} if include_actions: record['actions'] = get_scheduling_actions(scheduling, request) record['workflow'] = get_workflow_actions(item, request) discussion_actions = get_discussion_actions(discussion, request) if discussion_actions: assert len(discussion_actions) == 1 record['discussion_action'] = discussion_actions[0] else: record['discussion_action'] = None items.append(record) return items
def form_description(self): language = get_language_by_name(self.language)["name"] props = IDCDescriptiveProperties.providedBy(self.context) \ and self.context or IDCDescriptiveProperties(self.context) if self.is_translation: return _(u"edit_translation_legend", default=u'Editing $language translation of "$title"', mapping={"title": translate(props.title, context=self.request), "language": language}) else: return _( u"translate_item_help", default=u'The document "$title" has not yet been translated into $language. Use this form to add the translation', mapping={"title": translate(props.title, context=self.request), "language": language})
def columns(self): return [ CustomSelectionColumn( lambda item:str(item.audit_id), name="selection"), column.GetterColumn(title=_("version"), getter=lambda i,f:"%s" % (i.audit_id), cell_formatter=lambda g,i,f:'<a href="%s/version-log/%s">%s</a>' % (f.url, i.__name__, i.seq)), column.GetterColumn(title=_("procedure"), getter=lambda i,f:i.procedure), column.GetterColumn(title=_("modified"), getter=lambda i,f:self.date_formatter.format(i.date_active)), column.GetterColumn(title=_("by"), getter=lambda i,f:IDCDescriptiveProperties(i.user).title), column.GetterColumn(title=_("message"), getter=lambda i,f:i.note), ]
def expand_containers(self, items, containers, _url, chain=(), context=None): #seen_context = False current = False for key, container in containers: if IAlchemistContainer.providedBy(container): descriptor = queryModelDescriptor( proxy.removeSecurityProxy(container).domain_model) if descriptor: name = getattr(descriptor, 'container_name', None) if name is None: name = getattr(descriptor, 'display_name', None) if not name: name = container.domain_model.__name__ else: assert IDCDescriptiveProperties.providedBy(container) container = proxy.removeSecurityProxy(container) name = container.title if context is not None: current = container.__name__ == context.__name__ selected = len(chain) == 0 and current if current: #seen_context = True nodes = self.expand(chain) else: nodes = () items.append({ 'title': name, 'url': "%s/%s" % (_url.rstrip('/'), key), 'current': current, 'selected': selected, 'kind': 'container', 'nodes': nodes, })
def expand_containers(self, items, containers, _url, chain=(), context=None): #seen_context = False current = False for key, container in containers: if IAlchemistContainer.providedBy(container): descriptor = queryModelDescriptor( proxy.removeSecurityProxy(container).domain_model) if descriptor: name = getattr(descriptor, "container_name", None) if name is None: name = getattr(descriptor, "display_name", None) if not name: name = container.domain_model.__name__ else: assert IDCDescriptiveProperties.providedBy(container) container = proxy.removeSecurityProxy(container) name = container.title if context is not None: current = container.__name__ == context.__name__ selected = len(chain) == 0 and current if current: #seen_context = True nodes = self.expand(chain) else: nodes = () items.append({ "title": name, "url": "%s/%s" % (_url.rstrip("/"), key), "current": current, "selected": selected, "kind": "container", "nodes": nodes, })
def __init__(self, context, request): super(ChangeBaseView, self).__init__(context, request) # table to display the versions history formatter = date.getLocaleFormatter(self.request, "dateTime", "short") # !+ note this breaks the previous sort-dates-as-strings-hack of # formatting dates, for all locales, as date.strftime("%Y-%m-%d %H:%M") # that, when sorted as a string, gives correct results. self.columns = [ column.GetterColumn(title=_(u"action"), getter=lambda i,f:i.action), column.GetterColumn(title=_(u"date"), getter=lambda i,f:formatter.format(i.date_active)), column.GetterColumn(title=_(u"user"), getter=lambda i,f:IDCDescriptiveProperties(i.user).title), column.GetterColumn(title=_(u"description"), getter=lambda i,f:i.description), column.GetterColumn(title=_(u"audit date"), getter=lambda i,f:formatter.format(i.date_audit)), ]
def __init__(self, context, request, view, manager): self.context = context self.request = request self.__parent__ = view self.manager = manager self.wf_status = "new" self.has_status = False # table to display the workflow history formatter = date.getLocaleFormatter(self.request, "dateTime", "short") # !+ note this breaks the previous sort-dates-as-strings-hack of # formatting dates as date.strftime("%Y-%m-%d %H:%M") -- when sorted # as a string -- gives correct results (for all locales). self.columns = [ column.GetterColumn(title=_(u"date"), getter=lambda i,f:formatter.format(i.date_active)), column.GetterColumn(title=_(u"user"), getter=lambda i,f:IDCDescriptiveProperties(i.user).title), column.GetterColumn(title=_(u"description"), getter=lambda i,f:_label(i)), ]
def expand_containers(self, items, containers, _url, chain=(), context=None): # seen_context = False current = False for key, container in containers: if IAlchemistContainer.providedBy(container): descriptor = queryModelDescriptor(proxy.removeSecurityProxy(container).domain_model) if descriptor: name = getattr(descriptor, "container_name", None) if name is None: name = getattr(descriptor, "display_name", None) if not name: name = container.domain_model.__name__ else: assert IDCDescriptiveProperties.providedBy(container) container = proxy.removeSecurityProxy(container) name = container.title if context is not None: current = container.__name__ == context.__name__ selected = len(chain) == 0 and current if current: # seen_context = True nodes = self.expand(chain) else: nodes = () items.append( { "title": name, "url": "%s/%s" % (_url.rstrip("/"), key), "current": current, "selected": selected, "kind": "container", "nodes": nodes, } )
def update(self): need("yui-dragdrop") need("yui-container") sitting = self._parent._parent.context scheduled_item_ids = [item.item_id for item in sitting.item_schedule] # add location to items gsm = component.getSiteManager() adapter = gsm.adapters.lookup( (interface.implementedBy(self.model), interface.providedBy(self)), ILocation ) date_formatter = self.get_date_formatter("date", "medium") items = [ adapter(item, None) for item in self._query_items() ] # for each item, format dictionary for use in template self.items = [{ "title": properties.title, "name": item.__class__.__name__, "description": properties.description, #"date": _(u"$F", mapping={"F": # datetimedict.fromdatetime(item.changes[-1].date)}), #"date":item.changes[-1].date, # not every item has a auditlog (headings) # use last status change instead. "date": date_formatter.format(self._item_date(item)), "state": IWorkflow(item).get_state(item.status).title, "id": item.parliamentary_item_id, "class": ( (item.parliamentary_item_id in scheduled_item_ids and "dd-disable") or ""), "url": self._item_url(item), "type": item.type } for item, properties in [ (item, (IDCDescriptiveProperties.providedBy(item) and item or IDCDescriptiveProperties(item))) for item in items ] ]
def update(self): need('yui-dragdrop') need('yui-container') session = Session() group_id = self.get_group_id() items = tuple(session.query(self.model).filter( sql.and_( self.model.status.in_(self.states), self.model.group_id == group_id) )) sitting = self._parent._parent.context scheduled_item_ids = [item.item_id for item in sitting.item_schedule] # add location to items gsm = component.getSiteManager() adapter = gsm.adapters.lookup( (interface.implementedBy(self.model), interface.providedBy(self)), ILocation) items = [adapter(item, None) for item in items] # for each item, format dictionary for use in template self.items = [{ 'title': properties.title, 'name': item.__class__.__name__, 'description': properties.description, #'date': _(u"$F", mapping={'F': # datetimedict.fromdatetime(item.changes[-1].date)}), 'date': item.changes[-1].date_active, 'state': _(IWorkflow(item).workflow.states[item.status].title), 'id': item.parliamentary_item_id, 'class': (item.parliamentary_item_id in scheduled_item_ids) and "dd-disable" or "", 'url': url.set_url_context(url.absoluteURL(item, self.request)) } for (item, properties) in [ (item, (IDCDescriptiveProperties.providedBy(item) and item or IDCDescriptiveProperties(item))) for item in items ] ]
def form_name(self): if IVersion.providedBy(self.context): context = self.context.head props = IDCDescriptiveProperties.providedBy(context) \ and context or IDCDescriptiveProperties(context) if self.is_translation: language = get_language_by_name(self.context.language)['name'] return _(u"edit_translation_legend", default=u'Editing $language translation of "$title"', mapping={'title': translate(props.title, context=self.request), 'language': language}) elif IVersion.providedBy(self.context): return _(u"edit_version_legend", default=u'Editing "$title" (version $version)', mapping={'title': translate(props.title, context=self.request), 'version': self.context.version_id}) return _(u"edit_item_legend", default=u'Editing "$title"', mapping={'title': translate(props.title, context=self.request)})
def testChangeTitle(self): container = self._TestView__newContext() document = Document() container['document'] = document from zope.dublincore.interfaces import IDCDescriptiveProperties class FauxDCDescriptiveProperties(object): implements(IDCDescriptiveProperties) __Security_checker__ = checker.Checker( { "title": "zope.Public", }, {"title": "zope.app.dublincore.change"}) def __init__(self, context): self.context = context def setTitle(self, title): self.context.title = title def getTitle(self): return self.context.title title = property(getTitle, setTitle) ztapi.provideAdapter(IDocument, IDCDescriptiveProperties, FauxDCDescriptiveProperties) fc = self._TestView__newView(container) dc = IDCDescriptiveProperties(document) fc.request.form.update({'retitle_id': 'document', 'new_value': 'new'}) fc.changeTitle() events = getEvents() self.assertEquals(dc.title, 'new') self.failIf('title' not in events[-1].descriptions[0].attributes)
def update(self): need('yui-dragdrop') need('yui-container') session = Session() items = tuple(session.query(self.model).filter( self.model.status.in_(self.states))) sitting = self._parent._parent.context scheduled_item_ids = [item.item_id for item in sitting.item_schedule] # add location to items gsm = component.getSiteManager() adapter = gsm.adapters.lookup( (interface.implementedBy(self.model), interface.providedBy(self)), ILocation) items = [adapter(item, None) for item in items] site_url = url.absoluteURL(getSite(), self.request) # for each item, format dictionary for use in template self.items = [{ 'title': properties.title, 'name': item.__class__.__name__, 'description': properties.description, # 'date': _(u"$F", mapping={"F": # datetimedict.fromdatetime(item.changes[-1].date)}), #'date':item.changes[-1].date, # not every item has a auditlog (headings) use last status change instead. 'date':item.status_date, # 'state': IWorkflow(item).workflow.states[item.status].title, 'id': item.parliamentary_item_id, 'class': (item.parliamentary_item_id in scheduled_item_ids) and "dd-disable" or "", 'url': url.set_url_context(site_url+('/business/%ss/obj-%s' % (item.type, item.parliamentary_item_id))) } for item, properties in \ [(item, (IDCDescriptiveProperties.providedBy(item) and item or \ IDCDescriptiveProperties(item))) for item in items]]
def _get_items(self): formatter = self.get_date_formatter("date", "long") trusted = removeSecurityProxy(self.context) session = Session() memberships = session.query(domain.GroupMember).join( domain.User).filter(domain.User.user_id == trusted.user_id).all() items = [] def get_relevant_date(date_type, title=None): if title and getattr(title, date_type, None): return formatter.format(getattr(title, date_type)) elif getattr(mb, date_type, None): return formatter.format(getattr(mb, date_type)) elif getattr(mb.group, date_type, None): return formatter.format(getattr(mb.group, date_type)) else: return "" for mb in memberships: item = {} item["group"] = IDCDescriptiveProperties(mb.group).title item["group_type"] = translate(mb.group.type, context=self.request) if mb.member_titles: for title in mb.member_titles: final_item = dict(item) final_item["member_title"] = _(title.title_type.title_name) final_item["start_date"] = get_relevant_date( "start_date", title) final_item["end_date"] = get_relevant_date( "end_date", title) items.append(final_item) else: item["member_title"] = _(u"Member") item["start_date"] = get_relevant_date("start_date") item["end_date"] = get_relevant_date("end_date") items.append(item) return items
def __init__(self, context, request): super(VersionLogView, self).__init__(context.__parent__, request) # table to display the versions history formatter = date.getLocaleFormatter(self.request, "dateTime", "short") # !+ note this breaks the previous sort-dates-as-strings-hack of # formatting dates, for all locales, as date.strftime("%Y-%m-%d %H:%M") # that, when sorted as a string, gives correct results. self.columns = [ column.SelectionColumn( lambda item:str(item.version_id), name="selection"), column.GetterColumn(title=_(u"version"), getter=lambda i,f:'<a href="%s">%d</a>' % ( "%s/versions/obj-%d" % (f.url, i.version_id), i.version_id)), column.GetterColumn(title=_(u"manual"), getter=lambda i,f:i.manual), column.GetterColumn(title=_(u"modified"), getter=lambda i,f:formatter.format(i.change.date_active)), column.GetterColumn(title=_(u"by"), getter=lambda i,f:IDCDescriptiveProperties(i.change.user).title), column.GetterColumn(title=_(u"message"), getter=lambda i,f:i.change.description), ] self.selection_column = self.columns[0]
def title_member(self): session = Session() context = session.merge(removeSecurityProxy(self.context)) mp_user = None try: mp_user = session.query(domain.MemberOfParliament).filter( domain.MemberOfParliament.user_id == context.user_id).one() except NoResultFound: #this user has no associated MP record pass except MultipleResultsFound: # this should not happen log.error("Multiple MP objects found for : %s", context.__str__()) finally: if mp_user is None: return self.title dc_constituency = IDCDescriptiveProperties(mp_user.constituency) return _( "member_title_with_constituency", default=u"Member of Parliament for ${constituency} (${member})", mapping={ "constituency": dc_constituency.title, "member": self.title })
def title(self): return IDCDescriptiveProperties(self.context).title
def duration(self): return IDCDescriptiveProperties(self).duration
def item_uri(self): return IDCDescriptiveProperties(self.item).uri
def obj2dict(obj, depth, parent=None, include=[], exclude=[], lang=None, root_key=None): """ Returns dictionary representation of a domain object. """ if lang is None: lang = getattr(obj, "language", capi.default_language) result = {} obj = zope.security.proxy.removeSecurityProxy(obj) descriptor = None if IAlchemistContent.providedBy(obj): try: descriptor = utils.get_descriptor(obj) except KeyError: log.error("Could not get descriptor for IAlchemistContent %r", obj) if parent is not None and IWorkflowed.providedBy(obj): permissions = get_object_state_rpm(obj).permissions result["permissions"] = get_permissions_dict(permissions) result["tags"] = IStateController(obj).get_state().tags # Get additional attributes for name in include: value = getattr(obj, name, None) if value is None: continue if not name.endswith("s"): name += "s" if isinstance(value, collections.Iterable): res = [] # !+ allowance for non-container-api-conformant alchemist containers if IAlchemistContainer.providedBy(value): value = value.values() for item in value: i = obj2dict(item, 0, lang=lang, root_key=root_key) res.append(i) result[name] = res else: result[name] = value # Get mapped attributes seen_keys = [] mapper = class_mapper(obj.__class__) for mproperty in mapper.iterate_properties: if mproperty.key.startswith("_vp"): #skip vertical props continue if mproperty.key in exclude: continue seen_keys.append(mproperty.key) value = getattr(obj, mproperty.key) if value == parent: continue if value is None: continue if isinstance(mproperty, RelationshipProperty) and depth > 0: if isinstance(value, collections.Iterable): result[mproperty.key] = [] for item in value: # !+DEPTH(ah, 2014-09-19) depth was set to 1 here, this causes # a very deep branching for upper level groups like legislature and chamber # and legislature times out occasionally. Doesnt seem neccessary to go depth=1 # for child objects, because they get serialized independently anyway, changing # depth to depth-1 so all dependent objects are iterated 1 level lower than the # parent. # UPDATE(ah, 2014-11-03) Item Schedule is an exceptional case of an object # whose context is within a parent container but is not visible outside of the sitting # it is not a type defined in types.xml and does not have its own # wokflow so we need to handle that in a unique way # we don't decrement the depth and instead process it as is active_depth = depth if item.__class__.__name__ == "ItemSchedule": active_depth = depth else: active_depth = depth-1 result[mproperty.key].append( obj2dict( item, active_depth, parent=obj, include=["owner", "item_schedule", "item_schedule_discussion"], exclude=exclude + INNER_EXCLUDES, lang=lang, root_key=root_key ) ) else: result[mproperty.key] = obj2dict(value, depth-1, parent=obj, include=["owner"], exclude=exclude + INNER_EXCLUDES, lang=lang, root_key=root_key ) else: if isinstance(mproperty, RelationshipProperty): continue elif isinstance(mproperty, ColumnProperty): columns = mproperty.columns if len(columns) == 1: if is_column_binary(columns[0]): fname = PersistFiles.store_file(obj, parent, columns[0].key, root_key) if fname: result[columns[0].key] = dict(saved_file=fname) continue if descriptor: columns = mproperty.columns is_foreign = False if len(columns) == 1: if len(columns[0].foreign_keys): is_foreign = True if (not is_foreign) and (mproperty.key in descriptor.keys()): field = descriptor.get(mproperty.key) if (field and field.property and (schema.interfaces.IChoice.providedBy(field.property) or IVocabularyTextField.providedBy(field.property)) ): factory = field.property.vocabulary or field.property.source if factory is None: vocab_name = getattr(field.property, "vocabularyName", None) factory = get_vocabulary(vocab_name) # !+VOCABULARIES(mb, aug-2012)some vocabularies # expect an interaction to generate values # todo - update these vocabularies to work # with no request e.g. in notification threads display_name = None try: vocabulary = factory(obj) # handle vdex hierarchical terms if ITreeVocabulary.providedBy(factory): values = value.splitlines() term_values = [] for val in values: term_values.append(dict( name=mproperty.key, value=val, displayAs=factory.getTermCaption( factory.getTermById(val), lang=lang))) result[mproperty.key] = term_values continue term = vocabulary.getTerm(value) if lang: if hasattr(factory, "getTermCaption"): display_name = factory.getTermCaption( factory.getTermById(value), lang=lang) else: display_name = translate( term.title or term.value, target_language=lang, domain="bungeni") else: display_name = term.title or term.value except zope.security.interfaces.NoInteraction: log.error("This vocabulary %s expects an interaction " "to generate terms.", factory) # try to use dc adapter lookup try: _prop = mapper.get_property_by_column( mproperty.columns[0]) _prop_value = getattr(obj, _prop.key) dc = IDCDescriptiveProperties(_prop_value, None) if dc: display_name = IDCDescriptiveProperties( _prop_value).title except KeyError: log.warn("No display text found for %s on " "object %s. Unmapped in orm.", property.key, obj) except Exception, e: log.error("Could not instantiate vocabulary %s. " "Exception: %s", factory, e) finally: # fallback we cannot look up vocabularies/dc if display_name is None: if not isinstance(value, unicode): display_name = unicode(value) if display_name is not None: result[mproperty.key] = dict( name=mproperty.key, value=value, displayAs=display_name) continue
def item_title(self): if interfaces.IScheduleText.providedBy(self.item): return self.item.text return IDCDescriptiveProperties(self.item).title
def item_mover(self): # !+ item_owner_title # currently item may be (doc, heading, editorial_note) of which # only doc has an "owner" attribute. schedule_item = self.item if hasattr(schedule_item, "owner"): return IDCDescriptiveProperties(schedule_item.owner).title
def get_descriptive_properties(context): return IDCDescriptiveProperties(context)
elif IAlchemistContainer.providedBy(context): domain_model = context._class try: descriptor = utils.get_descriptor(domain_model) except KeyError, e: log.warn("TYPE_INFO: no descriptor for model %s " "[container=%s] [error=%s]" % (domain_model, context, e)) descriptor = None name = "" if descriptor: name = getattr(descriptor, "container_name", None) if name is None: name = getattr(descriptor, "display_name", None) if not name: name = getattr(context, "__name__", None) title = name elif ILocation.providedBy(context) and IDCDescriptiveProperties.providedBy(context): title = IDCDescriptiveProperties(context).title return title #!+DevProgammingGuide(mr, oct-2012) always return localized template data class SecondaryNavigationViewlet(browser.BungeniViewlet): render = ViewPageTemplateFile("templates/secondary-navigation.pt") def update(self): # request = self.request context = self.context chain = _get_context_chain(context) length = len(chain) self.items = []
def render(self, date, template=None): #need('yui-editor') need('yui-rte') need('yui-resize') need('yui-button') if template is None: template = self.template container = self.context.__parent__ #schedule_url = self.request.getURL() container_url = ui_url.absoluteURL(container, self.request) # determine position in container key = stringKey(self.context) keys = list(container.keys()) pos = keys.index(key) links = {} if pos > 0: links['previous'] = "%s/%s/%s" % (container_url, keys[pos - 1], self.__name__) if pos < len(keys) - 1: links['next'] = "%s/%s/%s" % (container_url, keys[pos + 1], self.__name__) #start_date = utils.datetimedict.fromdatetime(self.context.start_date) #end_date = utils.datetimedict.fromdatetime(self.context.end_date) #session = Session() sitting_type_dc = IDCDescriptiveProperties(self.context.sitting_type) site_url = ui_url.absoluteURL(getSite(), self.request) return template( display="sitting", #title=_(u"$A $e, $B $Y", mapping=start_date), title="%s: %s - %s" % (self.context.group.short_name, self.context.start_date.strftime('%Y-%m-%d %H:%M'), self.context.end_date.strftime('%H:%M')), description=_( u"$type — ${start}-${end}", mapping={ 'type': translate(sitting_type_dc.title), 'start': self.context.start_date.strftime('%Y-%m-%d %H:%M'), 'end': self.context.end_date.strftime('%H:%M') }), # title = u"", # description = u"", # links=links, actions=get_sitting_actions(self.context, self.request), items=get_sitting_items(self.context, self.request, include_actions=True), #categories=vocabulary.ItemScheduleCategories(self.context), new_category_url="%s/admin/content/categories/add?next_url=..." % site_url, status=self.context.status, )
def label(self): return IDCDescriptiveProperties(self.audit_head).title
def expand(self, chain, include_siblings=True): if len(chain) == 0: return () context = chain.pop() items = [] if IApplication.providedBy(context): items.extend(self.expand(chain)) elif IAlchemistContent.providedBy(context): _url = url.absoluteURL(context, self.request) if IDCDescriptiveProperties.providedBy(context): title = context.title else: props = IDCDescriptiveProperties(context, None) if props is not None: title = props.title else: title = context.short_name selected = len(chain) == 0 if chain: nodes = self.expand(chain) else: kls = context.__class__ containers = [ (key, getattr(context, key)) for key, value in kls.__dict__.items() if isinstance(value, ManagedContainerDescriptor)] nodes = [] self.expand_containers(nodes, containers, _url, chain, None) items.append( {'title': title, 'url': _url, 'current': True, 'selected': selected, 'kind': 'content', 'nodes': nodes, }) elif IAlchemistContainer.providedBy(context): # loop through all managed containers of the parent # object, and include the present container as the # 'current' node. parent = context.__parent__ assert parent is not None _url = url.absoluteURL(parent, self.request) # append managed containers as child nodes kls = type(proxy.removeSecurityProxy(parent)) if include_siblings is True: if IApplication.providedBy(parent): containers = [ (name, parent[name]) for name in location.model_to_container_name_mapping.values() if name in parent ] elif IReadContainer.providedBy(parent): containers = list(parent.items()) else: containers = [ (key, getattr(parent, key)) for key, value in kls.__dict__.items() if isinstance(value, ManagedContainerDescriptor)] else: containers = [(context.__name__, context)] self.expand_containers(items, containers, _url, chain, context) elif ILocation.providedBy(context): _url = url.absoluteURL(context, self.request) #props = IDCDescriptiveProperties.providedBy(context) and \ # context or IDCDescriptiveProperties(context) if IDCDescriptiveProperties.providedBy(context): props = IDCDescriptiveProperties(context) else: props = context props = proxy.removeSecurityProxy(props) selected = len(chain) == 0 if selected and IReadContainer.providedBy(context): nodes = [] try: self.expand_containers( nodes, context.items(), _url, chain, context) except: pass else: nodes = self.expand(chain) i_id = getattr(props, 'id','N/A') items.append( {'title': getattr(props, 'title', i_id), 'url': _url, 'current': True, 'selected': selected, 'kind': 'location', 'nodes': nodes, }) elif IReadContainer.providedBy(context): items.extend(self.expand(chain)) return items
def mover(self): session = Session() context = session.merge(removeSecurityProxy(self.context)) return IDCDescriptiveProperties(context.item).mover
descriptor = utils.get_descriptor(domain_model) except KeyError, e: log.warn("TYPE_INFO: no descriptor for model %s " "[container=%s] [error=%s]" % ( domain_model, context, e)) descriptor = None name = "" if descriptor: name = getattr(descriptor, "container_name", None) if name is None: name = getattr(descriptor, "display_name", None) if not name: name = getattr(context, "__name__", None) title = name elif (ILocation.providedBy(context) and IDCDescriptiveProperties.providedBy(context)): title = IDCDescriptiveProperties(context).title return title #!+DevProgammingGuide(mr, oct-2012) always return localized template data class SecondaryNavigationViewlet(browser.BungeniViewlet): render = ViewPageTemplateFile("templates/secondary-navigation.pt") def update(self): #request = self.request context = self.context chain = _get_context_chain(context) length = len(chain) self.items = [] if length < 2:
try: descriptor = utils.get_descriptor(domain_model) except KeyError, e: log.warn("TYPE_INFO: no descriptor for model %s " "[container=%s] [error=%s]" % (domain_model, context, e)) descriptor = None name = "" if descriptor: name = getattr(descriptor, "container_name", None) if name is None: name = getattr(descriptor, "display_name", None) if not name: name = getattr(context, "__name__", None) title = name elif (ILocation.providedBy(context) and IDCDescriptiveProperties.providedBy(context)): title = IDCDescriptiveProperties(context).title return title #!+DevProgammingGuide(mr, oct-2012) always return localized template data class SecondaryNavigationViewlet(browser.BungeniViewlet): render = ViewPageTemplateFile("templates/secondary-navigation.pt") def update(self): #request = self.request context = self.context chain = _get_context_chain(context) length = len(chain) self.items = []
def set(self, value): descproperties = IDCDescriptiveProperties(self.context, None) if descproperties is None: raise ValueError("") descproperties.title = value
def expand(self, chain, include_siblings=True): if len(chain) == 0: return () context = chain.pop() items = [] if IApplication.providedBy(context): items.extend(self.expand(chain)) elif IAlchemistContent.providedBy(context): _url = url.absoluteURL(context, self.request) selected = len(chain) == 0 if chain: nodes = self.expand(chain) else: containers = utils.get_managed_containers(context) nodes = [] self.expand_containers(nodes, containers, _url, chain, None) items.append({ "id": self.get_nav_entry_id(_url), "label": IDCDescriptiveProperties(context).title, "url": _url, "current": True, "selected": selected, "kind": "content", "nodes": nodes, }) elif IAlchemistContainer.providedBy(context): # loop through all managed containers of the parent # object, and include the present container as the # "current" node. parent = context.__parent__ assert parent is not None _url = url.absoluteURL(parent, self.request) # append managed containers as child nodes if include_siblings is True: if IApplication.providedBy(parent): containers = [ (name, parent[name]) for name in location.model_to_container_name_mapping.values() if name in parent ] elif IReadContainer.providedBy(parent): containers = list(parent.items()) else: containers = utils.get_managed_containers(parent) else: containers = [(context.__name__, context)] self.expand_containers(items, containers, _url, chain, context) elif ILocation.providedBy(context): # e.g. bungeni.core.content.Section, DisplayForm _url = url.absoluteURL(context, self.request) selected = len(chain) == 0 if selected and IReadContainer.providedBy(context): nodes = [] try: self.expand_containers(nodes, context.items(), _url, chain, context) except: pass else: nodes = self.expand(chain) _title = getattr(context, "title", None) or \ getattr(context, "page_title", "!+BungeniBrowserView.title") items.append({ "id": self.get_nav_entry_id(_url), # !+BungeniBrowserView.title "label": _title, #IDCDescriptiveProperties(context).title, "url": _url, "current": True, "selected": selected, "kind": "location", "nodes": nodes, }) elif IReadContainer.providedBy(context): #!+NavigationTreeViewlet-EXPAND-IReadContainer(mr, oct-2012) does this ever execute?! raise Exception( "!+NavigationTreeViewlet-EXPAND-IReadContainer [%s]" % context) items.extend(self.expand(chain)) return items
def getDCTitle(ob): dc = IDCDescriptiveProperties(ob, None) if dc is None: return None else: return dc.title
def label(self): dp = self.audit_head return "%s -> %s" % (dp.doc.title, IDCDescriptiveProperties(dp.principal).title)
def get_sitting_items(sitting, request, include_actions=False): items = [] if sitting.status in get_states("groupsitting", keys=["draft_agenda", "published_agenda"]): order = "planned_order" else: order = "real_order" schedulings = map(removeSecurityProxy, sitting.items.batch(order_by=order, limit=None)) site_url = url.absoluteURL(getSite(), request) for scheduling in schedulings: item = ProxyFactory(location_wrapped(scheduling.item, sitting)) props = IDCDescriptiveProperties.providedBy(item) and item or \ IDCDescriptiveProperties(item) discussions = tuple(scheduling.discussions.values()) discussion = discussions and discussions[0] or None truncated_discussion = None if ((discussion is not None) and (discussion.body_text is not None)): #truncate discussion to first hundred characters t_discussion = discussion.body_text[0:100] try: #truncate discussion to first two lines index = t_discussion.index("<br>") index2 = t_discussion.index("<br>", index + 4) truncated_discussion = t_discussion[0:index2] + "..." except ValueError: truncated_discussion = t_discussion + "..." info = IWorkflowInfo(item, None) state_title = info.workflow().workflow.states[item.status].title record = { 'title': props.title, 'description': props.description, 'name': stringKey(scheduling), 'status': item.status, 'type': item.type.capitalize, 't': item.type, 'state_title': state_title, #'category_id': scheduling.category_id, #'category': scheduling.category, 'discussion': discussion, 'truncated_discussion': truncated_discussion, 'delete_url': "%s/delete" % url.absoluteURL(scheduling, request), 'url': url.set_url_context(site_url + ('/business/%ss/obj-%s' % (item.type, item.parliamentary_item_id))) } if include_actions: record['actions'] = get_scheduling_actions(scheduling, request) record['workflow'] = get_workflow_actions(item, request) discussion_actions = get_discussion_actions(discussion, request) if discussion_actions: assert len(discussion_actions) == 1 record['discussion_action'] = discussion_actions[0] else: record['discussion_action'] = None items.append(record) return items
def expand(self, chain, include_siblings=True): if len(chain) == 0: return () context = chain.pop() items = [] if IApplication.providedBy(context): items.extend(self.expand(chain)) elif IAlchemistContent.providedBy(context): _url = url.absoluteURL(context, self.request) if IDCDescriptiveProperties.providedBy(context): title = context.title else: props = IDCDescriptiveProperties(context, None) if props is not None: title = props.title else: title = context.short_name selected = len(chain) == 0 if chain: nodes = self.expand(chain) else: kls = context.__class__ containers = [(key, getattr(context, key)) for key, value in kls.__dict__.items() if isinstance(value, ManagedContainerDescriptor)] nodes = [] self.expand_containers(nodes, containers, _url, chain, None) items.append({ 'title': title, 'url': _url, 'current': True, 'selected': selected, 'kind': 'content', 'nodes': nodes, }) elif IAlchemistContainer.providedBy(context): # loop through all managed containers of the parent # object, and include the present container as the # 'current' node. parent = context.__parent__ assert parent is not None _url = url.absoluteURL(parent, self.request) # append managed containers as child nodes kls = type(proxy.removeSecurityProxy(parent)) if include_siblings is True: if IApplication.providedBy(parent): containers = [ (name, parent[name]) for name in location.model_to_container_name_mapping.values() if name in parent ] elif IReadContainer.providedBy(parent): containers = list(parent.items()) else: containers = [ (key, getattr(parent, key)) for key, value in kls.__dict__.items() if isinstance(value, ManagedContainerDescriptor) ] else: containers = [(context.__name__, context)] self.expand_containers(items, containers, _url, chain, context) elif ILocation.providedBy(context): _url = url.absoluteURL(context, self.request) #props = IDCDescriptiveProperties.providedBy(context) and \ # context or IDCDescriptiveProperties(context) if IDCDescriptiveProperties.providedBy(context): props = IDCDescriptiveProperties(context) else: props = context props = proxy.removeSecurityProxy(props) selected = len(chain) == 0 if selected and IReadContainer.providedBy(context): nodes = [] try: self.expand_containers(nodes, context.items(), _url, chain, context) except: pass else: nodes = self.expand(chain) i_id = getattr(props, 'id', 'N/A') items.append({ 'title': getattr(props, 'title', i_id), 'url': _url, 'current': True, 'selected': selected, 'kind': 'location', 'nodes': nodes, }) elif IReadContainer.providedBy(context): items.extend(self.expand(chain)) return items
def mover(self): context = _merged(self.context) # !+TRANSLATE_MESS(mr, oct-2012) this is content data and NOT a UI msgid? # Should then be using translate_obj ?! return translate_i18n( IDCDescriptiveProperties(context.owner).title_member)
def title(self): context = _merged(self.context) return IDCDescriptiveProperties(context.item).title
def mover(self): context = _merged(self.context) return IDCDescriptiveProperties(context.item).mover
def mover(self): session = Session() context = session.merge(removeSecurityProxy(self.context)) return translate_i18n( IDCDescriptiveProperties(context.owner).title_member)
def obj2dict(obj, depth, parent=None, include=[], exclude=[], lang=None, root_key=None): """ Returns dictionary representation of a domain object. """ if lang is None: lang = getattr(obj, "language", capi.default_language) result = {} obj = zope.security.proxy.removeSecurityProxy(obj) descriptor = None if IAlchemistContent.providedBy(obj): try: descriptor = utils.get_descriptor(obj) except KeyError: log.error("Could not get descriptor for IAlchemistContent %r", obj) if parent is not None and IWorkflowed.providedBy(obj): permissions = get_object_state_rpm(obj).permissions result["permissions"] = get_permissions_dict(permissions) result["tags"] = IStateController(obj).get_state().tags # Get additional attributes for name in include: value = getattr(obj, name, None) if value is None: continue if not name.endswith("s"): name += "s" if isinstance(value, collections.Iterable): res = [] # !+ allowance for non-container-api-conformant alchemist containers if IAlchemistContainer.providedBy(value): value = value.values() for item in value: i = obj2dict(item, 0, lang=lang, root_key=root_key) res.append(i) result[name] = res else: result[name] = value # Get mapped attributes mapper = class_mapper(obj.__class__) for property in mapper.iterate_properties: if property.key in exclude: continue value = getattr(obj, property.key) if value == parent: continue if value is None: continue if isinstance(property, RelationshipProperty) and depth > 0: if isinstance(value, collections.Iterable): result[property.key] = [] for item in value: result[property.key].append( obj2dict(item, 1, parent=obj, include=[], exclude=exclude + INNER_EXCLUDES, lang=lang, root_key=root_key)) else: result[property.key] = obj2dict(value, depth - 1, parent=obj, include=[], exclude=exclude + INNER_EXCLUDES, lang=lang, root_key=root_key) else: if isinstance(property, RelationshipProperty): continue elif isinstance(property, ColumnProperty): columns = property.columns if len(columns) == 1: if is_column_binary(columns[0]): if (parent and interfaces.ISerializable.providedBy(obj)): #skip serialization of binary fields #that have already been serialized elsewhere continue #save files result[columns[0].key] = dict( saved_file=PersistFiles.store_file( obj, columns[0], root_key)) continue if descriptor: columns = property.columns is_foreign = False if len(columns) == 1: if len(columns[0].foreign_keys): is_foreign = True if (not is_foreign) and (property.key in descriptor.keys()): field = descriptor.get(property.key) if (field and field.property and (schema.interfaces.IChoice.providedBy(field.property) or IVocabularyTextField.providedBy(field.property))): factory = (field.property.vocabulary or field.property.source) if factory is None: vocab_name = getattr(field.property, "vocabularyName", None) factory = zope.component.getUtility( schema.interfaces.IVocabularyFactory, vocab_name) # !+VOCABULARIES(mb, aug-2012)some vocabularies # expect an interaction to generate values # todo - update these vocabularies to work # with no request e.g. in notification threads display_name = None try: vocabulary = factory(obj) #handle vdex hierarchical terms if ITreeVocabulary.providedBy(factory): values = value.splitlines() term_values = [] for val in values: term_values.append( dict(name=property.key, value=val, displayAs=factory.vdex. getTermCaption( factory.getTermById(val), lang))) result[property.key] = term_values continue term = vocabulary.getTerm(value) if lang: if hasattr(factory, "vdex"): display_name = ( factory.vdex.getTermCaption( factory.getTermById(value), lang)) else: display_name = translate( (term.title or term.value), target_language=lang, domain="bungeni") else: display_name = term.title or term.value except zope.security.interfaces.NoInteraction: log.error( "This vocabulary %s expects an" "interaction to generate terms.", factory) # try to use dc adapter lookup try: _prop = mapper.get_property_by_column( property.columns[0]) _prop_value = getattr(obj, _prop.key) dc = IDCDescriptiveProperties( _prop_value, None) if dc: display_name = (IDCDescriptiveProperties( _prop_value).title) except KeyError: log.warn( "No display text found for %s" " on object %s. Unmapped in orm.", property.key, obj) except Exception, e: log.error( "Could not instantiate" " vocabulary %s. Exception: %s", factory, e) finally: # fallback we cannot look up vocabularies/dc if display_name is None: if not isinstance(value, unicode): display_name = unicode(value) if display_name is not None: result[property.key] = dict(name=property.key, value=value, displayAs=display_name) continue