Created
December 11, 2012 20:48
-
-
Save pellekrogholt/4261999 to your computer and use it in GitHub Desktop.
extend collective.contentrules.mail 0.4 / plone 3.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configure | |
xmlns="http://namespaces.zope.org/zope" | |
xmlns:five="http://namespaces.zope.org/five" | |
xmlns:browser="http://namespaces.zope.org/browser" | |
i18n_domain="mysite.site"> | |
<include package="z3c.unconfigure" file="meta.zcml" /> | |
<unconfigure> | |
<adapter factory="collective.contentrules.mail.adapter.MailReplacer" /> | |
</unconfigure> | |
<!-- note: the adapter one is required --> | |
<adapter factory=".mail.MailReplacerExtended" | |
provides=".mail.IMailReplacerExtended" | |
/> | |
<unconfigure> | |
<utility | |
component="collective.contentrules.mail.model.DefaultMailModel" | |
name="collective.contentrules.mail.model.base" | |
/> | |
</unconfigure> | |
<utility | |
component=".mail.ExtendedMailModel" | |
name="collective.contentrules.mail.model.base" | |
/> | |
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zope.schema import TextLine, Object, List, Tuple | |
from zope.interface import implements | |
from zope.component import adapts | |
from zope.schema import getFieldsInOrder | |
from collective.contentrules.mail.model import MailModel | |
from collective.contentrules.mail.interfaces import IMailModel | |
from collective.contentrules.mail.interfaces import IMailReplacer | |
from collective.contentrules.mail.adapter import MailReplacer | |
from Products.CMFCore.utils import getToolByName | |
from Products.CMFCore.interfaces import IDublinCore | |
from mysite.site import siteMessageFactory as _ | |
class IMailReplacerExtended(IMailReplacer): | |
foo = TextLine(title=_(u"foo of content",)) | |
class MailReplacerExtended(MailReplacer): | |
"""Provides attributes which can be used in a mail model""" | |
implements(IMailReplacerExtended) | |
adapts(IDublinCore) | |
@property | |
def foo(self): | |
""" | |
The goal is self.context.getContactEmail() | |
""" | |
#import pdb; pdb.set_trace() | |
return "foo called" | |
# The default mail model, which uses the default mail replacer. | |
ExtendedMailModel = MailModel(title=_(u"Extended standard model for plone content"), | |
replacer_interface=IMailReplacerExtended) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
working(tm) - the model was crucial to setup as well