(フィールドの保存場所)

Field storage tells how the value of schema field is stored.

AttributeStorage

Products.Archetypes.storage.AttributeStorage.

This is recommended from data which is always read when the object is accessed: title, description, etc.

AnnotationStorage

Products.Archetypes.storage.annotation.AnnotationStorage.

AnnotationStorage creates object attribute __annotations__ which is OOBTree object. An OOBTree uses buckets as the smallest persistent entity. A bucket usually holds a small number of items. Buckets are loaded on request and as needed compared to using native Python datatypes.

It is safe to assume that you can fit few variables to one bucket easily.

You also might want to define ATFieldProperty accessor if you are using this storage. This allows you to read the object value using standard Python attribute access notation.

Note that in this case the access goes through AT accessor and mutator functions. This differs from raw storage value access: for example AT accessor encodes strings in UTF-8 before returning them.

Example:

VariantProductSchema['myField'].storage = atapi.AnnotationStorage()

class VariantProduct(folder.ATFolder):

    meta_type = "VariantProduct"
    schema = VariantProductSchema

    myField = atapi.ATFieldProperty('title')

product = VariantProduct()

product.setMyField("foobar") # Set field using AT mutator method

products.myField = # AT field property magic. This is equal to product.getMyField()

SQLStorage

This stores field values in external SQL database.

目次

前のトピックへ

(フィールドとウィジェット)

次のトピックへ

(Archetypes ReferenceFields)

このページ