thanks again to everyone who helped me yesterday. I feel understand things a lot better now. However, there are still a lot of things I need to learn.

As suggested I'm trying to factor out a function from a content type into utility so that it can be used for any content type. My utility is simple: I want to be able to publish documents to my subscribers. The following code is based on bits of the RegistrationTool and elsewhere but with a little more understanding than my usual copy & paste:

class PublishTool(BaseTool)

    def publishByEmail(self, document=""):
        text = getattr(aq_base(document), EditableBody)
        subject = getattr(aq_base(document), Title)
        lang = getattr(aq_base(document), lang)

        ptool = getUtility(IPropertiesTool)

        headers = {}
        headers['Subject'] = subject
        headers['From'] = ptool.email_from_address
        host = getUtility(IMailHost)
        subscibers = self.getSubscribersByLanguage(lang)
        for s in subscribers:
            headers['To'] = s.email
            email = makeEmail(decode(text, script), script, headers)
                # don't stop just because you can't send a single e-mail

Now, apart from obvious problems that this is not the way to handle with large subscriptions - MailDrop or a dedicated mailing list are better for that, I know and I suspect makeEmail might not work in this context - what is the best way to make this available as an action for my documents? Looking at CMFDefault it seems that currently I would actually do much of this work in a PythonScript with attendant template very similar to how discussions work. Is this correct? Or is there another way to provide this action to documents and make it available only when the user has the correct permissions?

While I've been working on this I've noticed is that there are no browser views for the various utilities such as logging in, signing up or having a discussion. Is this because they haven't been done yet or am I looking in the wrong place?


Charlie Clark
Helmholtzstr. 20
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226

Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to