Hi,
I have an issue that I cant fix. I want an custom Id, generated from
'{0}-{1}'.format(first_name, last_name)
But it doesn't work. I tried it with an behavior, here is my code so far
Behavior
<plone:behavior
title="Name from Patient"
name="ps.vita.namefrompatientname"
description="Automatically generate short URL name for content based on patient name"
provides=".id.INameFromPatientName"
factory=".id.NameFromPatientName"
for="plone.dexterity.interfaces.IDexterityContent"
/>
<adapter factory=".id.NameFromPatientName" />
class INameFromPatientName(Interface):
"""Marker interface to enable name from filename behavior"""
print 'INameFromPatientName ...'
@implementer(INameFromTitle)
@adapter(INameFromPatientName)
class NameFromPatientName(object):
def __init__(self, context):
print '__init__ ...'
self.context = context
def __new__(cls, context):
instance = super(NameFromPatientName, cls).__new__(cls)
print '..........'
try:
title = context.first_name + ' ' + context.last_name
except AttributeError:
return u'new person'
if context.prefix:
title = '%s %s' % (context.prefix, title)
if context.suffix:
title = '%s, %s' % (title, context.suffix)
instance.title = '%s-%s' % (context.first_name, context.last_name)
context.setTitle(title)
return instance
I already copied and paste the code from https://github.com/plone/plone.app.dexterity/blob/master/plone/app/dexterity/behaviors/filename.py
but it does nothing...
I hope someone could give me a hint