[Zope3-checkins] CVS: Zope3/src/zope/app/browser/content - __init__.py:1.1.2.1 add.pt:1.1.2.1 configure.zcml:1.1.2.1 dtmlpageeval.py:1.1.2.1 file.py:1.1.2.1 folder.py:1.1.2.1 i18n.py:1.1.2.1 i18n_edit.pt:1.1.2.1 i18nimage.py:1.1.2.1 i18nimageedit.pt:1.1.2.1 image.py:1.1.2.1 imageedit.pt:1.1.2.1 sql.py:1.1.2.1 sqltest.pt:1.1.2.1 sqltestresults.pt:1.1.2.1 zpt.py:1.1.2.1
Jim Fulton
jim@zope.com
Mon, 23 Dec 2002 14:31:07 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/content
In directory cvs.zope.org:/tmp/cvs-serv19908/zope/app/browser/content
Added Files:
Tag: NameGeddon-branch
__init__.py add.pt configure.zcml dtmlpageeval.py file.py
folder.py i18n.py i18n_edit.pt i18nimage.py i18nimageedit.pt
image.py imageedit.pt sql.py sqltest.pt sqltestresults.pt
zpt.py
Log Message:
Initial renaming before debugging
=== Added File Zope3/src/zope/app/browser/content/__init__.py ===
#
# This file is necessary to make this directory a package.
=== Added File Zope3/src/zope/app/browser/content/add.pt ===
<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>
=== Added File Zope3/src/zope/app/browser/content/configure.zcml ===
<zopeConfigure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:form="http://namespaces.zope.org/form"
package="Zope.App.OFS.Content.File"
>
<!-- File View Directives -->
<browser:defaultView for="zope.app.interfaces.content.file.IFile" name="show.html" />
<browser:view
for="zope.app.interfaces.content.file.IFile"
permission="Zope.View"
factory="zope.app.browser.content.file.FileView">
<browser:page name="show.html" attribute="show" />
</browser:view>
<form:edit
schema = "zope.app.interfaces.content.file.IFile"
name = "edit.html"
label = "Change a file"
permission = "Zope.ManageContent"
/>
<form:edit
schema = "zope.app.interfaces.content.file.IFile"
name = "upload.html"
label = "Upload a file"
permission = "Zope.ManageContent"
class = ".Views.Browser.FileUpload."
/>
<!-- I18n File View Directives -->
<browser:view
name="view"
for="zope.app.interfaces.content.18nfile.II18nFile"
permission="Zope.View"
factory="zope.app.browser.content.i18n.I18nFileView" />
<browser:view
for="zope.app.interfaces.content.18nfile.II18nFile"
permission="Zope.View"
factory="zope.app.browser.content.i18n.I18nFileEdit">
<browser:page name="editForm.html" template="Views/Browser/i18n_edit.pt" />
<browser:page name="edit.html" attribute="action" />
</browser:view>
<!-- File Menu Directives -->
<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:menuItems menu="zmi_views" for="zope.app.interfaces.content.18nfile.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="File" action="File"
description="A file object, suitable for large data." />
<browser:menuItem menu="add_content"
for="zope.app.interfaces.container.IAdding"
title="I18n File" action="I18nFile"
description="A file that supports multiple locales." />
<browser:icon name="zmi_icon" for="zope.app.interfaces.content.file.IFile" file="File_icon.gif" />
</zopeConfigure>
<zopeConfigure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:form="http://namespaces.zope.org/form"
package="Zope.App.OFS.Content.Image">
<browser:defaultView for="zope.app.content.image.IImage" name="data" />
<!-- Image View Directives -->
<browser:view
name="data"
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 = ".Views.Browser.ImageUpload."
template = "Views/Browser/edit.pt"
/>
<!-- I18n Image View Directives -->
<browser:view
name="data"
for="Zope.App.OFS.Content.Imagezope.app.content.i18nimage.II18nImage"
permission="Zope.View"
allowed_attributes="__call__ tag"
factory="zope.app.browser.content.i18nimage.I18nImageData" />
<browser:defaultView
for="zope.app.content.i18nimage.II18nImage"
name="data" />
<browser:view
for="zope.app.content.i18nimage.II18nImage"
permission="Zope.ManageContent"
factory="zope.app.browser.content.i18nimage.I18nImageEdit">
<browser:page name="upload.html" template="Views/Browser/i18n_edit.pt" />
<browser:page name="uploadAction.html" attribute="action" />
</browser:view>
<!-- tabs for image -->
<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: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: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." />
<browser:menuItem menu="add_content"
for="zope.app.interfaces.container.IAdding"
title="I18n Image" action="I18nImage"
description="A multi-locale version of an Image." />
</zopeConfigure>
<zopeConfigure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:form="http://namespaces.zope.org/form"
package="Zope.App.OFS.Content.ZPTPage"
>
<!-- ZPT Page View Directives -->
<browser:defaultView
name="index.html"
for="zope.app.content.zpt.IZPTPage"
/>
<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"
/>
<!-- tabs for ZPT Page -->
<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." />
</zopeConfigure>
<zopeConfigure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
package="Zope.App.OFS.Content.Folder">
<!-- Folder View Directives -->
<browser:defaultView for="zope.app.content.folder.IFolder" name="index.html" />
<browser:view
permission="Zope.ManageContent"
for="zope.app.content.folder.IFolder"
name="create"
factory="zope.app.browser.content.folder.FolderAdding">
<browser:page name="index.html" template="Views/Browser/add.pt" />
<browser:page name="action.html" attribute="action" />
</browser:view>
<browser:icon name="zmi_icon" for="zope.app.content.folder.IFolder"
file="Folder_icon.gif" />
<browser:menuItems menu="zmi_views" for="zope.app.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.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.content.folder.IRootFolder"
>
<browser:menuItem title="Process Manager"
action="++etc++ApplicationController/index.html"
/>
</browser:menuItems>
</zopeConfigure>
<zopeConfigure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:form="http://namespaces.zope.org/form"
package="Zope.App.OFS.Content.SQLScript">
<!-- SQL Script View Directives -->
<browser:defaultView
for="zope.app.interfaces.content.sql.ISQLScript"
name="editForm.html" />
<browser:view
for="zope.app.interfaces.content.sql.ISQLScript"
permission="Zope.View"
factory="zope.app.browser.content.sql.SQLScriptTest">
<browser:page name="testForm.html" template="Views/Browser/test.pt" />
<browser:page name="testResults.html"
template="Views/Browser/testResults.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="testForm.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." />
</zopeConfigure>
<zopeConfigure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:form="http://namespaces.zope.org/form"
package="Zope.App.OFS.Content.DTMLPage"
>
<!-- DTML Page View Directives -->
<browser:defaultView
name="index.html"
for="zope.app.content.dtmlpage.IDTMLPage" />
<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"
/>
<!-- tabs for DTML Page -->
<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>
=== Added File Zope3/src/zope/app/browser/content/dtmlpageeval.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.
#
##############################################################################
"""Define view component for ZPT page eval results.
$Id: dtmlpageeval.py,v 1.1.2.1 2002/12/23 19:31:04 jim Exp $
"""
from zope.publisher.browser import BrowserView
from zope.proxy.context.context import getWrapperContainer
class DTMLPageEval(BrowserView):
def index(self, REQUEST=None, **kw):
"""Call a Page Template"""
template = self.context
return template.render(REQUEST, **kw)
=== Added File Zope3/src/zope/app/browser/content/file.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.
#
##############################################################################
"""
$Id: file.py,v 1.1.2.1 2002/12/23 19:31:04 jim Exp $
"""
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: file.py,v 1.1.2.1 2002/12/23 19:31:04 jim Exp $
"""
__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__
=== Added File Zope3/src/zope/app/browser/content/folder.py ===
##############################################################################
#
# 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: folder.py,v 1.1.2.1 2002/12/23 19:31:04 jim Exp $
"""
from zope.app.browser.container.adding import Adding
from zope.app.interfaces.content.folder import IFolderAdding
class FolderAdding(Adding):
__implements__ = IFolderAdding
=== Added File Zope3/src/zope/app/browser/content/i18n.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.
#
##############################################################################
"""
$Id: i18n.py,v 1.1.2.1 2002/12/23 19:31:04 jim Exp $
"""
from zope.publisher.browser import BrowserView
from zope.i18n.negotiator import negotiator
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)
"""
Revision information:
$Id: i18n.py,v 1.1.2.1 2002/12/23 19:31:04 jim Exp $
"""
from zope.publisher.browser import BrowserView
from Zope.App.PageTemplate import ViewPageTemplateFile
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
=== Added File Zope3/src/zope/app/browser/content/i18n_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="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>
=== Added File Zope3/src/zope/app/browser/content/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.
#
##############################################################################
"""
Define view component for image editing.
Revision Information:
$Id: i18nimage.py,v 1.1.2.1 2002/12/23 19:31:04 jim Exp $
"""
from zope.publisher.browser import BrowserView
from Zope.App.PageTemplate import ViewPageTemplateFile
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
""" Define view component for internationalized images.
$Id: i18nimage.py,v 1.1.2.1 2002/12/23 19:31:04 jim Exp $
"""
from zope.app.browser.content.image import ImageData
from zope.i18n.negotiator import negotiator
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)
=== Added File Zope3/src/zope/app/browser/content/i18nimageedit.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="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>
=== Added File Zope3/src/zope/app/browser/content/image.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.
#
##############################################################################
""" Define view component for naive file editing.
$Id: image.py,v 1.1.2.1 2002/12/23 19:31:04 jim Exp $
"""
from zope.publisher.browser import BrowserView
from Zope.App.PageTemplate import ViewPageTemplateFile
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
"""Define view component for image editing.
$Id: image.py,v 1.1.2.1 2002/12/23 19:31:04 jim Exp $
"""
from zope.app.browser.content.file import FileUpload
from zope.event import publish
from zope.app.event.objectevent import ObjectModifiedEvent
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
=== Added File Zope3/src/zope/app/browser/content/imageedit.pt ===
<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>
=== Added File Zope3/src/zope/app/browser/content/sql.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.
#
##############################################################################
"""
$Id: sql.py,v 1.1.2.1 2002/12/23 19:31:04 jim Exp $
"""
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())
=== Added File Zope3/src/zope/app/browser/content/sqltest.pt ===
<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>
=== Added File Zope3/src/zope/app/browser/content/sqltestresults.pt ===
<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>
=== Added File Zope3/src/zope/app/browser/content/zpt.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.
#
##############################################################################
"""Define view component for ZPT page eval results.
$Id: zpt.py,v 1.1.2.1 2002/12/23 19:31:04 jim Exp $
"""
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)