<commit_before># Copyright (c) 2011 gocept gmbh & co. kg
# See also LICENSE.txt

import zeit.cms.browser.view
import zeit.edit.browser.view
import zope.app.pagetemplate
import zope.formlib.form


class Forms(object):
    """View that collects all inline forms."""


class FormGroup(zope.viewlet.viewlet.SimpleViewletClass('layout.forms.pt')):
    """Base class for groups of inline forms."""

    def forms(self):
        """Returns all actual views that belong to this form group."""
        # XXX the wohle code here is rather icky, but there doesn't seem to be
        # a cleaner way
        from zeit.content.article.interfaces import IArticle
        from zeit.cms.browser.interfaces import ICMSLayer
        from zeit.edit.interfaces import IContentViewletManager

        # resolve wrapper class that ZCML creates for views and viewlets to get
        # to the original class
        form_group_class = self.__class__.__bases__[0]

        result = []
        for reg in zope.component.getGlobalSiteManager().registeredAdapters():
            # step 1: get all viewlets which have ourselves as the view
            required = (
                IArticle,
                ICMSLayer,
                zope.interface.implementedBy(form_group_class),
                IContentViewletManager
                )
            if reg.required != required:
                continue

            # step 2: these viewlets are form-loaders that load an actual view
            # of the same name, so we resolve that to get to the actual form
            form = zope.component.getMultiAdapter(
                (self.context, self.request), name=reg.name)
            result.append(form)
        return result


FoldableFormGroup = zope.viewlet.viewlet.SimpleViewletClass('layout.foldable-forms.pt')

FormLoader = zope.viewlet.viewlet.SimpleViewletClass('layout.form-loader.pt')


class InlineForm(zope.formlib.form.SubPageEditForm,
                 zeit.edit.browser.view.UndoableMixin):

    template = zope.app.pagetemplate.ViewPageTemplateFile('inlineform.pt')

    css_class = None

    def __call__(self):
        self.mark_transaction_undoable()
        return super(InlineForm, self).__call__()

    @property
    def widget_data(self):
        result = []
        for widget in self.widgets:<commit_msg>Re #9406: Mix in Base-view into InlineForm so we get self.url()<commit_after># Copyright (c) 2011 gocept gmbh & co. kg
# See also LICENSE.txt

import zeit.cms.browser.view
import zeit.edit.browser.view
import zope.app.pagetemplate
import zope.formlib.form


class Forms(object):
    """View that collects all inline forms."""


class FormGroup(zope.viewlet.viewlet.SimpleViewletClass('layout.forms.pt')):
    """Base class for groups of inline forms."""

    def forms(self):
        """Returns all actual views that belong to this form group."""
        # XXX the wohle code here is rather icky, but there doesn't seem to be
        # a cleaner way
        from zeit.content.article.interfaces import IArticle
        from zeit.cms.browser.interfaces import ICMSLayer
        from zeit.edit.interfaces import IContentViewletManager

        # resolve wrapper class that ZCML creates for views and viewlets to get
        # to the original class
        form_group_class = self.__class__.__bases__[0]

        result = []
        for reg in zope.component.getGlobalSiteManager().registeredAdapters():
            # step 1: get all viewlets which have ourselves as the view
            required = (
                IArticle,
                ICMSLayer,
                zope.interface.implementedBy(form_group_class),
                IContentViewletManager
                )
            if reg.required != required:
                continue

            # step 2: these viewlets are form-loaders that load an actual view
            # of the same name, so we resolve that to get to the actual form
            form = zope.component.getMultiAdapter(
                (self.context, self.request), name=reg.name)
            result.append(form)
        return result


FoldableFormGroup = zope.viewlet.viewlet.SimpleViewletClass('layout.foldable-forms.pt')

FormLoader = zope.viewlet.viewlet.SimpleViewletClass('layout.form-loader.pt')


class InlineForm(zope.formlib.form.SubPageEditForm,
                 zeit.edit.browser.view.UndoableMixin,
                 zeit.cms.browser.view.Base):

    template = zope.app.pagetemplate.ViewPageTemplateFile('inlineform.pt')

    css_class = None

    def __call__(self):
        self.mark_transaction_undoable()
        return super(InlineForm, self).__call__()

    @property
    def widget_data(self):
        result = []
        for widget in self.widgets:
{'fraction_non_alphanumeric': 0.08324462422823078, 'fraction_numerical': 0.0038322333404300617, 'mean_word_length': 2.467158671586716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4866633', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1288, 'n_words': 366}