Newbie: manage_add DTML access to product variables
I'm fairly new to Zope and Python, so please forgive me if this is a stupid question. I'm trying to add a new exUserFolder authentication plugin using LDAP. I've copied the Radius plugin for the most part and have almost everything working except I wanted to have a list of possible methods (ways of using the LDAP database to authenticate a user) that the Zope Admin chooses from on the manage_add DTML page. I can't figure out how to keep the list in the python code for the object where it would be easy to update when I add new methods, but still access the list in my manage_add DTML page in a <dtml-in> loop. When the manage_add DTML is rendered, my object does not yet exist (the admin's response to the manage_add page is passed to a python function that actually creates the object). I have two questions, then. 1. How do I format an object to use in a <dtml-in> loop? (I'm thinking it needs to be a list of dict's). 2. How do I access a function or variable in a Product's python code directly from DTML (or how do I add a callable method in Zope's DTML namespace from a Product's python code?) I think my major problem here is lack of understanding of how Products are accesible within the DTML namespace. Thanks in advance, JMH
did you look at the LDAPUserFolder? jens On Tuesday, February 5, 2002, at 05:46 , John Hall wrote:
I'm fairly new to Zope and Python, so please forgive me if this is a stupid question. I'm trying to add a new exUserFolder authentication plugin using LDAP. I've copied the Radius plugin for the most part and have almost everything working except I wanted to have a list of possible methods (ways of using the LDAP database to authenticate a user) that the Zope Admin chooses from on the manage_add DTML page.
I can't figure out how to keep the list in the python code for the object where it would be easy to update when I add new methods, but still access the list in my manage_add DTML page in a <dtml-in> loop. When the manage_add DTML is rendered, my object does not yet exist (the admin's response to the manage_add page is passed to a python function that actually creates the object).
I have two questions, then.
1. How do I format an object to use in a <dtml-in> loop? (I'm thinking it needs to be a list of dict's).
2. How do I access a function or variable in a Product's python code directly from DTML (or how do I add a callable method in Zope's DTML namespace from a Product's python code?) I think my major problem here is lack of understanding of how Products are accesible within the DTML namespace.
Thanks in advance, JMH
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Yes, I did. It does not authenticate using the method I need. The LDAP server is not under my administrative control and I cannot add any additional fields for LDAPUserFolder's use. Since I would have to write my own auth routine anyway, I thought that exUserFolder would be a better platform to use. Thanks, JMH Jens Vagelpohl wrote:
did you look at the LDAPUserFolder?
jens
On Tue, 5 Feb 2002, John Hall wrote:
1. How do I format an object to use in a <dtml-in> loop? (I'm thinking it needs to be a list of dict's).
dtml-in will accept four differen formats: a list of objects with attributes, a list of values, a list of dicts, or a list of pairs. A list of objects is the most common case, and you get access to the attributes by name inside the loop. A list of values can only be accessed using <dtml-var sequence-item>, which gives you access to each item in the list in turn. For a list of dicts you want to specify the 'mapping' keyword on dtml-in, in which case the keys of each dict can be used in dtml-var statements. I'm not 100% sure what the list of pairs does, but I think one of the two items in the pair goes into sequence-key and the other into sequence-item.
2. How do I access a function or variable in a Product's python code directly from DTML (or how do I add a callable method in Zope's DTML namespace from a Product's python code?) I think my major problem here is lack of understanding of how Products are accesible within the DTML namespace.
If you make the right security declarations you can probably access a class variable from dtml. What might be easier, though, is to use the binding feature of DTMLFile to make the list available when the method is called, via pre-declaration in your Product: [code that defines your class, including the class variable listOfMethods] yourAddMethod = DTMLFile('dtml/addForm',globals(), listOfMethod = yourclass.listOfMethods) I'm not 100% sure this is going to solve your problem, but I've some some stuff along these lines successfully, so it might. --RDM
participants (3)
-
Jens Vagelpohl -
John Hall -
R. David Murray