[Zope-CMF] First steps with tools

2007-10-31 Thread Charlie Clark

Hi,

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)
try:
host.send(email)
except:
# 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

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



___
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

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


Re: [Zope-CMF] First steps with tools

2007-10-31 Thread Wichert Akkerman
Previously Charlie Clark wrote:
 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.

There are a million example out there you can use. I suggest that you
take a look at how those work. The plone collective may be especially
helpful. Don't be scared of by the fact that that is a Plone repository:
all the general concepts apply just as well to pure CMF.

If you want to see an example of a subscription/newsletter type of
product (which appears to be your use case) using only Z3 concepts look
at collective.revelation for example. 

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.
___
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

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


Re: [Zope-CMF] First steps with tools

2007-10-31 Thread Charlie Clark


Am 31.10.2007 um 15:02 schrieb Wichert Akkerman:


There are a million example out there you can use. I suggest that you
take a look at how those work. The plone collective may be especially
helpful. Don't be scared of by the fact that that is a Plone  
repository:

all the general concepts apply just as well to pure CMF.

If you want to see an example of a subscription/newsletter type of
product (which appears to be your use case) using only Z3 concepts  
look

at collective.revelation for example.


Thanks for the tips. I will certainly take a look at the  
collective.revelation.


But regarding the CMF and browser views: do these need doing for CMf  
2.2?


In the meantime implementing an action to publish in a PythonScript  
is, as ever, a doddle. :-D


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



___
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

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


Re: [Zope-CMF] First steps with tools

2007-10-31 Thread Jens Vagelpohl


On Oct 31, 2007, at 20:54 , Charlie Clark wrote:
But regarding the CMF and browser views: do these need doing for CMf  
2.2?


In the meantime implementing an action to publish in a PythonScript  
is, as ever, a doddle. :-D


If you're asking must I use them in CMF 2.2 then the answer is no,  
you can still use whatever scripting you like.


jens



___
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

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