add_moblog_entry.py
Click here to get the file
Size
1 kB
-
File type
text/python-source
File contents
#Parameters : entry_id,title,body,image_path
# Add object
new_id = context.invokeFactory(id=entry_id,type_name='COREBlogEntry')
ent = context[entry_id]
# Set body,title
ent.setContentType('text/plain','body')
ent.setTitle(title)
ent.setBody(body)
# Set category
cat_id = context.getCategoryFolder()['moblog'].getInternal_id()
ent.setEntry_categories(str(cat_id))
# Add image reference
ref_obj = context.restrictedTraverse(image_path)
ent.addReference(ref_obj,'relatesTo')
# Set position,size
ent.setMedia_position(3)
ent.setMedia_size('preview')
# Index entry
ent.indexObject()
# Publish entry
ent.content_status_modify(workflow_action='publish')