[Zope] NT, 4suite and Zope

Thomas B. Passin tpassin@mitretek.org
Mon, 22 Jul 2002 13:57:12 -0400


[Pascal Samuzeau]

I've a NT server. In intend to serve XML files, with my Zope's site,
I've installed 4suite.

Or, with NT, I have no choice to install 4suite than under C:\4suite.

But in any case under the Zope's lib/Product.

The matter is that I want to use of XSLTranslatedDocument, and this
one is waiting for the Ft.XML.Xslt, under lib/Products.

How is the right way to use of 4suite with Zope under NT ?

[Tom P]

I run xslt stylesheets under Zope using 4xslt.  You would run 4suite code
using an External Method.  After installation, you can either copy the pyxml
and 4suite directories to corresponding locations in the Zope directory
tree, or you can add a .pth file in the Zope Python directory to add those
dorectories to the python path.

You should make sure that the versions of 4suite and  pyxml that you use
will work with the version of Python in your Zope installation.  If you are
just setting up, that would probably be Python 2.1.3.

With this approach, all the xslt stylesheets would probably best be in the
file system rather than the Zope object database, although you could feed
them to the 4xslt code as strings from Zope.  If you keep the stylesheets in
the file system, you want to make sure that your code can find them.  There
are several ways to do this:

1) Use absolute paths.  This will be a problem if you ever move the system
to a different directory location.

2) Relative paths.  In this case you have to decide "relative to what"?.  I
recommend that you locate all these files relative to the python code that
uses them.  Python modules can find out their own location, so you can be
sure of finding the files relative to that.  I like to set a variable for
the base directory in the __init__.py file of a package.  This is an easy
way to make it available to any code that uses the package, including the
External Methods you will write.

Here is an example of what I do in DTML to invoke a stylesheet
transformation:

<dtml-let xml=
    "runXML(_['REQUEST']['xml']">
    <dtml-let xsl=
        "getBasepath()+'\\stylesheets\\routeInfoDisplay_4.xsl'">
            <dtml-var "transform_xml_string (xml,xsl)">
    </dtml-let>
</dtml-let>

Here, "xml" ends up containing an xml string.  "xsl" is the full path to the
stylesheet.  getBasepath() gets the base path I mentioned earlier.  In this
example, I am processing some xml posted from a web page in a hidden field.

getBasepath(), runXML() and transform_xml_string() are External Methods.

You should make sure that your external methods do nothing more than
dispatch to the real code, which should be located outside the Zope
directory structure.  Do not write any code that does real processing in the
External Method file itself, always call the code that will do the work.

Cheers,

Tom P