[Zope3-checkins]
SVN: Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/
Delete moved files and fix imports and configure.zcml
Roger Ineichen
roger at projekt01.ch
Thu Jan 20 11:59:11 EST 2005
Log message for revision 28892:
Delete moved files and fix imports and configure.zcml
Changed:
U Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/__init__.py
U Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/browser/configure.zcml
D Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/browser/i18nimage.py
U Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/configure.zcml
U Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/i18nfile.py
D Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/i18nimage.py
D Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/tests/test_i18nimage.py
-=-
Modified: Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/__init__.py
===================================================================
--- Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/__init__.py 2005-01-20 16:58:50 UTC (rev 28891)
+++ Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/__init__.py 2005-01-20 16:59:11 UTC (rev 28892)
@@ -18,4 +18,6 @@
__docformat__ = 'restructuredtext'
from i18nfile import I18nFile
-from i18nimage import I18nImage
+
+# TODO: check i BBB is requiered
+#from i18nimage import I18nImage
Modified: Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/browser/configure.zcml
===================================================================
--- Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/browser/configure.zcml 2005-01-20 16:58:50 UTC (rev 28891)
+++ Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/browser/configure.zcml 2005-01-20 16:59:11 UTC (rev 28892)
@@ -43,46 +43,4 @@
permission="zope.ManageContent"
/>
-
- <!-- i18nimage directives -->
-
- <browser:page
- name="index.html"
- for="zope.app.i18nfile.interfaces.II18nImage"
- permission="zope.View"
- allowed_attributes="__call__ tag"
- class=".i18nimage.I18nImageData"
- />
-
- <browser:pages
- for="zope.app.i18nfile.interfaces.II18nImage"
- permission="zope.ManageContent"
- class=".i18nimage.I18nImageEdit">
-
- <browser:page name="upload.html" template="image_edit.pt" />
- <browser:page name="uploadAction.html" attribute="action" />
-
- </browser:pages>
-
- <browser:menuItems
- menu="zmi_views"
- for="zope.app.i18nfile.interfaces.II18nImage"
- >
-
- <!-- Keep the old "edit" form -->
- <browser:menuItem title="Edit" action="upload.html"/>
-
- <!-- Suppress upload form (from IFile) -->
- <browser:menuItem title="Upload" action="upload.html"
- filter="python: False" />
-
- </browser:menuItems>
-
- <browser:addMenuItem
- class="zope.app.i18nfile.I18nImage"
- title="I18n Image"
- description="A multi-locale version of an Image."
- permission="zope.ManageContent"
- />
-
</configure>
Deleted: Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/browser/i18nimage.py
===================================================================
--- Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/browser/i18nimage.py 2005-01-20 16:58:50 UTC (rev 28891)
+++ Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/browser/i18nimage.py 2005-01-20 16:59:11 UTC (rev 28892)
@@ -1,82 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.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 image editing.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from urllib import quote
-
-from zope.i18n.negotiator import negotiator
-
-from zope.app.i18n import ZopeMessageIDFactory as _
-from zope.app.file.browser.image import ImageData
-from zope.app.size import byteDisplay
-
-class I18nImageEdit(object):
-
- name = 'editForm'
- title = _('Edit Form')
- description = _('This edit form allows you to make changes to the ' +
- 'properties of this image.')
-
- def size(self, language=None):
- sized = ISized(self.context._get(language))
- return sized.sizeForDisplay()
-
- def action(self, contentType, data, language, defaultLanguage,
- selectLanguage=None, removeLanguage=None,
- addLanguage=None, newLanguage=None):
- if selectLanguage:
- pass
- elif removeLanguage:
- self.context.removeLanguage(language)
- language = self.context.getDefaultLanguage()
- else:
- if addLanguage:
- language = newLanguage
- self.context.setDefaultLanguage(defaultLanguage)
- self.context.setData(data, language)
- self.context.contentType = contentType
- return self.request.response.redirect(self.request.URL[-1] +
- "/upload.html?language=%s" % quote(language, ''))
-
-
-class I18nImageData(ImageData):
-
- def __call__(self):
- image = self.context
- language = None
- if self.request is not None:
- langs = self.context.getAvailableLanguages()
- language = negotiator.getLanguage(langs, self.request)
- self.request.response.setHeader('content-type', image.contentType)
- return image.getData(language)
-
-
- def tag(self, height=None, width=None, **args):
- """See `ImageData.tag.`"""
-
- language = None
- if self.request is not None and \
- (width is None or height is None):
- langs = self.context.getAvailableLanguages()
- language = negotiator.getLanguage(langs, self.request)
-
- if width is None:
- width = self.context.getImageSize(language)[0]
- if height is None:
- height = self.context.getImageSize(language)[1]
- return ImageData.tag(self, width=width, height=height, **args)
Modified: Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/configure.zcml
===================================================================
--- Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/configure.zcml 2005-01-20 16:58:50 UTC (rev 28891)
+++ Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/configure.zcml 2005-01-20 16:59:11 UTC (rev 28892)
@@ -10,12 +10,7 @@
type="zope.app.content.interfaces.IContentType"
/>
- <interface
- interface=".interfaces.II18nImage"
- type="zope.app.content.interfaces.IContentType"
- />
-
<!-- content classes -->
<content class=".i18nfile.I18nFile">
@@ -45,35 +40,6 @@
/>
</content>
- <content class=".i18nimage.I18nImage">
- <factory
- id="zope.app.content.I18nImage"
- title="I18n Image"
- description="An Internationalized Image"
- />
- <require
- permission="zope.View"
- interface="zope.app.file.interfaces.IFile"
- attributes="getImageSize"
- />
- <require
- permission="zope.ManageContent"
- set_schema="zope.app.file.interfaces.IFile"
- />
- <require
- permission="zope.View"
- attributes="getDefaultLanguage getAvailableLanguages getData"
- />
- <require
- permission="zope.ManageContent"
- attributes="setDefaultLanguage removeLanguage setData"
- />
- <implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
- />
- </content>
-
-
<!-- include browser package -->
<include package=".browser" />
Modified: Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/i18nfile.py
===================================================================
--- Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/i18nfile.py 2005-01-20 16:58:50 UTC (rev 28891)
+++ Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/i18nfile.py 2005-01-20 16:59:11 UTC (rev 28892)
@@ -37,6 +37,11 @@
self.contentType = contentType or ''
+ #TODO: implement open method
+ def open(self, mode='r'):
+ """See interface 'zope.app.file.interface.IFile.'"""
+ pass
+
def _create(self, data):
"""Create a new subobject of the appropriate type. Should be
overriden in subclasses.
Deleted: Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/i18nimage.py
===================================================================
--- Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/i18nimage.py 2005-01-20 16:58:50 UTC (rev 28891)
+++ Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/i18nimage.py 2005-01-20 16:59:11 UTC (rev 28892)
@@ -1,50 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.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.
-#
-##############################################################################
-"""I18n-aware Image Content Component
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.interface import implements
-from zope.app.file.image import Image, getImageInfo
-from zope.app.i18nfile.i18nfile import I18nFile
-
-from interfaces import II18nImage
-
-class I18nImage(I18nFile):
- """An internationalized Image object. Note that images of all
- languages share the same content type.
- """
-
- implements(II18nImage)
-
- def _create(self, data):
- return Image(data)
-
- def setData(self, data, language=None):
- '''See interface `II18nFile`'''
- super(I18nImage, self).setData(data, language)
-
- if language is None or language == self.getDefaultLanguage():
- # Uploading for the default language only overrides content
- # type. Note: do not use the argument data here, it doesn't
- # work.
- contentType = getImageInfo(self.getData(language))[0]
- if contentType:
- self.contentType = contentType
-
- def getImageSize(self, language=None):
- '''See interface `II18nImage`'''
- return self._get(language).getImageSize()
Deleted: Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/tests/test_i18nimage.py
===================================================================
--- Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/tests/test_i18nimage.py 2005-01-20 16:58:50 UTC (rev 28891)
+++ Zope3/branches/jhauser-filefieldwidget/src/zope/app/i18nfile/tests/test_i18nimage.py 2005-01-20 16:59:11 UTC (rev 28892)
@@ -1,113 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.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.
-#
-##############################################################################
-"""I18n Image Tests
-
-$Id$
-"""
-
-import unittest
-from zope.interface.verify import verifyClass
-from zope.i18n.tests.testii18naware import TestII18nAware
-
-from zope.app.i18nfile.i18nimage import I18nImage
-
-def sorted(list):
- list.sort()
- return list
-
-class Test(TestII18nAware):
-
- def _makeImage(self, *args, **kw):
- return I18nImage(*args, **kw)
-
- def _createObject(self):
- obj = self._makeImage(defaultLanguage='fr')
- obj.setData('', 'lt')
- obj.setData('', 'en')
- return obj
-
- def testEmpty(self):
- file = self._makeImage()
-
- self.assertEqual(file.contentType, '')
- self.assertEqual(file.getData(), '')
- self.assertEqual(file.getDefaultLanguage(), 'en')
-
-
- def testConstructor(self):
- file = self._makeImage('Data')
- self.assertEqual(file.contentType, '')
- self.assertEqual(file.getData(), 'Data')
- self.assertEqual(file.getData('en'), 'Data')
- self.assertEqual(file.getData('nonexistent'), 'Data')
- self.assertEqual(file.getDefaultLanguage(), 'en')
- self.assertEqual(sorted(file.getAvailableLanguages()), ['en'])
-
- file = self._makeImage('Data', defaultLanguage='fr')
- self.assertEqual(file.contentType, '')
- self.assertEqual(file.getData(), 'Data')
- self.assertEqual(file.getData('en'), 'Data')
- self.assertEqual(file.getData('nonexistent'), 'Data')
- self.assertEqual(file.getDefaultLanguage(), 'fr')
- self.assertEqual(sorted(file.getAvailableLanguages()), ['fr'])
-
- def testMutators(self):
- image = self._makeImage()
-
- # Check that setData updates content type only when updating the
- # default language. Need some real images or at least headers
- # for that.
-
- gifHdr = 'GIF87a\x20\x00\x10\x00'
- image.setData(gifHdr)
- self.assertEqual(image.contentType, 'image/gif')
-
- pngHdr = '\211PNG\r\n\032\n\0\0\0\x20\0\0\0\x10'
- image.setData(pngHdr, 'fr')
- self.assertEqual(image.contentType, 'image/gif')
-
- image.setData(pngHdr, 'en')
- self.assertEqual(image.contentType, 'image/png')
-
- def testInterface(self):
- from zope.app.file.interfaces import IImage
- from zope.app.i18nfile.interfaces import II18nFile
- from zope.i18n.interfaces import II18nAware
-
- self.failUnless(IImage.implementedBy(I18nImage))
- self.failUnless(verifyClass(IImage, I18nImage))
-
- self.failUnless(II18nAware.implementedBy(I18nImage))
- self.failUnless(verifyClass(II18nAware, I18nImage))
-
- self.failUnless(II18nFile.implementedBy(I18nImage))
- self.failUnless(verifyClass(II18nFile, I18nImage))
-
- def testSetDefaultLanguage(self):
- # getDefaultLanguage and getAvailableLanguages are tested in the
- # above tests
-
- file = self._makeImage()
-
- file.setData('', language='lt')
- file.setDefaultLanguage('lt')
- self.assertEqual(file.getDefaultLanguage(), 'lt')
-
-
-def test_suite():
- loader = unittest.TestLoader()
- return loader.loadTestsFromTestCase(Test)
-
-if __name__=='__main__':
- unittest.TextTestRunner().run(test_suite())
More information about the Zope3-Checkins
mailing list