ndb.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:start 作者: argeweb 项目源码 文件源码
def convert_KeyProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.KeyProperty``."""
        if 'reference_class' not in kwargs\
                or 'query' not in kwargs:
            try:
                reference_class = prop._kind
            except AttributeError:
                reference_class = prop._reference_class

            if isinstance(reference_class, string_types):
                # This assumes that the referenced module is already imported.
                try:
                    reference_class = model._kind_map[reference_class]
                except KeyError:
                    # If it's not imported, just bail, as we can't
                    # edit this field safely.
                    return None
            kwargs['reference_class'] = reference_class

        kwargs.setdefault('allow_blank', not prop._required)

        if prop._repeated:
            return RepeatedKeyPropertyField(**kwargs)
        else:
            return KeyPropertyField(**kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号