Logo Search packages:      
Sourcecode: zope-cmfbibliographyat version File versions  Download package

endnote.py

############################################################################
#                                                                          #
#             copyright (c) 2004 ITB, Humboldt-University Berlin           #
#             written by: Raphael Ritz, r.ritz@biologie.hu-berlin.de       #
#                                                                          #
############################################################################

"""EndRenderer (EndNotes) class"""

# Python stuff
import os

# Zope stuff
from Globals import InitializeClass
from App.Dialogs import MessageDialog

# CMF stuff
from Products.CMFCore.utils import getToolByName

# Bibliography stuff
from Products.CMFBibliographyAT.tool.renderers.base \
     import IBibliographyRenderer, BibliographyRenderer


00025 class EndRenderer(BibliographyRenderer):
    """
    specific EndNote renderer
    depends on the BibTeX renderer
    """

    __implements__ = (IBibliographyRenderer ,)

    meta_type = "EndNote Renderer"

    format = {'name':'EndNote',
              'extension':'end'}

00038     def __init__(self,
                 id = 'endnote',
                 title = "depends on the bibtex renderer"):
        """
        initializes id and title
        """
        self.id = id
        self.title = title

00047     def render(self, object):
        """
        renders a bibliography object in EndNote's text format
        """
        bib_tool = getToolByName(object, 'portal_bibliography')
        bibtex_source = bib_tool.render(object, 'bib')

        # open a pipe
        (fi, fo, fe) = os.popen3('bib2xml | xml2end', 't')
        # provide the input
        fi.write(bibtex_source)
        fi.close()
        # get the output
        end = fo.read()
        fo.close()
        # get the staus/error message
        # (this isn't used but we don't want it in the output)
        error = fe.read()
        fe.close()
        # done
        return end


# Class instanciation
InitializeClass(EndRenderer)


def manage_addEndRenderer(self, REQUEST=None):
    """ """
    try:
        self._setObject('endnote', EndRenderer())
    except:
        return MessageDialog(
            title='Bibliography tool warning message',
            message='The renderer you attempted to add already exists.',
            action='manage_main')
    return self.manage_main(self, REQUEST)

Generated by  Doxygen 1.6.0   Back to index