[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/File - NaiveFile.py:1.1.2.1 NaiveFileEdit.py:1.1.2.1 __init__.py:1.1.2.1 edit.pt:1.1.2.1
Stephan Richter
srichter@cbu.edu
Sat, 19 Jan 2002 23:57:31 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/File
In directory cvs.zope.org:/tmp/cvs-serv30501/File
Added Files:
Tag: Zope-3x-branch
NaiveFile.py NaiveFileEdit.py __init__.py edit.pt
Log Message:
- Restructuring the directory structure in Zope.App.OFS
- Added a simple Image support including two views
NOTE: The ImageData.tag() method does not work yet, since absolute_url is
not implemented yet.
=== Added File Zope3/lib/python/Zope/App/OFS/File/NaiveFile.py ===
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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.
import Persistence
from Interface import Interface
from Zope.App.Security.IAttributeRolePermissionManageable \
import IAttributeRolePermissionManageable
class INaiveFile(Interface):
"""This is a simple implementation of a File in Zope.
Warning: You should not use this interface to implement large data
files.
"""
def edit(data, contentType=None):
"""Sets the data and the content type for the object.
Since some implementations will provide their content type through the
data, it is good to leave the argument optional.
"""
def setData(data):
"""Sets ONLY the data without changing the content type."""
def getData():
"""Returns the bits (data) of the File itself."""
def setContentType(contentType):
"""Sets the content type of the file."""
def getContentType():
"""Returns the content type of the file using mime-types syntax."""
_RAISE_KEYERROR = []
class NaiveFile(Persistence.Persistent):
""" """
__implements__ = INaiveFile
def __init__(self, data=None, contentType=None):
""" """
self._data = data
if contentType is None:
self._contentType = ''
else:
self._contentType = contentType
############################################################
# Implementation methods for interface
# Zope.App.OFS.NaiveFile.INaiveFile
def setContentType(self, contentType):
'''See interface INaiveFile'''
self._contentType = contentType
def getContentType(self):
'''See interface INaiveFile'''
return self._contentType
def edit(self, data, contentType=None):
'''See interface INaiveFile'''
self._data = data
if contentType is not None:
self._contentType = contentType
def getData(self):
'''See interface INaiveFile'''
return self._data
def setData(self, data):
'''See interface INaiveFile'''
self._data = data
#
############################################################
=== Added File Zope3/lib/python/Zope/App/OFS/File/NaiveFileEdit.py ===
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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.
"""
Define view component for naive file editing.
"""
import os
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
class NaiveFileEdit( AttributePublisher ):
__implements__ = AttributePublisher.__implements__
def __init__( self, naiveFile ):
self._naiveFile = naiveFile
def edit(self, data, contentType, REQUEST=None):
file = self.getContext()
file.edit(data, contentType)
if REQUEST is not None:
return self.index(REQUEST, msg='File Edited.')
#
# Make it possible for 'index' to find the naiveFile.
#
def getContext( self ):
return self._naiveFile
index = PageTemplateFile('naiveFile_edit.pt')
=== Added File Zope3/lib/python/Zope/App/OFS/File/__init__.py ===
=== Added File Zope3/lib/python/Zope/App/OFS/File/edit.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<style metal:fill-slot="headers" type="text/css">
<!--
.ContentIcon {
width: 20px;
}
.ContentTitle {
text-align: left;
}
-->
</style>
</head>
<body>
<div metal:fill-slot="body">
<p tal:content="here/msg"
tal:condition="python: hasattr(here, 'msg')">
Message will go here.
</p>
<form action="edit" method="post">
<table class="EditTable">
<tbody>
<tr>
<th class="EditAttributeName">Content-Type</th>
<td class="EditAttributeValue">
<input type="text" name="contentType"
tal:attributes="value here/getContentType" />
</td>
</tr>
<tr>
<th class="EditAttributeName">Data</th>
<td class="EditAttributeValue">
<textarea name="data"
tal:content="here/getData">Data</textarea>
</td>
</tr>
</tbody>
</table>
<input type="submit" name="edit" value="Save Changes">
</form>
</div>
</body>
</html>