[Zope-CVS] CVS: Packages/Moztop/idesupport/xmlrpc - file.py:1.1 configure.zcml:1.5

Stephan Richter srichter@cbu.edu
Thu, 16 Jan 2003 09:43:02 -0500


Update of /cvs-repository/Packages/Moztop/idesupport/xmlrpc
In directory cvs.zope.org:/tmp/cvs-serv31744/idesupport/xmlrpc

Modified Files:
	configure.zcml 
Added Files:
	file.py 
Log Message:
Now you can edit Files. Cool.


=== Added File Packages/Moztop/idesupport/xmlrpc/file.py ===
##############################################################################
#
# Copyright (c) 2002, 2003 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# 
##############################################################################
"""

$Id: file.py,v 1.1 2003/01/16 14:42:30 srichter Exp $
"""
import datetime, StringIO
from zope.component import getAdapter
from zope.publisher.xmlrpc import MethodPublisher
from zope.app.interfaces.dublincore import IZopeDublinCore

class Methods(MethodPublisher):
    """ """

    def getMetaData(self):
        """Return a dictionary of all meta data."""
        dc = getAdapter(self.context, IZopeDublinCore)

        if dc.modified is not None:
            modified = dc.modified.strftime('%Y/%m/%d %H:%M:%S')
        else:
            modified = 'N/A'

        if dc.created is not None:
            created = dc.created.strftime('%Y/%m/%d %H:%M:%S')
        else:
            created = 'N/A'

        return {
            'title': dc.title,
            'description': dc.description,
            'modified': modified,
            'created': created
            }

    def setMetaData(self, title, description):
        """Set the new meta data."""
        dc = getAdapter(self.context, IZopeDublinCore)
        dc.title = unicode(title)
        dc.description = unicode(description)
        dc.modified = datetime.datetime.now()
        return "Meta Data successfully changed."

    
    def upload(self, data, content_type=''):
        """ """
        data = StringIO.StringIO(data)
        self.context.edit(data, content_type)
        return 'Upload successful!'


    def getFileInfo(self):
        """ """
        return {'size': str(self.context.getSize()) + ' bytes',
                'content_type' : self.context.contentType}
        

        


=== Packages/Moztop/idesupport/xmlrpc/configure.zcml 1.4 => 1.5 ===
--- Packages/Moztop/idesupport/xmlrpc/configure.zcml:1.4	Thu Jan 16 08:49:32 2003
+++ Packages/Moztop/idesupport/xmlrpc/configure.zcml	Thu Jan 16 09:42:30 2003
@@ -11,6 +11,13 @@
 
   <xmlrpc:view 
       name="methods"
+      for="zope.app.interfaces.content.file.IFile"
+      factory=".file.Methods"
+      permission="Zope.Manage"
+      allowed_methods="getMetaData, setMetaData, upload"/>
+
+  <xmlrpc:view 
+      name="methods"
       for="zope.app.interfaces.content.image.IImage"
       factory=".image.Methods"
       permission="Zope.Manage"