OK, I've figured this much out so far. I've created one DTML document for each registration. I'm using acquisition to pass that document to a DTML method that displays the document. The URL looks like: ".../Yourfullname3b01efcd/DisplayFullRegInfo" where Yourfullname3b01efcd is the document name, and DisplayFullRegInfo is the DTML method. Now I want to get the information in the document (which is a python dictionary in text form) and use eval() (which I've put in an external method) to parse it back into a python dictionary. To get the data in the document, it turns out all I have to do is say "PARENTS[0]". Now the fun starts. This is in DisplayFullRegInfo: <dtml-let data="PARENTS[0]"> <dtml-var data><hr> <dtml-var expr="parseSeminarRegistration(data)"> </dtml-let> I keep getting weird error messages for parseSeminarRegistration(), which worked in a different DTML method just fine. The messages complain about the argument, so I decide to examine the argument type. Here's the external method, parseSeminarRegistration(): import types def parseSeminarRegistration(code): return 'your type is: ' + str(type(code)) #return eval(code) Normally I just use eval(), but this should indicate the type. Here's the output: ------------------------------------------------------------ -------------------- {'homephone': 'Your home phone (for emergencies)', 'email': 'Your email address', 'admin_email': 'Their email address', 'price_dates': '(("2001-5-15", 1700), ("2001-7-4", 1800))', 'semnumber': '1', 'busphone': 'Your business phone number', 'admin_contact': "Person we should contact about payment, if it's not you", 'admin_phone': 'Their phone number', 'bill_to': 'Person or company paying for the seminar', 'payment_date': '', 'admin_fax': 'Their fax number', 'country': 'USA or your country', 'state': 'State or province', 'required_forms': '(("Limited Liability Form", "N", "http://www.mindview.net/Seminars/regFormParts/LimitedLiabil ity"), ("Activity Release Form", "N", "http://www.mindview.net/Seminars/regFormParts/ActivityRelea seForm.html"))', 'name': 'Your full name', 'zip': 'Zip or postal code', 'city': 'City', 'invoice_number': '', 'current_price': '', 'seminar_id': 'Design-A-Day Patterns Practicum July 30-August 3 ', 'paid': 'N', 'purchase_order_id': '', 'registration_date': '2001/05/15 20:11:07.26156 GMT-7', 'completed': 'N', 'address1': 'Street address', 'address2': 'Second address line, if needed', 'fax': 'Your fax number, if you have one'} ------------------------------------------------------------ -------------------- your type is: The external method is clearly called, but it simply gives a blank. No 'None', even, as if *no* argument is being passed (which I didn't think was possible). I'm clearly missing something here. (If there's a more appropriate way to get the data file then tell me to do that). Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
Bruce Eckel wrote:
needed', 'fax': 'Your fax number, if you have one'} ------------------------------------------------------------ -------------------- your type is:
Is this from html source or from rendered page? Example:
type(1) <type 'int'>
whixh is rendered as:
type(1)
------------ Hannu
Bruce Eckel wrote:
<dtml-let data="PARENTS[0]"> <dtml-var data><hr> <dtml-var expr="parseSeminarRegistration(data)"> </dtml-let>
I keep getting weird error messages for parseSeminarRegistration(), which worked in a different DTML method just fine. The messages complain about the argument, so I decide to examine the argument type. Here's the external method, parseSeminarRegistration():
try <dtml-var expr="parseSeminarRegistration(data)" html_quote> ------------- Hannu
OK, I've figured this much out so far. I've created one DTML document for each registration. I'm using acquisition to pass that document to a DTML method that displays the document. The URL looks like: ".../Yourfullname3b01efcd/DisplayFullRegInfo" where Yourfullname3b01efcd is the document name, and DisplayFullRegInfo is the DTML method.
Now I want to get the information in the document (which is a python dictionary in text form) and use eval() (which I've put in an external method) to parse it back into a python dictionary. To get the data in the document, it turns out all I have to do is say "PARENTS[0]". Now the fun starts. This is in DisplayFullRegInfo:
<dtml-let data="PARENTS[0]"> <dtml-var data><hr> <dtml-var expr="parseSeminarRegistration(data)"> </dtml-let>
I keep getting weird error messages for parseSeminarRegistration(), which worked in a different DTML method just fine. The messages complain about the argument, so I decide to examine the argument type. Here's the external method, parseSeminarRegistration():
import types def parseSeminarRegistration(code): return 'your type is: ' + str(type(code)) #return eval(code)
Normally I just use eval(), but this should indicate the type. Here's the output:
-----------------------------------------------------------
-------------------- {'homephone': 'Your home phone (for emergencies)', 'email': 'Your email address', 'admin_email': 'Their email address', 'price_dates': '(("2001-5-15", 1700), ("2001-7-4", 1800))', 'semnumber': '1', 'busphone': 'Your business phone number', 'admin_contact': "Person we should contact about payment, if it's not you", 'admin_phone': 'Their phone number', 'bill_to': 'Person or company paying for the seminar', 'payment_date': '', 'admin_fax': 'Their fax number', 'country': 'USA or your country', 'state': 'State or province', 'required_forms': '(("Limited Liability Form", "N", "http://www.mindview.net/Seminars/regFormParts/LimitedLiabi l ity"), ("Activity Release Form", "N", "http://www.mindview.net/Seminars/regFormParts/ActivityRele a seForm.html"))', 'name': 'Your full name', 'zip': 'Zip or postal code', 'city': 'City', 'invoice_number': '', 'current_price': '', 'seminar_id': 'Design-A-Day Patterns Practicum July 30-August 3 ', 'paid': 'N', 'purchase_order_id': '', 'registration_date': '2001/05/15 20:11:07.26156 GMT-7', 'completed': 'N', 'address1': 'Street address', 'address2': 'Second address line, if needed', 'fax': 'Your fax number, if you have one'} -----------------------------------------------------------
Progress: I figured out that the string exists, but it's being html-quoted, which suggests to me that the information from the file is somehow being passed rather than being opened by my 'DisplayFullRegInfo' DTML method. So I suspect I'm taking the wrong approach, and asking the wrong question. I think the question should be: Inside a DTML method that's called with an argument via acquisition (I may be misusing the term here), if the argument represents a DTML document name: http://www.foobar.org/place/TheArgument/TheDTMLMethod How do I (1) get TheArgument from inside TheDTMLMethod (methinks PARENTS[0], but that seemed to be problematic) (2) Open the DTML document, once I have the argument Thanks... *********** REPLY SEPARATOR *********** On 5/17/01 at 7:57 AM Bruce Eckel wrote: - -
-------------------- your type is:
The external method is clearly called, but it simply gives a blank. No 'None', even, as if *no* argument is being passed (which I didn't think was possible).
I'm clearly missing something here. (If there's a more appropriate way to get the data file then tell me to do that).
Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
_______________________________________________ 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 )
Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
hello,
(1) get TheArgument from inside TheDTMLMethod (methinks PARENTS[0], but that seemed to be problematic) (2) Open the DTML document, once I have the argument
<dtml-var "learn.learn_at_home()"> would give you the processed contents of a dtml method (learn_at_home) found in the learn folder. <dtml-var "learn.learn_at_home"> would give you the raw contents of a dtml method (learn_at_home) found in the learn folder. <dtml-with archives> <dtml-with 2001> <dtml-in "objectValues(['DTML Document'])" size=3 sort=title reverse> <dtml-call "REQUEST.set('renderedfooter',1)"> <dtml-var sequence-item> <a href="<dtml-var absolute_url>" title="Permanent link to the entry for <dtml-var title>">PermaLink</a> <br /> </dtml-in> </dtml-with> </dtml-with> <dtml-call "REQUEST.set('renderedfooter',0)"> that snippet digs into the folders archives -> 2001, tells Zope not to process the headers and footers (more to it than that), inserts the contents of the dtml document with the line <dtml-var sequence-item> the contents being whatever is in the dtml document except the header and footer code. hope that helps, luke
Bruce Eckel wrote:
Inside a DTML method that's called with an argument via acquisition (I may be misusing the term here), if the argument represents a DTML document name:
http://www.foobar.org/place/TheArgument/TheDTMLMethod
How do I
(1) get TheArgument from inside TheDTMLMethod (methinks PARENTS[0], but that seemed to be problematic) (2) Open the DTML document, once I have the argument
I think you are using aquisition in a very unusual manner. Don't think of the URL path elements as arguments, but as context for a method call. Zope is essentially an ORB that maps URLs to invocations of methods. Normally, everything in a Zope URL are objects, except the last element which maybe a method name or an object whose default method (usually index_html) will be invoked. In your case, TheArgument should not be a string that you will use to fetch a document, but rather a reference to the document itself, upon which your method will operate. In other words, this: http://www.foobar.org/place/TheArgument/TheDTMLMethod is like this: place.TheArgument.TheDTMLMethod() So maybe you can say TheArgument is like the "self" argument, after all... By putting TheArgument in the acquisition path, you acquire TheArgument's attributes, that is, its attributes are added to your namespace stack, where your method can access them directly. Also, be careful not to confuse context with containment. The container of a method is the folder where it is statically located. The context of a method very often is the same as the container, but as you already know it may not be. The context is given by the acquisition path spelled out in the URL of the request. In a recent tutorial, I used an altered version of an image from Grady Booch's OOAD book to explain acquisition. You can see it here: http://www.hiperlogica.com.br/en/laboratorio/palestras/acquisition/img4.htm Best regards, Luciano
Great post Luciano! ..and very interesting diagrams. Interested in contributing to a new Zope zine/CDROM project? "A to ZOPE: A Zope Object Patterns Encyclopedia" The first thing I am looking for are people's true 'back-of-napkin' or whiteboard schematics. The ones they draw when they are really explaining, discussing or brainstorming Zope. Literally. These are typically dynamic sketches which grow over th course of an intense meeting, accompanied by suitable pointing, swapping of pens and talking. I want to render a set of these dynimically using Flash5 linked to a .zexp file, as a strong way to 'Visaully Think' Zope. I hope one result will be a useful resource for the Zope community, for clients, for devopers, for training. I am am happy to do the Flash programming , but what is missing right now are a collection of zopsitas raw drawings. I have my own 5x8 I use for all my work and keep as refernce. If your are interested please contact me and/or send me scans of any napkins! [originals welcome epsecially with authenticated coffee stains :-)] thanks ./Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'] ----- Original Message ----- From: "Luciano Ramalho" <luciano@hiper.com.br> To: <Bruce@EckelObjects.com> Cc: <zope@zope.org>; <chrism@digicool.com> Sent: Thursday, May 17, 2001 7:08 PM Subject: Re: [Zope] A corker
Bruce Eckel wrote:
Inside a DTML method that's called with an argument via acquisition (I may be misusing the term here), if the argument represents a DTML document name:
http://www.foobar.org/place/TheArgument/TheDTMLMethod
How do I
(1) get TheArgument from inside TheDTMLMethod (methinks PARENTS[0], but that seemed to be problematic) (2) Open the DTML document, once I have the argument
I think you are using aquisition in a very unusual manner. Don't think of the URL path elements as arguments, but as context for a method call. Zope is essentially an ORB that maps URLs to invocations of methods. Normally, everything in a Zope URL are objects, except the last element which maybe a method name or an object whose default method (usually index_html) will be invoked.
In your case, TheArgument should not be a string that you will use to fetch a document, but rather a reference to the document itself, upon which your method will operate. In other words, this:
http://www.foobar.org/place/TheArgument/TheDTMLMethod
is like this:
place.TheArgument.TheDTMLMethod()
So maybe you can say TheArgument is like the "self" argument, after all...
By putting TheArgument in the acquisition path, you acquire TheArgument's attributes, that is, its attributes are added to your namespace stack, where your method can access them directly.
Also, be careful not to confuse context with containment. The container of a method is the folder where it is statically located. The context of a method very often is the same as the container, but as you already know it may not be. The context is given by the acquisition path spelled out in the URL of the request.
In a recent tutorial, I used an altered version of an image from Grady Booch's OOAD book to explain acquisition. You can see it here:
http://www.hiperlogica.com.br/en/laboratorio/palestras/acquisition/img4.htm
Best regards,
Luciano
participants (5)
-
Bruce Eckel -
Hannu Krosing -
Jason Cunliffe -
Luciano Ramalho -
Luke Tymowski