[Zope3-checkins] CVS: zopeproducts/photo/browser - __init__.py:1.1 configure.zcml:1.1 photo.py:1.1 preview.pt:1.1

Bjorn Tillenius bjorn at codeworks.lt
Fri Aug 15 09:10:54 EDT 2003


Update of /cvs-repository/zopeproducts/photo/browser
In directory cvs.zope.org:/tmp/cvs-serv25590/browser

Added Files:
	__init__.py configure.zcml photo.py preview.pt 
Log Message:
First checkin of the photo product.

This is intended to be similar to the photo product in Zope 2. It's not
quite finished yet, though it's already usable. Read the README for more
information.


=== Added File zopeproducts/photo/browser/__init__.py ===


=== Added File zopeproducts/photo/browser/configure.zcml ===
<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:browser="http://namespaces.zope.org/browser"
    i18n_domain="photo"
    >

<browser:addform
    label="Add Photo"
    name="AddPhoto"
    schema="zopeproducts.photo.interfaces.IPhoto"
    content_factory="zopeproducts.photo.Photo"
    permission="zope.ManageContent"
    class=".photo.PhotoEdit"
    menu="add_content"
    title="Photo"
    />

<browser:editform
    label="Edit Photo"
    name="edit.html"
    schema="zopeproducts.photo.interfaces.IPhoto"
    fields="title description useParentOptions currentDisplayId resizeUtility"
    for="zopeproducts.photo.interfaces.IPhoto"
    permission="zope.ManageContent"
    class=".photo.PhotoAdd"
    menu="zmi_views"
    title="Edit"
    />

<browser:editform
    label="Upload New Photo"
    name="upload.html"
    schema="zopeproducts.photo.interfaces.IPhoto"
    for="zopeproducts.photo.interfaces.IPhoto"
    permission="zope.ManageContent"
    class=".photo.PhotoUpload"
    menu="zmi_views"
    title="Upload"
    /> 

<browser:page
    name="index.html"
    for="zopeproducts.photo.interfaces.IPhoto"
    permission="zope.View"
    allowed_attributes="__call__ tag"
    class="zopeproducts.photo.browser.photo.PhotoData"
    /> 

<browser:page
    for="zopeproducts.photo.interfaces.IPhoto"
    name="preview.html"
    template="preview.pt"
    menu="zmi_views"
    title="Preview"
    permission="zope.ManageContent"
    /> 

</configure>


=== Added File zopeproducts/photo/browser/photo.py ===
##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################
"""Browser View for the Photo class

$Id: photo.py,v 1.1 2003/08/15 12:10:48 BjornT Exp $
"""

from zope.app.browser.content.image import ImageData

class PhotoData(ImageData):

    def __call__(self):
        if 'display' in self.request:
            dispId = self.request['display']
        else:
            dispId = None
        image = self.context.getImage(dispId)
        if image is not None: 
            if self.request is not None:
                self.request.response.setHeader('content-type',
                                                image.getContentType())
                return image.getData()
        else:
            return ''

    def tag(self, height=None, width=None, alt=None,
            scale=0, xscale=0, yscale=0, css_class=None, **args):
        if width is None:
            width = self.context.getImage().getImageSize()[0]
        if height is None:
            height = self.context.getImage().getImageSize()[1]
        return super(PhotoData, self).tag(height, width, alt, scale,
                                          xscale, yscale, css_class, **args)


from zope.app.browser.form.widget import FileWidget, ListWidget
from zope.app.form.widget import CustomWidget
from zope.publisher.browser import BrowserView

from zopeproducts.photo import Photo

class CurrentDisplayIdFix:
    """Changes the currentIdDisplay widget to be a ListWidget.

    This way we don't get the values sorted and can specify a
    text which represents each value.
    """
    currentDisplayId_widget = CustomWidget(ListWidget, size=1)

class PhotoAdd(CurrentDisplayIdFix):
    """Class to change some of the widgets om the add page for
    the Photo class.
    """
    data_widget = CustomWidget(FileWidget)

class PhotoEdit(CurrentDisplayIdFix):
    """Class to change som of the widgets on the edit page for
    the Photo class.
    """

    data_widget = CustomWidget(FileWidget)

class PhotoUpload(PhotoEdit):
    """The same as PhotoEdit but we can now upload a file as well"""
    data_widget = CustomWidget(FileWidget)




=== Added File zopeproducts/photo/browser/preview.pt ===
<html metal:use-macro="views/standard_macros/page">
<body>
<div metal:fill-slot="body">
<iframe src="." height="98%" width="98%"></iframe>
</div>
</body>
</html>




More information about the Zope3-Checkins mailing list