def auto_relations(obj, event): """ Auto update relations from internal links """ msg = u"" tags = [] level = u'info' try: tags = _auto_relations(obj) except Exception, err: logger.exception(err) msg = _( u"An error occured while trying to auto-relate content: %s" % err) level = u'error'
def _toFieldValue(self, input): """ Convert form value to field value """ if self.convert_missing_value and input == self._missing: value = self.context.missing_value else: if isinstance(input, (str, unicode)): input = [input, ''] elif isinstance(input, list): input = tuple(input) try: value = tuple(str(x) for x in input) except ValueError, v: raise ConversionError(_("Invalid text data"), v)
""" msg = u"" tags = [] level = u'info' try: tags = _auto_relations(obj) except Exception, err: logger.exception(err) msg = _( u"An error occured while trying to auto-relate content: %s" % err) level = u'error' else: length = len(tags) if tags else 0 if length == 1: text = 'one relation since it is linked in content' else: text = '%s relations since they are linked in content' % length msg = _(u"Automatically detected and added %s. " "If you do not wish some relations to " "some content, please remove the internal link to it and than " "manually remove the relation" % text) request = getattr(obj, 'REQUEST', None) if not request: return msg if not tags: return msg IStatusMessage(request).add(msg, level)