The project I am working on uses Plone's awesome Dexterity plugin. A couple of my custom content types have very specific names that must be computed. The way I had originally accomplished this before was by adding plone.app.content.interfaces.INameFromTitle as a behavior in the object's generic setup entry, per the manual's directions:
<?xml version="1.0"?>
<object name="avrc.aeh.cycle" meta_type="Dexterity FTI">
...
<property name="schema">myproject.mytype.IMyType</property>
<property name="klass">plone.dexterity.content.Item</property>
...
<property name="behaviors">
<element value="plone.app.content.interfaces.INameFromTitle" />
</property>
...
</object>
Then I created an adapter that would provide INameFromTitle:
from five import grok
from zope.interface import Interface
import zope.schema
from plone.app.content.interfaces import INameFromTitle
class IMyType(Interface):
foo = zope.schema.TextLine(
title=u'Foo'
)
class NameForMyType(grok.Adapter):
grok.context(IMyType)
grok.provides(INameFromTitle)
@property
def title(self):
return u'Custom Title %s' % self.context.foo
This method is very similar to that suggested in this blog post:
http://davidjb.com/blog/2010/04/plone-and-dexterity-working-with-computed-fields
Unfortunately, this method stopped working after plone.app.dexterity beta and now my content items don't have their names assigned properly.
Would anyone happen to know how to extend Dexterity's INameFromTitle behavior for very specific naming use-cases?
Your help is much appreciated, thanks!