コード例 #1
0
    def convert_KeyProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.KeyProperty``."""
        if 'reference_class' not in kwargs:
            try:
                reference_class = prop._kind
            except AttributeError:
                reference_class = prop._reference_class

            if isinstance(reference_class, string_types):
                # reference class is a string, try to retrieve the model object.
                mod = __import__(model.__module__, None, None, [reference_class], 0)
                reference_class = getattr(mod, reference_class)
            kwargs['reference_class'] = reference_class
        kwargs.setdefault('allow_blank', not prop._required)
        return KeyPropertyField(**kwargs)
コード例 #2
0
class EditProfileForm(forms.EditProfileForm):
    activated = fields.BooleanField('Activated')
    #group = fields.SelectField()_('Country'), choices=[])
    group = KeyPropertyField('Group', reference_class=Group)
コード例 #3
0
ファイル: ndb.py プロジェクト: NamPNQ/gae-init-babel
 def convert_KeyProperty(self, model, prop, kwargs):
     """Returns a form field for a ``ndb.KeyProperty``."""
     kwargs['reference_class'] = prop._reference_class
     kwargs.setdefault('allow_blank', not prop._required)
     return KeyPropertyField(**kwargs)
コード例 #4
0
ファイル: test_ndb.py プロジェクト: quantus/wtforms
 class F(Form):
     author = KeyPropertyField(reference_class=Author)