[Zope3-checkins] CVS: Zope3/src/zope/app/i18nfile/browser -
__init__.py:1.2 configure.zcml:1.2 file_edit.pt:1.2
i18nfile.py:1.2 i18nimage.py:1.2 image_edit.pt:1.2
Philipp von Weitershausen
philikon at philikon.de
Tue Feb 24 11:50:40 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/i18nfile/browser
In directory cvs.zope.org:/tmp/cvs-serv26556/src/zope/app/i18nfile/browser
Added Files:
__init__.py configure.zcml file_edit.pt i18nfile.py
i18nimage.py image_edit.pt
Log Message:
Moved I18nFile and I18nImage to their own package below zope.app,
including their interfaces and browser views.
=== Zope3/src/zope/app/i18nfile/browser/__init__.py 1.1 => 1.2 ===
--- /dev/null Tue Feb 24 11:50:39 2004
+++ Zope3/src/zope/app/i18nfile/browser/__init__.py Tue Feb 24 11:50:08 2004
@@ -0,0 +1,2 @@
+#
+# This file is necessary to make this directory a package.
=== Zope3/src/zope/app/i18nfile/browser/configure.zcml 1.1 => 1.2 ===
--- /dev/null Tue Feb 24 11:50:39 2004
+++ Zope3/src/zope/app/i18nfile/browser/configure.zcml Tue Feb 24 11:50:08 2004
@@ -0,0 +1,88 @@
+<configure
+ xmlns='http://namespaces.zope.org/zope'
+ xmlns:browser='http://namespaces.zope.org/browser'
+ i18n_domain='zope'
+ >
+
+ <!-- i18nfile directives -->
+
+ <browser:page
+ name="index.html"
+ for="zope.app.i18nfile.interfaces.II18nFile"
+ permission="zope.View"
+ class=".i18nfile.I18nFileView"
+ />
+
+ <browser:pages
+ for="zope.app.i18nfile.interfaces.II18nFile"
+ permission="zope.View"
+ class=".i18nfile.I18nFileEdit">
+
+ <browser:page name="editForm.html" template="file_edit.pt" />
+ <browser:page name="edit.html" attribute="action" />
+
+ </browser:pages>
+
+ <browser:menuItems
+ menu="zmi_views"
+ for="zope.app.i18nfile.interfaces.II18nFile">
+
+ <!-- Keep original edit view, for now -->
+ <browser:menuItem title="Edit" action="editForm.html" />
+
+ <!-- Supress the upload view from file -->
+ <browser:menuItem title="Upload" action="editForm.html"
+ filter="python: False" />
+
+ </browser:menuItems>
+
+ <browser:addMenuItem
+ class="zope.app.i18nfile.I18nFile"
+ title="I18n File"
+ description="A file that supports multiple locales."
+ 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>
=== Zope3/src/zope/app/i18nfile/browser/file_edit.pt 1.1 => 1.2 ===
--- /dev/null Tue Feb 24 11:50:39 2004
+++ Zope3/src/zope/app/i18nfile/browser/file_edit.pt Tue Feb 24 11:50:08 2004
@@ -0,0 +1,98 @@
+<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="context/msg"
+ tal:condition="python: hasattr(context, 'msg')">
+ Message will go here.
+ </p>
+
+ <p tal:content="view/description">
+ Description of the Form.
+ </p>
+
+ <form action="edit.html" method="post">
+
+ <div class="row">
+ <div class="label" i18n:translate="">Content Type</div>
+ <div class="field">
+ <input name="contentType" type="text" size="20"
+ tal:attributes="value context/getContentType" />
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="label" i18n:translate="">Default Language</div>
+ <div class="field">
+ <select name="defaultLanguage">
+ <span tal:repeat="lang context/getAvailableLanguages"
+ tal:omit-tag="">
+ <option tal:attributes="
+ value lang;
+ selected python:context.getDefaultLanguage() == lang"
+ tal:content="lang" />
+ </span>
+ </select>
+ </div>
+ </div>
+ <hr />
+ <div class="row">
+ <div class="label" i18n:translate="">Language</div>
+ <div class="field">
+ <select name="language">
+ <span tal:repeat="lang context/getAvailableLanguages"
+ tal:omit-tag="">
+ <option tal:attributes="
+ value lang;
+ selected python:request.get('language',
+ context.getDefaultLanguage()) == lang"
+ tal:content="lang" />
+ </span>
+ </select>
+ <input type="submit" name="selectLanguage" value="Show"
+ i18n:attributes="value show-button"/>
+ <input type="submit" name="removeLanguage"
+ i18n:attributes="value remove-button"/>
+
+ <input type="submit" name="addLanguage"
+ value="Add new language"
+ i18n:attributes="value" />
+ <input type="text" name="newLanguage" size="10" />
+ </div>
+ </div>
+ <div class="row">
+ <div class="label" i18n:translate="">Data</div>
+ <div class="field">
+ <textarea name="data" cols="70" rows="10"
+ tal:content="python:context.getData(request.get('language'))" />
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="controls">
+ <input type="submit" name="edit" value="Save Changes"
+ i18n:attributes="value save-changes-button"/>
+ </div>
+ </div>
+
+ </form>
+
+</div>
+</body>
+</html>
+
+
=== Zope3/src/zope/app/i18nfile/browser/i18nfile.py 1.1 => 1.2 ===
--- /dev/null Tue Feb 24 11:50:39 2004
+++ Zope3/src/zope/app/i18nfile/browser/i18nfile.py Tue Feb 24 11:50:08 2004
@@ -0,0 +1,62 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""I18n versions of several content objects.
+
+$Id$
+"""
+from zope.i18n.negotiator import negotiator
+
+__metaclass__ = type
+
+class I18nFileView:
+
+ def __call__(self):
+ """Call the File
+ """
+ request = self.request
+ language = None
+ if request is not None:
+ langs = self.context.getAvailableLanguages()
+ language = negotiator.getLanguage(langs, request)
+
+ request.response.setHeader('Content-Type',
+ self.context.getContentType())
+ request.response.setHeader('Content-Length',
+ self.context.getSize(language))
+
+ return self.context.getData(language)
+
+
+class I18nFileEdit:
+
+ name = 'editForm'
+ title = 'Edit Form'
+ description = ('This edit form allows you to make changes to the ' +
+ 'properties of this file.')
+
+ 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.edit(data, contentType, language)
+ return self.request.response.redirect(self.request.URL[-1] +
+ "/editForm.html?language=%s" %language) # XXX url_quote
=== Zope3/src/zope/app/i18nfile/browser/i18nimage.py 1.1 => 1.2 ===
--- /dev/null Tue Feb 24 11:50:40 2004
+++ Zope3/src/zope/app/i18nfile/browser/i18nimage.py Tue Feb 24 11:50:08 2004
@@ -0,0 +1,81 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Define view component for image editing.
+
+$Id$
+"""
+from zope.i18n.negotiator import negotiator
+from zope.app.i18n import ZopeMessageIDFactory as _
+from zope.app.file.browser.image import ImageData
+
+__metaclass__ = type
+
+class I18nImageEdit:
+
+ name = 'editForm'
+ title = _('Edit Form')
+ description = _('This edit form allows you to make changes to the ' +
+ 'properties of this image.')
+
+ def getImageSize(self, language=None):
+ # XXX Change to ISizeable adapter
+ size = self.context.getImageSize(language)
+ return "%d x %d" % (size[0], size[1])
+
+ 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.edit(data, contentType, language)
+ return self.request.response.redirect(self.request.URL[-1] +
+ "/editForm.html?language=%s" % language) # XXX url_quote
+
+
+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.getContentType())
+ # XXX: no content-length? See ImageData.__call__
+ 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)
=== Zope3/src/zope/app/i18nfile/browser/image_edit.pt 1.1 => 1.2 ===
--- /dev/null Tue Feb 24 11:50:40 2004
+++ Zope3/src/zope/app/i18nfile/browser/image_edit.pt Tue Feb 24 11:50:08 2004
@@ -0,0 +1,110 @@
+<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="options/msg | nothing">
+ Message will go here.
+ </p>
+
+ <p tal:content="view/description">
+ Description of the Form.
+ </p>
+
+ <form action="uploadAction.html" method="post"
+ enctype="multipart/form-data">
+
+ <div class="row">
+ <div class="label" i18n:translate="">Content Type</div>
+ <div class="field">
+ <input name="contentType" type="text" size="20"
+ tal:attributes="value context/getContentType" />
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="label" i18n:translate="">Default Language</div>
+ <div class="field">
+ <select name="defaultLanguage">
+ <span tal:repeat="lang context/getAvailableLanguages"
+ tal:omit-tag="">
+ <option tal:attributes="
+ value lang;
+ selected python:context.getDefaultLanguage() == lang"
+ tal:content="lang" />
+ </span>
+ </select>
+ </div>
+ </div>
+ <hr />
+ <div class="row">
+ <div class="label" i18n:translate="">Language</div>
+ <div class="field">
+ <select name="language">
+ <span tal:repeat="lang context/getAvailableLanguages"
+ tal:omit-tag="">
+ <option tal:attributes="
+ value lang;
+ selected python:request.get('language',
+ context.getDefaultLanguage()) == lang"
+ tal:content="lang" />
+ </span>
+ </select>
+ <input type="submit" name="selectLanguage" value="Show"
+ i18n:attributes="value show-button"/>
+ <input type="submit" name="removeLanguage"
+ i18n:attributes="value remove-button"/>
+
+ <input type="submit" name="addLanguage"
+ value="Add new language"
+ i18n:attributes="value" />
+ <input type="text" name="newLanguage" size="10" />
+ </div>
+ </div>
+ <div class="row">
+ <div class="label" i18n:translate="">Data</div>
+ <div class="field">
+ <input type="file" name="data" size="20" />
+ </div>
+ </div>
+ <div class="row">
+ <div class="label" i18n:translate="">Dimensions</div>
+ <div class="field"
+ tal:content="python:view.getImageSize(request.get('language'))">
+ 40 x 40
+ </div>
+ </div>
+ <div class="row">
+ <div class="label" i18n:translate="">Dimensions</div>
+ <div class="field"
+ tal:content="python:view.getSize(request.get('language'))">
+ 40 kB
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="controls">
+ <input type="submit" name="edit" value="Save Changes"
+ i18n:attributes="value save-changes-button"/>
+ </div>
+ </div>
+
+ </form>
+
+</div>
+</body>
+</html>
More information about the Zope3-Checkins
mailing list