polymodel.py 文件源码

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

项目:MKFQ 作者: maojingios 项目源码 文件源码
def gql(cls, query_string, *args, **kwds):
    """Returns a polymorphic query using GQL query string.

    This query is polymorphic in that it has its filters configured in a way
    to retrieve instances of the model or an instance of a subclass of the
    model.

    Args:
      query_string: properly formatted GQL query string with the
        'SELECT * FROM <entity>' part omitted
      *args: rest of the positional arguments used to bind numeric references
        in the query.
      **kwds: dictionary-based arguments (for named parameters).
    """
    if cls == cls.__root_class__:
      return super(PolyModel, cls).gql(query_string, *args, **kwds)
    else:
      from google.appengine.ext import gql


      query = db.GqlQuery('SELECT * FROM %s %s' % (cls.kind(), query_string))










      query_filter = [('nop',
                       [gql.Literal(cls.class_name())])]
      query._proto_query.filters()[('class', '=')] = query_filter
      query.bind(*args, **kwds)
      return query
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号