[Zope3-checkins] CVS: Zope3/src/zope/app/browser/content - __init__.py:1.2 add.pt:1.2 configure.zcml:1.2 document.gif:1.2 dtml.gif:1.2 dtmlpageeval.py:1.2 file.py:1.2 file_icon.gif:1.2 folder.py:1.2 folder_icon.gif:1.2 i18n.py:1.2 i18n_edit.pt:1.2 i18nimage.py:1.2 i18nimageedit.pt:1.2 image.py:1.2 image_icon.gif:1.2 imageedit.pt:1.2 sql.py:1.2 sqltest.pt:1.2 sqltestresults.pt:1.2 zpt.gif:1.2 zpt.py:1.2
Jim Fulton
jim@zope.com
Wed, 25 Dec 2002 09:14:03 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/content
In directory cvs.zope.org:/tmp/cvs-serv15352/src/zope/app/browser/content
Added Files:
__init__.py add.pt configure.zcml document.gif dtml.gif
dtmlpageeval.py file.py file_icon.gif folder.py
folder_icon.gif i18n.py i18n_edit.pt i18nimage.py
i18nimageedit.pt image.py image_icon.gif imageedit.pt sql.py
sqltest.pt sqltestresults.pt zpt.gif zpt.py
Log Message:
Grand renaming:
- Renamed most files (especially python modules) to lower case.
- Moved views and interfaces into separate hierarchies within each
project, where each top-level directory under the zope package
is a separate project.
- Moved everything to src from lib/python.
lib/python will eventually go away. I need access to the cvs
repository to make this happen, however.
There are probably some bits that are broken. All tests pass
and zope runs, but I haven't tried everything. There are a number
of cleanups I'll work on tomorrow.
=== Zope3/src/zope/app/browser/content/__init__.py 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:01 2002
+++ Zope3/src/zope/app/browser/content/__init__.py Wed Dec 25 09:12:30 2002
@@ -0,0 +1,2 @@
+#
+# This file is necessary to make this directory a package.
=== Zope3/src/zope/app/browser/content/add.pt 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:01 2002
+++ Zope3/src/zope/app/browser/content/add.pt Wed Dec 25 09:12:30 2002
@@ -0,0 +1,108 @@
+<html metal:use-macro="views/standard_macros/page">
+<head>
+<style metal:fill-slot="headers" type="text/css">
+
+.Selector {
+ width: 10px;
+}
+
+.TypeIcon {
+ width: 20px;
+}
+
+.TypeName {
+ text-align: left;
+}
+
+.TypeDescription {
+ text-align: left;
+ font-style: italic;
+}
+</style>
+</head>
+<body>
+
+<div metal:fill-slot="body">
+
+<form action="action.html" method="POST">
+<table class="TypeListing">
+
+ <caption>Add Content</caption>
+
+ <tr>
+ <td class="Selector"><br /></td>
+ <th class="TypeName">Title</th>
+ </tr>
+
+ <!--
+ ** listAddableInfo returns a sequence of mappings, containing:
+ ** 'id' : the ID of the addable type
+ ** 'title' : the title of the addable type
+ ** 'description' : the description of the addable type
+ -->
+ <tbody tal:repeat="info view/addingInfo">
+
+ <tr>
+
+ <td class="Selector">
+ <input type="radio" name="type_name"
+ tal:attributes="value info/action; id info/action" />
+ </td>
+
+ <td class="TypeName">
+ <label tal:attributes="for info/action">
+ <span tal:replace="info/title">Folder</span>
+ </label>
+ </td>
+
+ </tr>
+
+ <tr>
+ <td class="Selector"><br /></td>
+ <td class="TypeDescription">
+ <label tal:attributes="for info/action" tal:content="info/description">
+ Folders are generic containers for content, including other
+ folders.
+ </label>
+ </td>
+ </tr>
+
+ </tbody>
+
+ <tbody tal:condition="nothing">
+
+ <tr>
+
+ <td class="Selector">
+ <input type="radio" name="type_name" value="" />
+
+ </td>
+
+ <td class="TypeName">
+ <img alt="Folder" src="../../ZMI/www/document_icon.gif" />
+ Document
+ </td>
+
+ </tr>
+
+ <tr>
+ <td class="Selector"><br /></td>
+ <td class="TypeDescription">
+ Documents are simple textual content.
+ </td>
+ </tr>
+
+ </tbody>
+
+ <tr>
+ <td><br/></td>
+ <td><input type="text" name="id" />
+ <input type="submit" value=" Add " />
+ </td>
+ </tr>
+
+</table>
+</form>
+</div>
+</body>
+</html>
=== Zope3/src/zope/app/browser/content/configure.zcml 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:01 2002
+++ Zope3/src/zope/app/browser/content/configure.zcml Wed Dec 25 09:12:30 2002
@@ -0,0 +1,394 @@
+<zopeConfigure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ xmlns:form="http://namespaces.zope.org/form"
+ >
+
+<!-- File View Directives -->
+
+ <browser:view
+ for="zope.app.interfaces.content.file.IFile"
+ permission="zope.View"
+ factory="zope.app.browser.content.file.FileView">
+
+ <browser:page
+ name="index.html"
+ attribute="show" />
+
+ </browser:view>
+
+ <form:edit
+ name = "edit.html"
+ schema = "zope.app.interfaces.content.file.IFile"
+ label = "Change a file"
+ permission = "zope.ManageContent"
+ />
+
+ <form:edit
+ name = "upload.html"
+ schema = "zope.app.interfaces.content.file.IFile"
+ label = "Upload a file"
+ permission = "zope.ManageContent"
+ class = ".file.FileUpload."
+ />
+
+ <browser:menuItems
+ menu="zmi_views"
+ for="zope.app.interfaces.content.file.IFile">
+
+ <browser:menuItem
+ title="Edit"
+ action="edit.html"
+ filter="python:context.contentType.startswith('text/')"
+ />
+ <browser:menuItem
+ title="Upload"
+ action="upload.html"
+ />
+ <browser:menuItem
+ title="Role Permissions"
+ action="AllRolePermissions.html"
+ />
+ <browser:menuItem
+ title="View"
+ action="show.html"
+ />
+
+ </browser:menuItems>
+
+ <browser:menuItem menu="add_content"
+ for="zope.app.interfaces.container.IAdding"
+ title="File"
+ action="File"
+ description="A file object, suitable for large data." />
+
+ <browser:icon
+ name="zmi_icon"
+ for="zope.app.interfaces.content.file.IFile"
+ file="file_icon.gif"
+ />
+
+<!-- I18n File View Directives -->
+
+ <browser:view
+ name="index.html"
+ for="zope.app.interfaces.content.i18nfile.II18nFile"
+ permission="zope.View"
+ factory="zope.app.browser.content.i18n.I18nFileView"
+ />
+
+ <browser:view
+ for="zope.app.interfaces.content.i18nfile.II18nFile"
+ permission="zope.View"
+ factory="zope.app.browser.content.i18n.I18nFileEdit">
+
+ <browser:page
+ name="editForm.html"
+ template="i18n_edit.pt"
+ />
+ <browser:page
+ name="edit.html"
+ attribute="action"
+ />
+
+ </browser:view>
+
+ <browser:menuItems menu="zmi_views"
+ for="zope.app.interfaces.content.i18nfile.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: 0"
+ />
+
+ </browser:menuItems>
+
+ <browser:menuItem menu="add_content"
+ for="zope.app.interfaces.container.IAdding"
+ title="I18n File"
+ action="zope.app.content.I18nFile"
+ description="A file that supports multiple locales."
+ />
+
+<!-- Image -->
+
+ <browser:view
+ name="index.html"
+ for="zope.app.content.image.IImage"
+ permission="zope.View"
+ allowed_attributes="__call__ tag"
+ factory="zope.app.browser.content.image.ImageData"
+ />
+
+ <form:edit
+ schema = "zope.app.content.image.IImage"
+ name = "upload.html"
+ label = "Upload an image"
+ permission = "zope.ManageContent"
+ class = ".image.ImageUpload."
+ template = "imageedit.pt"
+ />
+
+ <browser:menuItems menu="zmi_views" for="zope.app.content.image.IImage">
+
+ <browser:menuItem
+ title="Upload"
+ action="upload.html"
+ />
+ <browser:menuItem
+ title="View"
+ action="."
+ />
+ <browser:menuItem
+ title="Role Permissions"
+ action="AllRolePermissions.html"
+ />
+
+ </browser:menuItems>
+
+ <browser:icon
+ name="zmi_icon"
+ for="zope.app.content.image.IImage"
+ file="image_icon.gif"
+ />
+
+ <browser:menuItem
+ menu="add_content"
+ for="zope.app.interfaces.container.IAdding"
+ title="Image"
+ action="Image"
+ description="This object helps you manage your images."
+ />
+
+ <!-- I18n Image -->
+
+ <browser:view
+ name="index.html"
+ for="zope.app.interfaces.content.i18nimage.II18nImage"
+ permission="zope.View"
+ allowed_attributes="__call__ tag"
+ factory="zope.app.browser.content.i18nimage.I18nImageData" />
+
+ <browser:view
+ for="zope.app.content.i18nimage.II18nImage"
+ permission="zope.ManageContent"
+ factory="zope.app.browser.content.i18nimage.I18nImageEdit">
+
+ <browser:page name="upload.html" template="i18nimageedit.pt" />
+ <browser:page name="uploadAction.html" attribute="action" />
+
+ </browser:view>
+
+ <browser:menuItems
+ menu="zmi_views"
+ for="zope.app.content.i18nimage.II18nImage"
+ >
+
+ <!-- Keep the old "edit" form -->
+ <browser:menuItem title="Edit" action="upload.html"/>
+
+ <!-- Suppress upload form (from IFile) -->
+ <browser:menuItem title="Uload" action="upload.html"
+ filter="python: 0" />
+
+ </browser:menuItems>
+
+ <browser:menuItem
+ menu="add_content"
+ for="zope.app.interfaces.container.IAdding"
+ title="I18n Image"
+ action="I18nImage"
+ description="A multi-locale version of an Image."
+ />
+
+<!-- ZPT Page View Directives -->
+
+ <browser:view
+ permission="zope.View"
+ for="zope.app.content.zpt.IZPTPage"
+ factory="zope.app.browser.content.zpt.ZPTPageEval">
+
+ <browser:page name="index.html" attribute="index" />
+
+ </browser:view>
+
+ <form:edit
+ schema="zope.app.content.zpt.IZPTPage"
+ name="edit.html"
+ label="Edit a ZPT page"
+ permission="zope.ManageContent"
+ />
+
+ <browser:menuItems menu="zmi_views"
+ for="zope.app.content.zpt.IZPTPage">
+
+ <browser:menuItem title="Edit" action="edit.html"/>
+ <browser:menuItem
+ title="Role Permissions"
+ action="AllRolePermissions.html"
+ />
+ <browser:menuItem title="View" action="."/>
+ </browser:menuItems>
+
+ <browser:icon name="zmi_icon"
+ for="zope.app.content.zpt.IZPTPage" file="zpt.gif" />
+
+ <browser:menuItem
+ menu="add_content"
+ for="zope.app.interfaces.container.IAdding"
+ title="Zope Page Template Page" action="ZPTPage"
+ description="An object for dynamic content based on Page Templates."
+ />
+
+<!-- Folder View Directives -->
+
+ <browser:view
+ for="zope.app.interfaces.content.folder.IFolder"
+ permission="zope.ManageContent"
+ name="create"
+ factory="zope.app.browser.content.folder.FolderAdding">
+
+ <browser:page name="index.html" template="add.pt" />
+ <browser:page name="action.html" attribute="action" />
+
+ </browser:view>
+
+ <browser:icon
+ name="zmi_icon"
+ for="zope.app.interfaces.content.folder.IFolder"
+ file="folder_icon.gif"
+ />
+
+ <browser:menuItems menu="zmi_views"
+ for="zope.app.interfaces.content.folder.IFolder">
+ <browser:menuItem title="Contents" action="@@contents.html"/>
+ <browser:menuItem title="Role Permissions"
+ action="@@AllRolePermissions.html"/>
+ <browser:menuItem title="Principal Roles"
+ action="@@PrincipalRoles.html"/>
+ <browser:menuItem title="View" action="@@index.html"/>
+ </browser:menuItems>
+
+ <browser:menuItem menu="add_content"
+ for="zope.app.interfaces.container.IAdding"
+ title="Folder" action="Folder"
+ description="A simple Folder."
+ />
+
+ <browser:view
+ for="zope.app.interfaces.content.folder.IFolder"
+ permission="zope.ManageContent"
+ factory="zope.app.browser.container.contents.Contents">
+
+ <browser:page name="index.html" attribute="index" permission="zope.View" />
+ <browser:page name="contents.html" attribute="contents" />
+ <browser:page name="manage" attribute="contents" />
+ <browser:page name="removeObjects.html" attribute="removeObjects" />
+
+ </browser:view>
+
+ <!-- ApplicationController navigation -->
+
+
+ <browser:menuItems menu="zmi_actions"
+ for="zope.app.interfaces.content.folder.IRootFolder"
+ >
+
+ <browser:menuItem title="Process Manager"
+ action="++etc++ApplicationController/index.html"
+ />
+
+ </browser:menuItems>
+
+
+<!-- SQL Script View Directives -->
+
+ <browser:view
+ for="zope.app.interfaces.content.sql.ISQLScript"
+ permission="zope.View"
+ factory="zope.app.browser.content.sql.SQLScriptTest"
+ >
+
+ <browser:page name="index.html"
+ template="sqltest.pt"
+ />
+ <browser:page name="testResults.html"
+ template="sqltestresults.pt"
+ />
+ </browser:view>
+
+
+ <form:edit
+ schema = "zope.app.interfaces.content.sql.ISQLScript"
+ name = "edit.html"
+ label = "Edit an SQL script"
+ permission = "zope.ManageContent"
+ />
+
+ <browser:menuItems
+ menu="zmi_views"
+ for="zope.app.interfaces.content.sql.ISQLScript"
+ >
+
+ <browser:menuItem title="Edit" action="edit.html"/>
+ <browser:menuItem title="Test" action="index.html"/>
+ <browser:menuItem title="Cache" action="Caching.html"/>
+
+ </browser:menuItems>
+
+ <browser:menuItem
+ menu="add_content"
+ for="zope.app.interfaces.container.IAdding"
+ title="SQLScript"
+ action="SQLScript"
+ description="A content object getting its data from a RDB."
+ />
+
+<!-- DTML Page View Directives -->
+
+ <browser:view
+ permission="zope.View"
+ for="zope.app.content.dtmlpage.IDTMLPage"
+ factory="zope.app.browser.content.dtmlpageeval.DTMLPageEval"
+ >
+
+ <browser:page name="index.html" attribute="index" />
+
+ </browser:view>
+
+
+ <form:edit
+ schema = "zope.app.content.dtmlpage.IDTMLPage"
+ name = "edit.html"
+ label = "Edit a DTML page"
+ permission = "zope.ManageContent"
+ />
+
+ <browser:menuItems
+ menu="zmi_views"
+ for="zope.app.content.dtmlpage.IDTMLPage"
+ >
+ <browser:menuItem title="Edit" action="edit.html"/>
+ <browser:menuItem title="View" action="."/>
+ <browser:menuItem title="Role Permissions"
+ action="AllRolePermissions.html"
+ />
+ </browser:menuItems>
+
+ <browser:icon
+ name="zmi_icon"
+ for="zope.app.content.dtmlpage.IDTMLPage"
+ file="dtml.gif"
+ />
+
+ <browser:menuItem
+ menu="add_content"
+ for="zope.app.interfaces.container.IAdding"
+ title="DTML Page" action="DTMLPage"
+ description="An object for dynamic content based on Document Templates."
+ />
+
+</zopeConfigure>
=== Zope3/src/zope/app/browser/content/document.gif 1.1 => 1.2 ===
<Binary-ish file>
=== Zope3/src/zope/app/browser/content/dtml.gif 1.1 => 1.2 ===
<Binary-ish file>
=== Zope3/src/zope/app/browser/content/dtmlpageeval.py 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:01 2002
+++ Zope3/src/zope/app/browser/content/dtmlpageeval.py Wed Dec 25 09:12:30 2002
@@ -0,0 +1,28 @@
+##############################################################################
+#
+# 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 ZPT page eval results.
+
+$Id$
+"""
+
+from zope.publisher.browser import BrowserView
+from zope.proxy.context import getWrapperContainer
+
+class DTMLPageEval(BrowserView):
+
+ def index(self, REQUEST=None, **kw):
+ """Call a Page Template"""
+
+ template = self.context
+ return template.render(REQUEST, **kw)
=== Zope3/src/zope/app/browser/content/file.py 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:01 2002
+++ Zope3/src/zope/app/browser/content/file.py Wed Dec 25 09:12:30 2002
@@ -0,0 +1,53 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+from zope.publisher.browser import BrowserView
+
+
+class FileView(BrowserView):
+
+ def show(self):
+ """Call the File"""
+ request = self.request
+ if request is not None:
+ request.response.setHeader('Content-Type',
+ self.context.getContentType())
+ request.response.setHeader('Content-Length',
+ self.context.getSize())
+
+ return self.context.getData()
+
+
+"""
+$Id$
+"""
+
+__metaclass__ = type
+
+from zope.app.browser.form.widget import FileWidget
+from zope.app.form.widget import CustomWidget
+
+class FileUpload:
+ """File editing mix-in that uses a file-upload widget.
+ """
+
+ data = CustomWidget(FileWidget)
+
+
+
+__doc__ = FileUpload.__doc__ + __doc__
=== Zope3/src/zope/app/browser/content/file_icon.gif 1.1 => 1.2 ===
<Binary-ish file>
=== Zope3/src/zope/app/browser/content/folder.py 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/browser/content/folder.py Wed Dec 25 09:12:30 2002
@@ -0,0 +1,24 @@
+##############################################################################
+#
+# Copyright (c) 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+from zope.app.browser.container.adding import Adding
+from zope.app.interfaces.content.folder import IFolderAdding
+
+class FolderAdding(Adding):
+
+ __implements__ = IFolderAdding
=== Zope3/src/zope/app/browser/content/folder_icon.gif 1.1 => 1.2 ===
<Binary-ish file>
=== Zope3/src/zope/app/browser/content/i18n.py 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/browser/content/i18n.py Wed Dec 25 09:12:30 2002
@@ -0,0 +1,67 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+from zope.i18n.negotiator import negotiator
+from zope.publisher.browser import BrowserView
+
+
+class I18nFileView(BrowserView):
+
+ 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(BrowserView):
+
+ __implements__ = BrowserView.__implements__
+
+ name = 'editForm'
+ title = 'Edit Form'
+ description = ('This edit form allows you to make changes to the ' +
+ 'properties of this file.')
+
+ template = ViewPageTemplateFile('i18n_edit.pt')
+
+ 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/browser/content/i18n_edit.pt 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/browser/content/i18n_edit.pt Wed Dec 25 09:12:30 2002
@@ -0,0 +1,111 @@
+<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">
+
+ <table class="EditTable">
+ <tbody>
+
+ <tr>
+ <th class="EditAttributeName">Content Type</th>
+ <td class="EditAttributeValue">
+ <input name="contentType" type="text" size=20
+ tal:attributes="value context/getContentType" />
+ </td>
+ </tr>
+ <tr>
+ <th class="EditAttributeName">Default Language</th>
+ <td class="EditAttributeValue">
+ <select name="defaultLanguage">
+ <span tal:repeat="lang context/getAvailableLanguages"
+ tal:omit-tag="">
+ <option selected
+ tal:attributes="value lang"
+ tal:condition="python:context.getDefaultLanguage() == lang"
+ tal:content="lang" />
+ <option
+ tal:attributes="value lang"
+ tal:condition="python:context.getDefaultLanguage() != lang"
+ tal:content="lang" />
+ </span>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td colspan=2>
+ <hr>
+ </td>
+ </tr>
+ <tr>
+ <th class="EditAttributeName">Language</th>
+ <td class="EditAttributeValue">
+ <select name="language">
+ <span tal:repeat="lang context/getAvailableLanguages"
+ tal:omit-tag="">
+ <option selected
+ tal:attributes="value lang"
+ tal:condition="python:request.get('language',
+ context.getDefaultLanguage()) == lang"
+ tal:content="lang" />
+ <option
+ tal:attributes="value lang"
+ tal:condition="python:request.get('language',
+ context.getDefaultLanguage()) != lang"
+ tal:content="lang" />
+ </span>
+ </select>
+ <input type="submit" name="selectLanguage"
+ value="Show" />
+ <input type="submit" name="removeLanguage"
+ value="Remove" />
+
+ <input type="submit" name="addLanguage"
+ value="Add new language" />
+ <input type="text" name="newLanguage" size=10 />
+ </td>
+ </tr>
+ <tr>
+ <th class="EditAttributeName">Data</th>
+ <td class="EditAttributeValue">
+ <textarea name="data" cols=70 rows=10
+ tal:content="python:context.getData(request.get('language'))">
+ </textarea>
+ </td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <input type="submit" name="edit" value="Save Changes" />
+
+ </form>
+
+ </div>
+ </body>
+</html>
+
+
=== Zope3/src/zope/app/browser/content/i18nimage.py 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/browser/content/i18nimage.py Wed Dec 25 09:12:30 2002
@@ -0,0 +1,85 @@
+##############################################################################
+#
+# 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.
+
+Revision Information:
+$Id$
+"""
+
+from zope.app.browser.content.image import ImageData
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+from zope.i18n.negotiator import negotiator
+from zope.publisher.browser import BrowserView
+
+
+class I18nImageEdit(BrowserView):
+
+ __implements__ = BrowserView.__implements__
+
+ 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):
+ 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/browser/content/i18nimageedit.pt 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/browser/content/i18nimageedit.pt Wed Dec 25 09:12:30 2002
@@ -0,0 +1,126 @@
+<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">
+
+ <table class="EditTable">
+ <tbody>
+
+ <tr>
+ <th class="EditAttributeName">Content Type</th>
+ <td class="EditAttributeValue">
+ <input name="contentType" type="text" size=20
+ tal:attributes="value context/getContentType" />
+ </td>
+ </tr>
+ <tr>
+ <th class="EditAttributeName">Default Language</th>
+ <td class="EditAttributeValue">
+ <select name="defaultLanguage">
+ <span tal:repeat="lang context/getAvailableLanguages"
+ tal:omit-tag="">
+ <option selected
+ tal:attributes="value lang"
+ tal:condition="python:context.getDefaultLanguage() == lang"
+ tal:content="lang" />
+ <option
+ tal:attributes="value lang"
+ tal:condition="python:context.getDefaultLanguage() != lang"
+ tal:content="lang" />
+ </span>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td colspan=2>
+ <hr>
+ </td>
+ </tr>
+ <tr>
+ <th class="EditAttributeName">Language</th>
+ <td class="EditAttributeValue">
+ <select name="language">
+ <span tal:repeat="lang context/getAvailableLanguages"
+ tal:omit-tag="">
+ <option selected
+ tal:attributes="value lang"
+ tal:condition="python:request.get('language',
+ context.getDefaultLanguage()) == lang"
+ tal:content="lang" />
+ <option
+ tal:attributes="value lang"
+ tal:condition="python:request.get('language',
+ context.getDefaultLanguage()) != lang"
+ tal:content="lang" />
+ </span>
+ </select>
+ <input type="submit" name="selectLanguage"
+ value="Show" />
+ <input type="submit" name="removeLanguage"
+ value="Remove" />
+
+ <input type="submit" name="addLanguage"
+ value="Add new language" />
+ <input type="text" name="newLanguage" size=10 />
+ </td>
+ </tr>
+ <tr>
+ <th class="EditAttributeName">Data</th>
+ <td class="EditAttributeValue">
+ <input type="file" name="data" size=20 />
+ </td>
+ </tr>
+
+ <tr>
+ <th class="EditAttributeName">Dimensions</th>
+ <td class="EditAttributeValue"
+ tal:content="python:view.getImageSize(
+ request.get('language'))">
+ </td>
+ </tr>
+ <tr>
+ <th class="EditAttributeName">Size</th>
+ <td class="EditAttributeValue"
+ tal:content="python:context.getSize(
+ request.get('language'))">
+ </td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <input type="submit" name="edit" value="Save Changes">
+
+ </form>
+
+ </div>
+ </body>
+</html>
+
+
=== Zope3/src/zope/app/browser/content/image.py 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/browser/content/image.py Wed Dec 25 09:12:30 2002
@@ -0,0 +1,124 @@
+##############################################################################
+#
+# 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 naive file editing.
+
+$Id$
+"""
+
+from zope.app.browser.content.file import FileUpload
+from zope.app.event.objectevent import ObjectModifiedEvent
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+from zope.event import publish
+from zope.publisher.browser import BrowserView
+
+
+class ImageData(BrowserView):
+
+ def __call__(self):
+ image = self.context
+ if self.request is not None:
+ self.request.response.setHeader('content-type',
+ image.getContentType())
+ return image.getData()
+
+ def tag(self, height=None, width=None, alt=None,
+ scale=0, xscale=0, yscale=0, css_class=None, **args):
+ """
+ Generate an HTML IMG tag for this image, with customization.
+ Arguments to self.tag() can be any valid attributes of an IMG tag.
+ 'src' will always be an absolute pathname, to prevent redundant
+ downloading of images. Defaults are applied intelligently for
+ 'height', 'width', and 'alt'. If specified, the 'scale', 'xscale',
+ and 'yscale' keyword arguments will be used to automatically adjust
+ the output height and width values of the image tag.
+
+ Since 'class' is a Python reserved word, it cannot be passed in
+ directly in keyword arguments which is a problem if you are
+ trying to use 'tag()' to include a CSS class. The tag() method
+ will accept a 'css_class' argument that will be converted to
+ 'class' in the output tag to work around this.
+ """
+ if width is None:
+ width = self.context.getImageSize()[0]
+ if height is None:
+ height = self.context.getImageSize()[1]
+
+ # Auto-scaling support
+ xdelta = xscale or scale
+ ydelta = yscale or scale
+
+ if xdelta and width:
+ width = str(int(round(int(width) * xdelta)))
+ if ydelta and height:
+ height = str(int(round(int(height) * ydelta)))
+
+ result = '<img src="%s"' % (self.absolute_url())
+
+ if alt is None:
+ alt = getattr(self, 'title', '')
+ result = '%s alt="%s"' % (result, alt)
+
+ if height is not None:
+ result = '%s height="%s"' % (result, height)
+
+ if width is not None:
+ result = '%s width="%s"' % (result, width)
+
+ if not 'border' in [a.lower() for a in args.keys()]:
+ result = '%s border="0"' % result
+
+ if css_class is not None:
+ result = '%s class="%s"' % (result, css_class)
+
+ for key in args.keys():
+ value = args.get(key)
+ result = '%s %s="%s"' % (result, key, value)
+
+ return '%s />' % result
+
+
+class ImageUpload(FileUpload):
+ """Image edit view mix-in that provides access to image size info"""
+
+ def size(self):
+ sx, sy = self.context.getImageSize()
+ return "%s x %s pixels" % (sx > 0 and sx or 0, sx > 0 and sy or 0)
+
+ def apply_update(self, data):
+ """Apply user inputs
+
+ These inputs have already been validated.
+
+ Return a boolean indicating whether we changed anything,
+ """
+
+ unchanged = True
+
+ # if we can compute the content type from the raw data, then
+ # that overrides what the user provided, so set the content
+ # type first.
+
+ contentType = data.get('contentType')
+ if contentType and contentType != self.context.contentType:
+ self.context.contentType = contentType
+ unchanged = False
+
+ if 'data' in data:
+ self.context.data = data['data']
+ unchanged = False
+
+ if not unchanged:
+ publish(self.context, ObjectModifiedEvent(self.context))
+
+ return unchanged
=== Zope3/src/zope/app/browser/content/image_icon.gif 1.1 => 1.2 ===
<Binary-ish file>
=== Zope3/src/zope/app/browser/content/imageedit.pt 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/browser/content/imageedit.pt Wed Dec 25 09:12:30 2002
@@ -0,0 +1,25 @@
+<html metal:use-macro="views/standard_macros/page">
+ <body>
+ <div metal:fill-slot="body">
+
+ <div metal:use-macro="view/generated_form/macros/body">
+
+ <form action=".">
+
+ <table class="EditTable">
+ <tr metal:fill-slot="extra_top">
+ <td class="EditAttributeName">Size</td>
+ <td class="EditAttributeValue" tal:content="view/size"
+ >103 x 45 pixels</td>
+ </tr>
+ </table>
+
+ <input type="submit" name="save" value="Save Changes" />
+
+ </form>
+
+ </div>
+ </div>
+ </body>
+
+</html>
=== Zope3/src/zope/app/browser/content/sql.py 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/browser/content/sql.py Wed Dec 25 09:12:30 2002
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+$Id$
+"""
+from zope.proxy.introspection import removeAllProxies
+from zope.publisher.browser import BrowserView
+from zope.app.interfaces.content.sql import ISQLScript
+from zope.app.interfaces.rdb import DatabaseException
+
+class SQLScriptTest(BrowserView):
+ """Edit View for SQL Scripts"""
+ __implements__ = BrowserView.__implements__
+ __used_for__ = ISQLScript
+
+ error = None
+
+ def getArguments(self):
+ form = self.request.form
+ arguments = {}
+ for arg in self.context.getArguments().items():
+ value = form.get(arg[0])
+ if value is None:
+ value = arg[1].get('default')
+ if value is not None:
+ arguments[arg[0].encode('UTF-8')] = value
+ return arguments
+
+ def getTestResults(self):
+ try:
+ return self.context(**self.getArguments())
+ except DatabaseException, error:
+ self.error = error
+ return []
+
+ def getFormattedError(self):
+ error = str(self.error)
+ return error
+
+ def getRenderedSQL(self):
+ return self.context.getTemplate()(**self.getArguments())
=== Zope3/src/zope/app/browser/content/sqltest.pt 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/browser/content/sqltest.pt Wed Dec 25 09:12:30 2002
@@ -0,0 +1,40 @@
+<html metal:use-macro="views/standard_macros/page">
+<head>
+ <title>Test SQL Script</title>
+</head>
+<body>
+
+ <div metal:fill-slot="body">
+ <form action="." method="post">
+
+ <pre tal:content="context/getSource" />
+
+ <table border="1"
+ tal:define="args context/getArguments"
+ tal:condition="args">
+ <tbody>
+ <tr>
+ <th>Argument Name</th>
+ <th>Type</th>
+ <th>Value</th>
+ </tr>
+
+ <tr tal:repeat="arg python: args.keys()">
+ <td tal:content="arg"></td>
+ <td tal:content="python: args[arg].get('type')"> </td>
+ <td><input type="text" name="" size="10" value=""
+ tal:attributes="value python: args[arg].get('default');
+ name arg"/></td>
+ </tr>
+
+
+ </tbody>
+ </table>
+
+ <input type="submit" name="testResults.html:method" value="Test" />
+
+ </form>
+ </div>
+
+</body>
+</html>
=== Zope3/src/zope/app/browser/content/sqltestresults.pt 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/browser/content/sqltestresults.pt Wed Dec 25 09:12:30 2002
@@ -0,0 +1,38 @@
+<html metal:use-macro="views/standard_macros/page">
+<head>
+ <title>Test SQL Script</title>
+</head>
+<body>
+
+ <div metal:fill-slot="body">
+
+ <pre tal:content="view/getRenderedSQL" />
+
+ <table border="1" cellspacing="0" cellpadding="2"
+ tal:define="result view/getTestResults"
+ tal:condition="result">
+ <tbody>
+
+ <tr>
+ <th tal:repeat="field result/columns"
+ tal:content="field">Field Name</th>
+ </tr>
+
+ <tr tal:repeat="row result">
+ <td tal:repeat="field result/columns"
+ tal:content="python: getattr(row, field)">Value</td>
+ </tr>
+
+
+ </tbody>
+ </table>
+
+ <span tal:condition="view/error">
+ <h3>An Error occurred</h3>
+ <pre tal:content="view/getFormattedError" />
+ </span>
+
+ </div>
+
+</body>
+</html>
=== Zope3/src/zope/app/browser/content/zpt.gif 1.1 => 1.2 ===
<Binary-ish file>
=== Zope3/src/zope/app/browser/content/zpt.py 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/browser/content/zpt.py Wed Dec 25 09:12:30 2002
@@ -0,0 +1,32 @@
+##############################################################################
+#
+# 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 ZPT page eval results.
+
+$Id$
+"""
+
+from zope.publisher.browser import BrowserView
+
+class ZPTPageEval(BrowserView):
+
+ def index(self, REQUEST=None, **kw):
+ """Call a Page Template"""
+
+ template = self.context
+
+ if REQUEST is not None:
+ REQUEST.response.setHeader('content-type',
+ template.content_type)
+
+ return template.render(REQUEST, **kw)