当前位置: 首页>>代码示例>>Python>>正文


Python db.ReferenceProperty方法代码示例

本文整理汇总了Python中google.appengine.ext.db.ReferenceProperty方法的典型用法代码示例。如果您正苦于以下问题:Python db.ReferenceProperty方法的具体用法?Python db.ReferenceProperty怎么用?Python db.ReferenceProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在google.appengine.ext.db的用法示例。


在下文中一共展示了db.ReferenceProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _decode_bookmark

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import ReferenceProperty [as 别名]
def _decode_bookmark(self, bookmark):
        """Decodes a bookmark and prepares the values to be used on queries.
        Currently supported properties are DateTimeProperty, FloatProperty,
        IntegerProperty, StringProperty and ReferenceProperty.

        Returns:
          A dictionary of property names/values to be used in queries.
        """
        required = list(self._bookmark_properties)
        required.append('_')
        try:
            bookmark = decode_bookmark(bookmark)
            # Ensure that all required values are available.
            for key in required:
                if key not in bookmark:
                    return None
        except:
            return None

        for key in required:
            value = bookmark[key]
            if key == '_':
                self._first_result = bookmark[key]
            elif key == '__key__':
                bookmark[key] = db.Key(value)
            else:
                prop = getattr(self._model_class, key)
                if isinstance(prop, db.ReferenceProperty):
                    bookmark[key] = db.Key(value)
                elif isinstance(prop, db.DateTimeProperty):
                    bookmark[key] = parseDateTime(value)
                else:
                    bookmark[key] = prop.data_type(value)

        return bookmark

# from http://kbyanc.blogspot.com/2007/09/python-reconstructing-datetimes-from.html 
开发者ID:elsigh,项目名称:browserscope,代码行数:39,代码来源:pager.py

示例2: convert_ReferenceProperty

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import ReferenceProperty [as 别名]
def convert_ReferenceProperty(model, prop, kwargs):
    """Returns a form field for a ``db.ReferenceProperty``."""
    kwargs['reference_class'] = prop.reference_class
    kwargs.setdefault('allow_blank', not prop.required)
    return ReferencePropertyField(**kwargs) 
开发者ID:jpush,项目名称:jbox,代码行数:7,代码来源:db.py

示例3: __new__

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import ReferenceProperty [as 别名]
def __new__(cls, name, bases, dct):
        myname = name.replace('ConnectionModel','').lower()
        if myname:
            #this is not the baseclass
            to_collection_name = 'myto_%s_connections' % myname #or any other naming scheme you like
            from_collection_name = 'myfrom_%s_connections' % myname #or any other naming scheme you like
            myto = 'myto_%s'%myname
            myfrom = 'myfrom_%s'%myname
            dct[myto] = db.ReferenceProperty(collection_name = to_collection_name)
            dct[myfrom] = db.ReferenceProperty(collection_name = from_collection_name)
            if 'put' in dct:
                myput = dct['put']
            else:
                myput = None

            def put(self):
                setattr(self, myto, self.myto)
                setattr(self, myfrom, self.myfrom)
                self._validate_connected_types()
                if myput is not None:
                    myput(self)
                else:
                    MyClass = eval(name)
                    super(MyClass, self).put()
            dct['put'] = put
                
        return super(ConnectionModelMetaclass, cls).__new__(cls, name, bases, dct) 
开发者ID:ActiveState,项目名称:code,代码行数:29,代码来源:recipe-578229.py

示例4: get_form_field

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import ReferenceProperty [as 别名]
def get_form_field(self, **kwargs):
    """Return a Django form field appropriate for a reference property.

    This defaults to a ModelChoiceField instance.
    """
    defaults = {'form_class': ModelChoiceField,
                'reference_class': self.reference_class}
    defaults.update(kwargs)
    return super(ReferenceProperty, self).get_form_field(**defaults) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:11,代码来源:djangoforms.py

示例5: get_value_for_form

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import ReferenceProperty [as 别名]
def get_value_for_form(self, instance):
    """Extract the property value from the instance for use in a form.

    This return the key object for the referenced object, or None.
    """
    value = super(ReferenceProperty, self).get_value_for_form(instance)
    if value is not None:
      value = value.key()
    return value 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:11,代码来源:djangoforms.py


注:本文中的google.appengine.ext.db.ReferenceProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。