Ejemplo n.º 1
0
    def __init__(self, cleaned_data, forms=None, templates=None,
                 application=None, **kwargs):
        self.cleaned_data = cleaned_data
        self.templates = templates or {}

        if application is None:
            raise ValueError('Application section is required')
        else:
            self.application = application

        self.context = yaql.create_context()
        yaql_functions.register(self.context)

        self.forms = []
        for key, value in kwargs.iteritems():
            setattr(self, key, value)

        if forms:
            for data in forms:
                (name, field_specs, validators,
                 verbose_name) = self.extract_form_data(data)
                self._add_form(name, field_specs, validators, verbose_name)

        # Add ManageWorkflowForm
        workflow_form = catalog_forms.WorkflowManagementForm
        self._add_form(workflow_form.name, workflow_form.field_specs,
                       workflow_form.validators, _("What's next?"))
Ejemplo n.º 2
0
    def __init__(self, forms=None, templates=None, application=None, **kwargs):
        self.templates = templates or {}

        if application is None:
            raise ValueError('Application section is required')
        else:
            self.application = application

        self.context = yaql.create_context()
        yaql_functions.register(self.context)

        self.cleaned_data = {}
        self.forms = []
        self._forms = []
        for key, value in kwargs.iteritems():
            setattr(self, key, value)

        if forms:
            for data in forms:
                name, field_specs, validators = self.extract_form_data(data)
                self._init_forms(field_specs, name, validators)

        # Add ManageWorkflowForm
        workflow_form = catalog_forms.WorkflowManagementForm
        self._init_forms(workflow_form.field_specs, workflow_form.name,
                         workflow_form.validators)
Ejemplo n.º 3
0
    def __init__(self, cleaned_data, version, forms=None, templates=None,
                 application=None, **kwargs):
        self.cleaned_data = cleaned_data
        self.templates = templates or {}
        self.spec_version = str(version)

        if application is None:
            raise ValueError('Application section is required')
        else:
            self.application = application

        self.context = yaql.create_context()
        yaql_functions.register(self.context)

        self.forms = []
        for key, value in kwargs.iteritems():
            setattr(self, key, value)

        if forms:
            for counter, data in enumerate(forms):
                name, field_specs, validators = self.extract_form_data(data)
                self._add_form(name, field_specs, validators)

        # Add ManageWorkflowForm
        workflow_form = catalog_forms.WorkflowManagementForm
        if semantic_version.Version.coerce(self.spec_version) >= \
                semantic_version.Version.coerce('2.2'):
            app_name_field = workflow_form.name_field(self._get_app_name())
            workflow_form.field_specs.insert(0, app_name_field)

        self._add_form(workflow_form.name,
                       workflow_form.field_specs,
                       workflow_form.validators)
Ejemplo n.º 4
0
    def __init__(self, cleaned_data, version, fqn, forms=None, templates=None,
                 application=None, **kwargs):
        self.cleaned_data = cleaned_data
        self.templates = templates or {}
        self.spec_version = str(version)

        if application is None:
            raise ValueError('Application section is required')
        else:
            self.application = application

        self.context = legacy.create_context()
        yaql_functions.register(self.context)

        self.forms = []
        for key, value in six.iteritems(kwargs):
            setattr(self, key, value)

        if forms:
            for counter, data in enumerate(forms):
                name, field_specs, validators = self.extract_form_data(data)
                self._add_form(name, field_specs, validators)

        # Add ManageWorkflowForm
        workflow_form = catalog_forms.WorkflowManagementForm()
        if semantic_version.Version.coerce(self.spec_version) >= \
                semantic_version.Version.coerce('2.2'):
            app_name_field = workflow_form.name_field(fqn)
            workflow_form.field_specs.insert(0, app_name_field)

        self._add_form(workflow_form.name,
                       workflow_form.field_specs,
                       workflow_form.validators)
Ejemplo n.º 5
0
    def __init__(self, *args, **kwargs):
        LOG.info("Creating form {0}".format(self.__class__.__name__))
        super(ServiceConfigurationForm, self).__init__(*args, **kwargs)

        self.auto_id = '{0}_%s'.format(self.initial.get('app_id'))
        self.context = legacy.create_context()
        yaql_functions.register(self.context)

        self.finalize_fields()
        self.update_fields()
Ejemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        LOG.info("Creating form {0}".format(self.__class__.__name__))
        super(ServiceConfigurationForm, self).__init__(*args, **kwargs)

        self.context = yaql.create_context()
        yaql_functions.register(self.context)

        self.finalize_fields()
        self.initial = kwargs.get('initial', self.initial)
        self.update_fields()
Ejemplo n.º 7
0
    def __init__(self,
                 cleaned_data,
                 version,
                 fqn,
                 forms=None,
                 templates=None,
                 application=None,
                 parameters=None,
                 **kwargs):
        self.cleaned_data = cleaned_data
        self.templates = templates or {}
        self.spec_version = str(version)
        if forms is None:
            forms = []

        if application is None:
            raise ValueError('Application section is required')
        else:
            self.application = application

        self.context = legacy.create_context()
        self.context['?service'] = self
        yaql_functions.register(self.context)

        params = parameters or {}
        self.parameters = {}
        for k, v in six.iteritems(params):
            if not k or not k[0].isalpha():
                continue
            v = helpers.evaluate(v, self.context)
            self.parameters[k] = v
            self.context[k] = v

        self.forms = []
        for key, value in six.iteritems(kwargs):
            setattr(self, key, value)

        for form in forms:
            (name, field_specs, validators,
             region) = self.extract_form_data(form)
            # NOTE(kzaitsev) should be str (not unicode) under python2
            # however it also works as str under python3
            name = helpers.to_str(name)
            self._add_form(name, field_specs, validators, region)

        # Add ManageWorkflowForm
        workflow_form = catalog_forms.WorkflowManagementForm()
        if semantic_version.Version.coerce(self.spec_version) >= \
                semantic_version.Version.coerce('2.2'):
            app_name_field = workflow_form.name_field(fqn)
            workflow_form.field_specs.insert(0, app_name_field)

        self._add_form(workflow_form.name, workflow_form.field_specs,
                       workflow_form.validators)
Ejemplo n.º 8
0
 def __setstate__(self, d):
     for k, v in d.iteritems():
         setattr(self, k, v)
     # dealing with the attributes which cannot be serialized (see
     # http://tinyurl.com/kxx3tam on pickle restrictions )
     # yaql context is not serializable because it contains lambda functions
     self.context = yaql.create_context()
     yaql_functions.register(self.context)
     # form classes are not serializable 'cause they are defined dynamically
     self.forms = []
     for name, field_specs, validators in d.get('_forms', []):
         self._add_form(name, field_specs, validators)
Ejemplo n.º 9
0
    def __init__(self, cleaned_data, version, fqn, forms=None, templates=None,
                 application=None, parameters=None, **kwargs):
        self.cleaned_data = cleaned_data
        self.templates = templates or {}
        self.spec_version = str(version)
        if forms is None:
            forms = []

        if application is None:
            raise ValueError('Application section is required')
        else:
            self.application = application

        self.context = legacy.create_context()
        self.context['?service'] = self
        yaql_functions.register(self.context)

        params = parameters or {}
        self.parameters = {}
        for k, v in six.iteritems(params):
            if not k or not k[0].isalpha():
                continue
            v = helpers.evaluate(v, self.context)
            self.parameters[k] = v
            self.context[k] = v

        self.forms = []
        for key, value in six.iteritems(kwargs):
            setattr(self, key, value)

        for form in forms:
            (name, field_specs, validators,
             region) = self.extract_form_data(form)
            # NOTE(kzaitsev) should be str (not unicode) under python2
            # however it also works as str under python3
            name = helpers.to_str(name)
            self._add_form(name, field_specs, validators, region)

        # Add ManageWorkflowForm
        workflow_form = catalog_forms.WorkflowManagementForm()
        if semantic_version.Version.coerce(self.spec_version) >= \
                semantic_version.Version.coerce('2.2'):
            app_name_field = workflow_form.name_field(fqn)
            workflow_form.field_specs.insert(0, app_name_field)

        self._add_form(workflow_form.name,
                       workflow_form.field_specs,
                       workflow_form.validators)