Programmatically creating a DTML Document?
Hi, I'm testing out using Zope as an HTTP-accessible database. (To be used by Java servlets!) Being lazy, I want to save my info as DTML Documents. I can't figure out how to programmatically make a new document in a sub folder, or set its contents. (I have seen pointers and examples for setting attributes of existing objects.) Can anyone help? Thanks, Robb
Robb, You'd do something like this from within DTML: <dtml-call expr="manage_addDTMLDocument('mydocumentid', 'mydocumentitle', mycontent)"> Where mycontent is a string object containing your document's content. This will add a DTML document to the folder which contains the method that contains this DTML snippet with an id of 'mydocumentid', a title of 'mydocumentitle'. You're probably going to want to use XML-RPC to do this from your servlet, however. The name looks scary, but it's real easy. XML-RPC is a protocol that Zope speaks that works over HTTP. It lets you call methods of Zope objects programmatically from outside the Zope application. There are a couple of Java packages that let you make use of XML-RPC, you can see them at http://www.xmlrpc.com/. Also, you might want to check out Amos Latteier's XML-RPC article at http://www.xml.com/pub/2000/01/xmlrpc/index.html You may also want to print out a copy of the Zope Quick Reference, available at http://www.zope.org/Members/ZQR. This is a work that is attempting to document all the available methods on objects within Zope. Good luck! Robb Shecter wrote:
Hi,
I'm testing out using Zope as an HTTP-accessible database. (To be used by Java servlets!) Being lazy, I want to save my info as DTML Documents. I can't figure out how to programmatically make a new document in a sub folder, or set its contents. (I have seen pointers and examples for setting attributes of existing objects.) Can anyone help?
Thanks, Robb
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Chris McDonough Digital Creations, Inc. Zope - http://www.zope.org
Chris McDonough wrote:
Robb,
You'd do something like this from within DTML:
<dtml-call expr="manage_addDTMLDocument('mydocumentid', 'mydocumentitle', mycontent)">
Thank you! I actually did end up finding the add method in the ZQR. I wasn't able to figure out on my own, though, what parameters the method takes. How would I have been able to find this? Is there some some source code file I can look in? Thanks, Robb
Ha, there's a *lot* of them you can look in. But don't make it hard on yourself. GO to http://www.codecatalog.com and type in the name of the function you're looking for... it'll come up with a list of .py files... generally the first one is the one that has the function definition in it.. although inheritance can make this less than 100% accurate, it's worth a shot. You can do the same thing locally by doing something like grep -R -i "def manage_addDTMLDocument" *|more from within the Zope directory. Sometimes this pays off, sometimes it doesn't. Yeah, we know, we know. :-) Robb Shecter wrote:
Chris McDonough wrote:
Robb,
You'd do something like this from within DTML:
<dtml-call expr="manage_addDTMLDocument('mydocumentid', 'mydocumentitle', mycontent)">
Thank you! I actually did end up finding the add method in the ZQR. I wasn't able to figure out on my own, though, what parameters the method takes. How would I have been able to find this? Is there some some source code file I can look in?
Thanks, Robb
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Chris McDonough Digital Creations, Inc. Zope - http://www.zope.org
participants (2)
-
Chris McDonough -
Robb Shecter