[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/Image - I18nImage.py:1.1 configure.zcml:1.6

Marius Gedminas mgedmin@delfi.lt
Tue, 25 Jun 2002 06:54:54 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/Image
In directory cvs.zope.org:/tmp/cvs-serv25797/lib/python/Zope/App/OFS/Content/Image

Modified Files:
	configure.zcml 
Added Files:
	I18nImage.py 
Log Message:
Added I18nImage object.


=== Added File Zope3/lib/python/Zope/App/OFS/Content/Image/I18nImage.py ===
##############################################################################
#
# 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.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.
# 
##############################################################################
"""
Revision Information:
$Id: I18nImage.py,v 1.1 2002/06/25 10:54:23 mgedmin Exp $
"""

import struct

from Zope.App.OFS.Content.Image.Image import IImage, Image, getImageInfo
from Zope.App.OFS.Content.File.I18nFile import II18nFile, I18nFile
from Zope.App.OFS.Annotation.IAnnotatable import IAnnotatable


class II18nImage(II18nFile, IImage):
    """I18n aware image interface."""


class I18nImage(I18nFile):
    """An internationalized Image object.  Note that images of all
    languages share the same content type.
    """

    __implements__ = (
        II18nImage,
        IAnnotatable,
        )


    def _create(self, data):
        return Image(data)


    def setData(self, data, language=None):
        '''See interface IFile'''
        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.setContentType(contentType)


    ############################################################
    # Implementation methods for interface
    # Zope.App.OFS.Image.IImage

    def getImageSize(self, language=None):
        '''See interface IImage'''
        return self._get(language).getImageSize()

    #
    ############################################################


=== Zope3/lib/python/Zope/App/OFS/Content/Image/configure.zcml 1.5 => 1.6 ===
 >
   <permission id="Zope.AddImages" title="Add Images" />
-  
+
   <content class=".Image.">
     <factory
-        id="Image"                        
+        id="Image"
         permission="Zope.ManageContent"
         title="Image"
         description="An Image" />
@@ -25,6 +25,34 @@
       factory="Zope.App.OFS.Annotation.AttributeAnnotations."
       provides="Zope.App.OFS.Annotation.IAnnotations."
       for=".Image." />
+
+  <content class=".I18nImage.">
+    <factory
+        id="I18nImage"
+        permission="Zope.ManageContent"
+        title="I18n Image"
+        description="An Internationalized Image" />
+    <require
+        permission="Zope.View"
+        interface="Zope.App.OFS.Content.File.IFile.IReadFile" />
+    <require
+        permission="Zope.View"
+        interface=".Image.IImage" />
+    <require
+        permission="Zope.ManageContent"
+        interface="Zope.App.OFS.Content.File.IFile.IWriteFile" />
+    <require
+        permission="Zope.View"
+        attributes="getDefaultLanguage getAvailableLanguages" />
+    <require
+        permission="Zope.ManageContent"
+        attributes="setDefaultLanguage removeLanguage" />
+  </content>
+
+  <adapter
+      factory="Zope.App.OFS.Annotation.AttributeAnnotations."
+      provides="Zope.App.OFS.Annotation.IAnnotations."
+      for=".I18nImage." />
 
   <!-- Further Directives -->