<commit_before>"""A simple multi-step wizard that uses the flask application session.

Creating multi-step forms of arbitrary length is simple and intuitive.

Example usage:

```
from flask.ext.wtf import FlaskForm

class MultiStepTest1(FlaskForm):
    field1 = StringField(validators=[validators.DataRequired()],)
    field2 = StringField(validators=[validators.DataRequired()],)


class MultiStepTest2(FlaskForm):
    field3 = StringField(validators=[validators.DataRequired()],)
    field4 = StringField(validators=[validators.DataRequired()],)


class MyCoolForm(MultiStepWizard):
    __forms__ = [
        MultiStepTest1,
        MultiStepTest2,
    ]
```
"""

from flask import session
from flask.ext.wtf import FlaskForm


class MultiStepWizard(FlaskForm):
    """Generates a multi-step wizard.

    The wizard uses the app specified session backend to store both
    form data and current step.

    TODO: make sure all the expected features of the typical form
    are exposed here, but automatically determining the active form
    and deferring to it. See __iter__ and data for examples.
    """

    __forms__ = []

    def __iter__(self):
        """Get the specific forms' fields for standard WTForm iteration."""
        _, form = self.get_active()
        return form.__iter__()

    def __len__(self):
        """Override the len method to emulate standard wtforms."""
        return len(self.__forms)

    def __getitem__(self, key):
        """Override getitem to emulate standard wtforms."""<commit_msg>Use new flask ext format.<commit_after>"""A simple multi-step wizard that uses the flask application session.

Creating multi-step forms of arbitrary length is simple and intuitive.

Example usage:

```
from flask.ext.wtf import FlaskForm

class MultiStepTest1(FlaskForm):
    field1 = StringField(validators=[validators.DataRequired()],)
    field2 = StringField(validators=[validators.DataRequired()],)


class MultiStepTest2(FlaskForm):
    field3 = StringField(validators=[validators.DataRequired()],)
    field4 = StringField(validators=[validators.DataRequired()],)


class MyCoolForm(MultiStepWizard):
    __forms__ = [
        MultiStepTest1,
        MultiStepTest2,
    ]
```
"""

from flask import session
from flask_wtf import FlaskForm


class MultiStepWizard(FlaskForm):
    """Generates a multi-step wizard.

    The wizard uses the app specified session backend to store both
    form data and current step.

    TODO: make sure all the expected features of the typical form
    are exposed here, but automatically determining the active form
    and deferring to it. See __iter__ and data for examples.
    """

    __forms__ = []

    def __iter__(self):
        """Get the specific forms' fields for standard WTForm iteration."""
        _, form = self.get_active()
        return form.__iter__()

    def __len__(self):
        """Override the len method to emulate standard wtforms."""
        return len(self.__forms)

    def __getitem__(self, key):
        """Override getitem to emulate standard wtforms."""
{'fraction_non_alphanumeric': 0.09135559921414538, 'fraction_numerical': 0.005239030779305829, 'mean_word_length': 3.6570121951219514, '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': '6691234', 'n_tokens_mistral': 872, 'n_tokens_neox': 822, 'n_words': 283}