[Zope] DTML parsing outside of Zope

Jonathan dev101 at magma.ca
Thu Jul 28 07:12:03 EDT 2005


----- Original Message ----- 
From: "Peter Bengtsson" <peterbe at gmail.com>
To: <zope at zope.org>
Sent: Thursday, July 28, 2005 5:59 AM
Subject: [Zope] DTML parsing outside of Zope


>I would like to be able to parse a very basic DTML string (a
> ZSQLMethod on the file system actually) outside Zope, ie. without
> having the whole zserver running.
> The DTML inside the string is very basic. It doesn't use REQUEST or
> aqcuisition. It's using <dtml-if "1==2"> and stuff.
> I've tried looking on the source code but it's so damn complicated for
> me. Can anybody give me a headstart on this?


If you are trying to access the zodb without having zope running, here are a 
couple of ways to make it happen:

# method #1
import os, sys, traceback
sys.path.append("/apps/zope/lib/python")
import Zope
app=Zope.app()
from Testing import makerequest
app = makerequest.makerequest(app)


# method #2
import os, sys
sys.path.append("/apps/zope/lib/python")
import Zope
import time
app=Zope.app()


Once you have 'app' you can do things like:

REQUEST = app.REQUEST
newobj = 
app.Wet.Content.Data.manage_addProduct['myProd'].manage_addmyItem(...)
app.unrestrictedTraverse('Control_Panel/Database/ShopwiserData').manage_pack()

hth

Jonathan 




More information about the Zope mailing list