You are not logged in Log in Join
You are here: Home » Members » aaltepet's Home » A branch of XMLWidgets which can have multiple widget roots » README » View Document

Log in
Name

Password

 

README

Copyright (c) 2002 Infrae. All rights reserved. See also LICENSE.txt

Meta:

  Valid for:  XMLWidgets-pluggable 0.12
  Author:     Andy Altepeter
  Email:      aaltepet at bethel dot edu
  Original Author: Martijn Faassen 
  Email:      faassen at infrae dot com

Using XMLWidgets-pluggable

All of the configuration/install/setup of XMLWidgets-pluggable for use with Silva is done in the install.py file of your product. This description assumes you are using XMLWidgets with Silva 1.2. This is not meant as a complete manual on how to use XMLWidgets with Silva. It will also be helpful for you to inspect the install.py file of the Silva release.

XMLWidgetRegistry uses a filesystemsite directory inside your product as the root container for your widgets. You register this directory in in install.py of your product for, like this:

add_fss_directory_view(root, service_extended_widgets, __file__, widgets)

Where service_extended_widgets is the name of the zope folder, and widgets is the name of the directory in your product.

You also want to tell the XMLWidgets Editor Service that there is another root (in def install(root)):

root.service_editor.addWidgetRoot(service_extended_widgets, depends_on=(SilvaDocument,Silva) )

Lets say you have a hr widget that renders a html hr. You create a directory here: /widgets/element/ect/hr

The directory ect is created to prevent naming conflicts with any other widgets named hr. Silva has multiple views of a widget (edit, preview, view), and you need to create a widget registry for each view. Since each view can render the widget different, you want to have the following structure in your widget directory:

hr/mode_view /mode_preview /mode_edit /mode_normal

You usually have a render script (page template, python script) in each of the above directories except mode_normal. You also have a render script in hr/, which is acquired when rendering mode_normal (which is really edit mode).

We want to configure SilvaDocument to use this new hr widget, so we add the following to the install.py file. In the install function, call the following:

def registerHR(root): wr_viewer = root.service_doc_viewer wr_editor = root.service_doc_editor wr_previewer = root.service_doc_previewer

hr_loc = [service_extended_widgets,element,ect,'hr']

doc_editor.addWidget(hr,tuple(hr_loc+['mode_normal'])) doc_previewer.addWidget(hr,tuple(hr_loc+['mode_preview'])) doc_viewer.addWidget(hr,tuple(hr_loc+['mode_view']))

cur_widgets = doc_editor.getAllowed(doc) doc_editor.setAllowed(doc,(cur_widgets + ['hr']) doc_editor.setDisplayname(hr,Horizontal Rule)

Some simple widgets use mode_view for mode_preview. HR is a simple widget So you may want to change the line that registers hr to the previewer to:

doc_previewer.addWidget(hr,tuple(hr_loc+['mode_view']))

There are a few other widget registries you may wish to register hr to: service_sub_* - this is the widget registry for field and complex list (li)

In the Services tab of the Silva Root (in the ZMI), if you visit any of the widget registries Info tabs, you will see a list of the widgets registered, their display names, and the allowed mapping.

XMLWidgets

XMLWidgets can be used to create through the web viewers and editors of XML content, stored in ParsedXML.

Note: I don't expect people to understand XMLWidgets without far more information. For now, perhaps an example would help. Silva's editor is such an example, so you could install Silva and play with it (see especially the service_widgets directory, and note the scripts in service_setup to register any new widgets).

The XMLWidgets Editor Service is added just once to a Zope system and should be called service_editor. It is a singleton which provides a number of facilities for viewers and editors.

The XMLWidgets Registry is used to register widgets (usually simple Zope folders with content such as page templates and python scripts). Currently they don't become equipped with any user interface, so you must use Python Scripts to configure them. The XMLWidgets Editor Service then can use this information to render documents (possibly in editor mode).