You are here: Home / Documentation / How To's / kim test

kim test

by kimtest — published Aug 16, 2016 10:50 AM, last modified Aug 16, 2016 10:50 AM
test
Plone 3.3.* and Plone 4.* You should already know how to: * Code a new Content Type or extend a Content Type. * Use Generic Setup xml files in the profiles/default directory. This is how you setup a Indexes and Metadata field for your portal_catalog with a extended content type. It will be the same for a new content type. I will add one field to the Metadata and Indexes in this example. This gives me access to the objects new attribute through portal_catalog>brains rather then waking up the object which is very slow. uwosh.product/uwosh/product/profiles/default/catalog.xml * catalog.xml 1) 2) 3) 4) 5) 6) 7) * Line 2: Tells Generic Setup where to map this Object Extension too. * Line 3-5: This sets up the portal_catalog>Indexes. It adds a new field called oneSearchId as a FieldIndex type. Don't forget to give the index a new attribute value which is on Line 4. * Line 6: This sets up the portal_catalog>Metadata with a new field called oneSearchId. oneSearchId is now accessible as a brain attribute when you make a query on the catalog. * (Specal Note) Line 6: This value oneSearchId needs to be the same name as the function definition in the Content Type Class below. This Line maps the Content Accessor of this field to the proper Metadata field. uwosh.product/uwosh/product/content/your_content_type.py * This is only a partial view of the whole file, showing key areas. 1) IYourContentTypeSchema= folder.ATBTreeFolderSchema.copy() + atapi.Schema(( 2) IntegerField('oneSearchId', 3) required=True, 4) searchable=False, 5) default = "", 6) validators = ('isInt'), 7) widget = IntegerWidget( 8) description = "Your Description", 9) label = _(u'Your Label', default=u'Your Label Default'), 10) )), 11) )) 12) ..... 13) class YourContentType(base.ATCTBTreeFolder): 14) implements(IYourContentTypeSchema) 15) ..... 16) def oneSearchId(self): 17) return self.getField('oneSearchId').get(self) 18) ...... * Line 1-11: We just extend the Folder Schema and add a new Schema Field. * Line 13-18: This is your ContentType Class which has your accessors and mutators for your Content. * Line 16-17: This is the basic accessor for your oneSearchId Field. It access and returns the oneSearchId. * (Specal Note) Line 16-17: The function definition name must be the same as the catalog.xml (Specal Note) Line 6. The catalog.xml maps to this function definition.
Navigation