This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
glasnost/scripts/editArticle.py

30 lines
605 B
Python
Executable File

#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
from scriptingTools import *
from glasnost.proxy.tools import getProxyForServerRole
articleId = sys.argv[1]
dispatcherId = commonTools.extractDispatcherId(articleId)
init(dispatcherId)
articlesProxy = getProxyForServerRole('articles')
object = getObject(articleId)
import tempfile
fileName = tempfile.mktemp()
open(fileName, 'w').write(object.body)
os.system('$EDITOR %s' % fileName)
newBody = open(fileName).read()
if newBody == object.body:
raise 'no change'
object.body = newBody
articlesProxy.modifyObject(object)
os.unlink(fileName)