[Zope-CMF] invokeFactory query
Chris Withers
chrisw@nipltd.com
Tue, 10 Jul 2001 10:31:38 +0100
seb bacon wrote:
>
> I think the current behaviour is probably OK for now.
Yeah, so do I, I changed my mind :-)
I now have a seperate skin method caleld addArticle:
## Script (Python) "addArticle"
##title=adds an article
##parameters=id=None
from DateTime import DateTime
now = DateTime()
(year,month,day,hour,minute,second,timezone)=now.parts()
second=int(second)
# find a place to store the article, create if necessary
c = container.portal_url.getPortalObject()
month = now.Month()
path=[`year`,month,`day`]
for segment in path:
if not hasattr(c,segment):
c.manage_addProduct['CMFDefault'].manage_addPortalFolder(segment)
c = getattr(c,segment)
# generate an id, if necessary, maek sure it doesn't exist already
while id is None or hasattr(c,id):
id = '%s.%s.%s' % (hour,minute,second)
second = second + 1
return c.invokeFactory(type_name='Article',
id=id,RESPONSE=container.REQUEST.RESPONSE)
...which I like :-)
cheers,
Chris