def __call__(self): relation_catalog = component.queryUtility(ICatalog) # First we make sure that templates are set on the committee query = {'object_provides': ICommittee.__identifier__} message = 'Make sure all meeting templates are set on the committee' intids = getUtility(IIntIds) for committee in self.objects(query, message): committee_container = committee.get_committee_container() for template_name in templates: if not getattr(committee, template_name, None) and getattr(committee_container, template_name, None): template_relation = getattr(committee_container, template_name) template = template_relation.to_object if template: setattr(committee, template_name, RelationValue(intids.getId(template))) committee.reindexObject() addRelations(committee, None) # Now we remove the relations to the templates on the ComitteeContainers # we can't use z3c.relationfield.eventremoveRelations because the fields # don't exist on the ICommitteeContainer schema anymore. # We also remove the attribute, as it will not be needed anymore query = {'object_provides': ICommitteeContainer.__identifier__} for committee_container in self.objects(query, message): for template_name in templates: if hasattr(committee_container, template_name): template = getattr(committee_container, template_name) if template: relation_catalog.unindex(template) delattr(committee_container, template_name)
def __call__(self): relation_catalog = component.queryUtility(ICatalog) # First we make sure that templates are set on the committee query = {'object_provides': ICommittee.__identifier__} message = 'Make sure all meeting templates are set on the committee' intids = getUtility(IIntIds) for committee in self.objects(query, message): committee_container = committee.get_committee_container() for template_name in templates: if not getattr(committee, template_name, None) and getattr( committee_container, template_name, None): template_relation = getattr(committee_container, template_name) template = template_relation.to_object if template: setattr(committee, template_name, RelationValue(intids.getId(template))) committee.reindexObject() addRelations(committee, None) # Now we remove the relations to the templates on the ComitteeContainers # we can't use z3c.relationfield.eventremoveRelations because the fields # don't exist on the ICommitteeContainer schema anymore. # We also remove the attribute, as it will not be needed anymore query = {'object_provides': ICommitteeContainer.__identifier__} for committee_container in self.objects(query, message): for template_name in templates: if hasattr(committee_container, template_name): template = getattr(committee_container, template_name) if template: relation_catalog.unindex(template) delattr(committee_container, template_name)
def append_excerpt(self, excerpt_document): """Add a relation to a new excerpt document. """ excerpts = getattr(self, 'excerpts', None) if not excerpts: # The missing_value attribute of a z3c-form field is used # as soon as an object has no default_value i.e. after creating # an object trough the command-line. # # Because the excerpts field needs a list as a missing_value, # we will fall into the "mutable keyword argument"-python gotcha. # The excerpts will be shared between the object-instances. # # Unfortunately the z3c-form field does not provide a # missing_value-factory (like the defaultFactory) which would be # necessary to fix this issue properly. # # As a workaround we reassign the field with a new list if the # excerpts-attribute has never been assigned before. excerpts = [] intid = getUtility(IIntIds).getId(excerpt_document) excerpts.append(RelationValue(intid)) self.excerpts = excerpts addRelations(self, None)
def __call__(self): self.install_upgrade_profile() has_meeting_feature = api.portal.get_registry_record( 'opengever.meeting.interfaces.IMeetingSettings.is_feature_enabled') if has_meeting_feature: query = {'object_provides': 'opengever.meeting.proposal.ISubmittedProposal'} for obj in self.objects(query, self.__class__.__doc__): addRelations(obj, None)
def __call__(self): self.install_upgrade_profile() if is_word_meeting_implementation_enabled(): query = { 'object_provides': 'opengever.meeting.proposal.ISubmittedProposal' } for obj in self.objects(query, self.__class__.__doc__): addRelations(obj, None)
def __call__(self): self.install_upgrade_profile() has_meeting_feature = api.portal.get_registry_record( 'opengever.meeting.interfaces.IMeetingSettings.is_feature_enabled') if has_meeting_feature: query = { 'object_provides': 'opengever.meeting.proposal.ISubmittedProposal' } for obj in self.objects(query, self.__class__.__doc__): addRelations(obj, None)