Stephan Richter wrote:
On Saturday 29 October 2005 11:35, Paolo Cilmo wrote:

I need to develop a site
using ZMI (Zope2 typical using) and especially i want
to develop this applications:

We do not support TTW development.

1- I've a package with a class and into the class a
2- with browser:addMenuItem in zcml i can insert a
package into zmi from "add menu"
3- I've a Page Template into ZMI
ASK: how i call from the Page Template the script,
passig parameters and to have a response from script?

Why do you need to have this Page Template in ZMI? Why not on the file system?

I'm working on an application where Page Templates belong in the ZMI, at least I think so. The content being displayed is a business directory, with suppliers, products, and categories for those products. We will be implementing 50 different directories, with the same basic content structure but very different designs. Each of those directories will use 5 or 6 page templates, which go in the ZMI.

It seems like this is a common pattern for content management applications.

Repeating my own posting from 10/9, here's how I made an adapter
to use a file system view with a ZMI template:

class ZPTViewAdapter(ZPTPage):
    """Adapt a ZPTPage instance to set up its namespace
    so it can be called by a View Class.

    def __init__(self, ob):
        self.ob = ob

    def pt_getContext(self, instance, request, **kw):
        """instance is a View component"""
namespace = super(ZPTViewAdapter, self).pt_getContext(instance, request, **kw)
        namespace['nothing'] = None
        namespace['template'] = self.ob
        namespace['container'] = self.ob.__parent__
        namespace['request'] = request
        namespace['view'] = instance
        namespace['context'] = context = instance.context
        namespace['views'] = ViewMapper(context, request)
        namespace['options'] = kw
        print 'ZPTPage namespace', namespace.keys()
        return namespace

    def __call__(self, instance, *args, **keywords):
        namespace = self.pt_getContext(
            instance=instance, args=args, options=keywords)
        debug_flags = instance.request.debug
        s = self.ob.pt_render(
            showtal=getattr(debug_flags, 'showTAL', 0),
            sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
        response = instance.request.response
        if not response.getHeader("Content-Type"):
            response.setHeader("Content-Type", self.ob.content_type)
        return s

# View class that uses the adapter

class MessageView(object):
    """A webpage saying hello
    def message(self):
        return '%s %s!' % (self.context.greeting, self.context.subject)

class KustomView(MessageView):
    """Pick up a template from parent container if available;
    if not, use the filebased one.
    def __call__(self):
        template = self.context.__parent__.get('')
        if template is not None:
template = getAdapter(template, IPageTemplateSubclassing, "zptViewAdapter")
            template = ViewPageTemplateFile('')

        return template(self)


-- Wade Leftwich
Ithaca, NY

Zope3-users mailing list

Reply via email to