Example #1
0
    def __init__(self, form, request, context):
        fti = queryUtility(IDexterityFTI, name=form.portal_type)
        if isDraftable(fti):
            current = ICurrentDraftManagement(request)

            if current.targetKey is None:
                beginDrafting(context, None)
                current.path = "/".join(context.getPhysicalPath())
                current.targetKey = IUUID(context)
                current.save()
            else:
                current.mark()

            if current.draft:
                context = DraftProxy(current.draft, context)
                alsoProvides(request, IEditFormDrafting)

        super(DefaultEditFormFieldWidgets, self).__init__(form, request, context)  # noqa
Example #2
0
    def __init__(self, form, request, context):
        fti = queryUtility(IDexterityFTI, name=form.portal_type)
        if isDraftable(fti):
            current = ICurrentDraftManagement(request)

            if current.targetKey != "++add++{0}".format(form.portal_type):
                beginDrafting(context, None)
                current.path = "/".join(context.getPhysicalPath())
                current.targetKey = "++add++{0}".format(form.portal_type)
                current.save()
            else:
                current.mark()

            target = getattr(current.draft, "_draftAddFormTarget", None)
            if current.draft and target:
                context = DraftProxy(current.draft, target.__of__(context))
                alsoProvides(request, IAddFormDrafting)

        super(DefaultAddFormFieldWidgets, self).__init__(form, request, context)  # noqa