2008年5月14日水曜日

データストア Property

http://code.google.com/appengine/docs/datastore/typesandpropertyclasses.html
http://code.google.com/appengine/docs/datastore/typesandpropertyclasses.html#StringProperty

class StringProperty(verbose_name=None, multiline=False, ...)

A short string property. Takes a Python str or unicode (basestring) value of 500 bytes or less.

500バイト以下

StringProperty property values are indexed, and can be used in filters and sort orders.

インデックスによるフィルタ、並び替え可能

If multiline is False, then the value cannot include linefeed characters. The djangoforms library uses this to enforce a difference between text fields and textarea fields in the data model, and others can use it for a similar purpose.

multiline=True にすると LF(Line Feed)を含めることができる

Value type: str or unicode

class TextProperty()

A long string.

Unlike StringProperty, a TextProperty value can be more than 500 bytes long. However, TextProperty values are not indexed, and cannot be used in filters or sort orders.

500 バイト以上対応

フィルタはつかえない
検索条件にするものには向かない

TextProperty values store text with a text encoding. For binary data, use BlobProperty.

Value type: Text


class DateTimeProperty(verbose_name=None, auto_now=False, auto_now_add=False, ...)

A date and time property.

If auto_now is True, the property value is set to the current time whenever the model instance is stored in the datastore, overwriting the property's previous value. This is useful for tracking a "last modified" date and time for a model instance.

If auto_now_add is True, the property value is set to the current time the first time the model instance is stored in the datastore, unless the property has already been assigned a value. This is useful for storing a "created" date and time for a model instance.

BadValueError: Property entry_date must be a datetime

Date-time values are stored as and returned using the UTC time zone. See datetime.datetime for a discussion of how to manage time zones.

Value type: datetime.datetime

datetime に文字列の日時をいきなり代入しようとすると以下のエラーとなる。
BadValueError: Property entry_date must be a datetime
strptime での対応が必要。

yymm = '2008-05-10 22:22:22'
ydate = datetime.datetime.strptime(yymm, '%Y-%m-%d %H:%M:%S')
print ydate

フォーマット文字 説明 出力例
a 'a.m.' または 'p.m.' (Associated Press に合わせるため,'.' が入っている点が PHP と違います). 'a.m.'
A 'AM' または 'PM' です. 'AM'
B 実装されていません.
d 月の中の日. 2 桁のゼロ詰めです. '01' から '31'
D 週の中の日. 3 文字のテキスト形式です. 'Fri'
f 12 時間表記の時と分.ただし,ゼロ分の場合には表示しません.独自の拡張です. '1', '1:30'
F 月名を長いテキスト形式で表したものです. 'January'
g 12 時間表記の時.ゼロ詰めはしません. '1' から '12'
G 24 時間表記の時.ゼロ詰めはしません. '0' から '23'
h 12 時間表記の時です. '01' から '12'
H 24 時間表記の時です. '00' から '23'
i 分です. '00' から '59'
I 実装されていません.
j 月の中の日.ゼロ詰めしません. '1' から '31'
l 週の中の曜日.長いテキスト形式です. 'Friday'
L 閏年かどうかを表すブール値です. True``または``False
m 月です.2 桁でゼロ詰めしたものです. '01' から '12'
M 月です.3 文字のテキスト形式です. 'Jan'
n 月です.ゼロ詰めしません. '1' から '12'
N Associated Press スタイルの月の省略表記です.独自の拡張です. 'Jan.', 'Feb.', 'March', 'May'
O グリニッジ標準時からの時差です. '+0200'
P 時刻です.12 時間表記の時,分,そして 'a.m.'/'p.m.' です.分がゼロの場合には省略され,必要に応じて'midnight' または 'noon' になります.独自の拡張です. '1 a.m.', '1:30 p.m.', 'midnight', 'noon', '12:30 p.m.'
r RFC 822 に従ったフォーマットの日時です. 'Thu, 21 Dec 2000 16:01:07 +0200'
s 秒です. 2 桁のゼロ詰めです. '00' から '59'
S 月の中の日につける 2 文字の序数接尾辞です. 'st', 'nd', 'rd' or 'th'
t 月の日数です. 28 から 31
T 計算機のタイムゾーン設定です. 'EST', 'MDT'
U 実装されていません.
w 週の中の曜日です.ゼロ詰めしません. '0' (Sunday) to '6' (Saturday)
W ISO-8601 に従った年の中の週番号です.週は月曜日から始まります. 1, 23
y 2 桁の年です. '99'
Y 4 桁の年です. '1999'
z 年の中の日 0 から 365
Z タイムゾーンオフセットを秒であらわしたものです.UTC よりも西側のタイムゾーン値は全て負の値になり,東側の値は常に正になります. -43200 から 43200

例:

It is {% now "jS F Y H:i" %}

フォーマット文字列中で普通の文字列を使いたければ,バックスラッシュでエスケープできます.下の例では,"f" が時刻を表すフォーマット指定子として解釈されないようにエスケープしています. "o" はフォーマット指定子ではないのでエスケープしていません:

It is the {% now "jS o\f F" %}

このテンプレートは "It is the 4th of September" になります.


Unityでドアの開閉はAnimatorそれともiTween?

Mac Mini M2 の Unity で Sketchup のデータを復元したつづき。 以前、苦労して作成したドアの開閉が動作しないので修復する。 どうやって動かしていたのか、また忘れそうなので記録しておく。             Animator 左右のドア PlaneL,...