[Product-Developers] setDefaulPage for subcatalog

Jaroslav Šatkevič jaroslav at akl.lt
Sun Feb 22 09:23:17 UTC 2009


Hello,

I have my own product and use Plone 3.2.1

My product have content types Subject and WikiCatalog.
When I add Subject object, subscriber add WikiCatalog and then want
set WikiCatalog as default page for Subject.

interfaces.py
---------------
class ISubject(Interface):
    """Interface for Subject type
    """
    contains('my.product.interfaces.IWikiCatalog')

    title = schema.TextLine(title=_(u"Title"),
                            description=_(u"Name of the subject"),
                            required=True)

    description = schema.Text(title=_(u"Description"),
                              description=_(u"A short summary of the 
subject"),
                              required=False)

class IWikiCatalog(Interface):
    """Conterneer for wiki objects"""

    contains('my.product.interfaces.IWiki',)

    title = schema.TextLine(title=_(u"Title"),
                            description=_(u"Folder title."),
                            required=True)


content.py
-------------
Catalog_schema = ATFolderSchema.copy()

catalog_hidden_fields = ('description',)
for fld in catalog_hidden_fields:
    Catalog_schema[fld].widget.visible={'edit': 'invisible',
                                        'view': 'invisible',
                                        }
Catalog_schema['title'].storage = AnnotationStorage()

class WikiCatalog(ATFolder):
    """Container, where we will store wiki pages. """
    implements(IWikiCatalog)
   
    portal_type = meta_type = 'WikiCatalog'
    schema = Catalog_schema
    _at_rename_after_creation = True

    title = ATFieldProperty('title')

registerType(WikiCatalog, PROJECTNAME)

class Subject(Container, BrowserDefaultMixin):
    """Subject type. Here we will put info about university subject's.
    """
    implements(ISubject, INameFromTitle)
    portal_type = 'Subject'

    title = u""
    description = u""

subjectFactory = Factory(Subject, title=_(u"Create new subject"))


def subject_added_event(subject, event):
    """Subject processing after creation:
    add wiki
    """
    wiki_id = 'wiki'
    default_text = 'Mano ((batai)) buvo du, vienas dingo, nerandu.'
    obj = event.object
   
    if wiki_id not in obj.objectIds():
        obj.invokeFactory('WikiCatalog', id=wiki_id,)
        obj.setDefaultPage(wiki_id)



Why this don't work?

--
Jaro




More information about the Product-Developers mailing list