[Zope-CVS] CVS: Packages/Moztop/moztopsupport/xmlrpc - __init__.py:1.1 configure.zcml:1.1 dtmlpage.py:1.1 file.py:1.1 folder.py:1.1 image.py:1.1 zptpage.py:1.1
Sidnei da Silva
sidnei@x3ng.com.br
Thu, 20 Mar 2003 13:24:30 -0500
Update of /cvs-repository/Packages/Moztop/moztopsupport/xmlrpc
In directory cvs.zope.org:/tmp/cvs-serv22557/moztopsupport/xmlrpc
Added Files:
__init__.py configure.zcml dtmlpage.py file.py folder.py
image.py zptpage.py
Log Message:
Big refactoring. Renamed idesupport to moztop support. Adding a utility to get Resource Types
=== Added File Packages/Moztop/moztopsupport/xmlrpc/__init__.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.
#
##############################################################################
"""Moztop Extension Product
$Id: __init__.py,v 1.1 2003/03/20 18:24:29 sidnei Exp $
"""
=== Added File Packages/Moztop/moztopsupport/xmlrpc/configure.zcml ===
<zopeConfigure
xmlns="http://namespaces.zope.org/zope"
xmlns:xmlrpc="http://namespaces.zope.org/xmlrpc">
<xmlrpc:view
name="methods"
for="zope.app.interfaces.container.IContentContainer"
factory=".folder.Methods"
permission="Zope.Manage"
allowed_methods="objectIds, createAndAdd, getMetaData, setMetaData"/>
<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"
allowed_methods="getMetaData, setMetaData, upload"/>
<xmlrpc:view
name="methods"
for="zope.app.interfaces.content.zpt.IZPTPage"
factory=".zptpage.Methods"
permission="Zope.Manage"
allowed_methods="getMetaData, setMetaData, setSource, getSource"/>
<xmlrpc:view
name="methods"
for="zope.app.interfaces.content.dtmlpage.IDTMLPage"
factory=".dtmlpage.Methods"
permission="Zope.Manage"
allowed_methods="getMetaData,setMetaData,setDTMLSource,getDTMLSource"/>
</zopeConfigure>
=== Added File Packages/Moztop/moztopsupport/xmlrpc/dtmlpage.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: dtmlpage.py,v 1.1 2003/03/20 18:24:29 sidnei 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 setDTMLSource(self, source):
""" """
self.context.source = unicode(source)
def getDTMLSource(self):
""" """
return self.context.getSource()
=== Added File Packages/Moztop/moztopsupport/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/03/20 18:24:29 sidnei 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}
=== Added File Packages/Moztop/moztopsupport/xmlrpc/folder.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: folder.py,v 1.1 2003/03/20 18:24:29 sidnei Exp $
"""
import datetime
from zope.component import createObject, getAdapter
from zope.publisher.xmlrpc import MethodPublisher
from zope.publisher.interfaces.xmlrpc import IXMLRPCPublisher
from zope.app.interfaces.dublincore import IZopeDublinCore
from zope.app.interfaces.container import IZopeContainer
from zope.app.interfaces.traversing import IPhysicallyLocatable, ITraverser
class Methods(MethodPublisher):
""" """
def objectIds(self):
'''Get object ids.'''
return tuple(self.context.keys())
def createAndAdd(self, type, name):
"""Create and add an object to the folder."""
content = createObject(self, type)
dc = getAdapter(content, IZopeDublinCore)
dc.created = datetime.datetime.now()
dc.modified = datetime.datetime.now()
container = getAdapter(self.context, IZopeContainer)
name = container.setObject(name, content)
return "A %s with name '%s' was successfully added!" %(type, name)
def renameObject(self, old_name, new_name):
"""Delete object with the given name."""
container = getAdapter(self.context, IZopeContainer)
content = container[old_name]
container.__delitem__(old_name)
new_name = container.setObject(new_name, content)
return "Object '%s' was renamed to '%s'." %(old_name, new_name)
def copyObject(self, name):
"""Copy object with the given name."""
container = getAdapter(self.context, IPhysicallyLocatable)
path = container.getPhysicalPath()
path = '/'.join(path)
if not path: path = '/'
return "Object '%s' was copied from '%s'." %(name, path)
def cutObject(self, name):
"""Cut object with the given name."""
container = getAdapter(self.context, IPhysicallyLocatable)
path = container.getPhysicalPath()
path = '/'.join(path)
if not path: path = '/'
return "Object '%s' was cut from '%s'." %(name, path)
def pasteObject(self, source, operation=None):
"""Paste object with the given name. If operation is cut,
remove source object."""
new_container = getAdapter(self.context, IZopeContainer)
traverser = getAdapter(self.context, ITraverser)
content = traverser.traverse(source)
content_pl = getAdapter(content, IPhysicallyLocatable)
content_path = content_pl.getPhysicalPath()
name = content_path[-1]
old_container_path = content_path[:-1]
if operation is not None:
old_container = traverser.traverse(container_path)
old_container.__delitem__(name)
name = new_container.setObject(name, content)
return "Object '%s' was pasted from '%s'." %(name, old_container_path)
def deleteObject(self, name):
"""Delete object with the given name."""
container = getAdapter(self.context, IZopeContainer)
container.__delitem__(name)
return "Object '%s' successfully deleted." %name
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."
=== Added File Packages/Moztop/moztopsupport/xmlrpc/image.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: image.py,v 1.1 2003/03/20 18:24:29 sidnei Exp $
"""
import datetime, StringIO
from zope.component import getAdapter
from zope.publisher.xmlrpc import MethodPublisher
from zope.app.interfaces.dublincore import IZopeDublinCore
from zope.app.content.image import ImageSized
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.data = data
return 'Upload successful!'
def getImageInfo(self):
""" """
return {'size': ImageSized(self.context).sizeForDisplay(),
'content_type' : self.context.contentType}
=== Added File Packages/Moztop/moztopsupport/xmlrpc/zptpage.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: zptpage.py,v 1.1 2003/03/20 18:24:29 sidnei Exp $
"""
import datetime, StringIO
from zope.component import getAdapter
from zope.publisher.xmlrpc import MethodPublisher
from zope.app.interfaces.dublincore import IZopeDublinCore
from zope.app.content.image import ImageSized
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 setZPTSource(self, source):
""" """
self.context.source = unicode(source)
def getZPTSource(self):
""" """
return self.context.getSource()