Back to index

plone3  3.1.7
Functions
archetypes.kss.fields_versioning Namespace Reference

Functions

def versionObjectBecauseFieldChanged

Function Documentation

Definition at line 20 of file fields_versioning.py.

00020 
00021 def versionObjectBecauseFieldChanged(obj, view, event):
00022     # XXX I believe we don't need to check if CMFEditions has actually
00023     # set the hook or not?
00024 
00025     pr = getToolByName(view.context, 'portal_repository')
00026     isVersionable = pr.isVersionable(obj)
00027     
00028     changed = False
00029     if not base_hasattr(obj, 'version_id'):
00030         changed = True
00031     else:
00032         try:
00033             changed = not pr.isUpToDate(obj, obj.version_id)
00034         except ArchivistUnregisteredError:
00035             # XXX: The object is not actually registered, but a
00036             # version is set, perhaps it was imported, or versioning
00037             # info was inappropriately destroyed
00038             changed = True
00039 
00040     fieldnames = event.fieldnames
00041     txtfieldnames ='"%s"' % ('", "'.join(fieldnames), )
00042     # XXX I am not sure we actually want to translate _here_, but 
00043     # at the moment this seems to be the best policy.
00044     comment_msg = _('Instant edited field(s) ${fields}' , 
00045                     mapping=dict(fields=txtfieldnames))
00046     # XXX unicode is not possible here?
00047     comment = view.context.translate(comment_msg)
00048     comment = comment.encode('utf')
00049 
00050     if changed and comment is not None and \
00051            pr.supportsPolicy(obj, 'at_edit_autoversion') and isVersionable:
00052         try:
00053             pr.save(obj=obj, comment=comment)
00054         except FileTooLargeToVersionError:
00055             commands = view.getCommandSet('plone')
00056             commands.issuePortalMessage(
00057                 _("Changes Saved. Versioning for this file has been disabled "
00058                   "because it is too large."),
00059                 msgtype="warn")

Here is the call graph for this function: