<s> from substanced . event import subscribe_created <EOL> from substanced . catalog import ( <EOL> catalog_factory , <EOL> indexview , <EOL> indexview_defaults , <EOL> Field , <EOL> ) <EOL> from substanced . root import Root <EOL> from . resources import ( <EOL> BlogEntry , <EOL> Comment , <EOL> ) <EOL> @ catalog_factory ( '<STR_LIT>' ) <EOL> class BlogCatalogFactory ( object ) : <EOL> pubdate = Field ( ) <EOL> @ subscribe_created ( Root ) <EOL> def created ( event ) : <EOL> root = event . object <EOL> catalogs = root [ '<STR_LIT>' ] <EOL> catalogs . add_catalog ( '<STR_LIT>' , update_indexes = True ) <EOL> @ indexview_defaults ( catalog_name = '<STR_LIT>' ) <EOL> class BlogCatalogViews ( object ) : <EOL> def __init__ ( self , resource ) : <EOL> self . resource = resource <EOL> @ indexview ( context = BlogEntry ) <EOL> @ indexview ( context = Comment ) <EOL> def pubdate ( self , default ) : <EOL> return getattr ( self . resource , '<STR_LIT>' , default ) </s>
