當前位置: 首頁>>代碼示例>>Python>>正文


Python db.DateTimeProperty方法代碼示例

本文整理匯總了Python中google.appengine.ext.db.DateTimeProperty方法的典型用法代碼示例。如果您正苦於以下問題:Python db.DateTimeProperty方法的具體用法?Python db.DateTimeProperty怎麽用?Python db.DateTimeProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在google.appengine.ext.db的用法示例。


在下文中一共展示了db.DateTimeProperty方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _decode_bookmark

# 需要導入模塊: from google.appengine.ext import db [as 別名]
# 或者: from google.appengine.ext.db import DateTimeProperty [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_DateTimeProperty

# 需要導入模塊: from google.appengine.ext import db [as 別名]
# 或者: from google.appengine.ext.db import DateTimeProperty [as 別名]
def convert_DateTimeProperty(model, prop, kwargs):
    """Returns a form field for a ``db.DateTimeProperty``."""
    if prop.auto_now or prop.auto_now_add:
        return None

    kwargs.setdefault('format', '%Y-%m-%d %H:%M:%S')
    return f.DateTimeField(**kwargs) 
開發者ID:jpush,項目名稱:jbox,代碼行數:9,代碼來源:db.py

示例3: get_form_field

# 需要導入模塊: from google.appengine.ext import db [as 別名]
# 或者: from google.appengine.ext.db import DateTimeProperty [as 別名]
def get_form_field(self, **kwargs):
    """Return a Django form field appropriate for a date-time property.

    This defaults to a DateTimeField instance, except if auto_now or
    auto_now_add is set, in which case None is returned, as such
    'auto' fields should not be rendered as part of the form.
    """
    if self.auto_now or self.auto_now_add:
      return None
    defaults = {'form_class': forms.DateTimeField}
    defaults.update(kwargs)
    return super(DateTimeProperty, self).get_form_field(**defaults) 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:14,代碼來源:djangoforms.py


注:本文中的google.appengine.ext.db.DateTimeProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。