Re: [Zope] checking for elements in a list
Christopher Rivard wrote: http://groups.yahoo.com/group/zope/message/150345 I'm working offline, so can't see what you're refering to. The solution that I have come to is to simply set a cookie and serve up the correct fields based on the cookie: dtml-if 17 in list_map_dir_id and 21 not in list_map_dir_id dtml-call RESPONSE.setCookie(list_type,'lodge') dtml-elif 21 in list_map_dir_id and 17 not in list_map_dir_id dtml-call RESPONSE.setCookie(list_type,'resto') dtml-elif 21 in list_map_dir_id and 17 in list_map_dir_id dtml-call RESPONSE.setCookie(list_type,'restolodge') dtml-else dtml-call RESPONSE.setCookie(list_type,'other') /dtml-if dtml-in insert_listing1_sql id: dtml-var newid dtml-call REQUEST.set('list_map_list_id', newid) /dtml-in dtml-call insert_listing_map_sql dtml-call RESPONSE.redirect('add_listing2?list_id=%s'%(REQUEST['list_map_list_id'])) Oh my god! What the hell are you doing? Want some plyers to pull your fingernails out while you're at it?! I am sure there are more elegant ways to do this - the client wanted the data in a RDBMS for portabilityyah yah yah ...and it looks like you don't have a clue about relational databases. Sounds like you want to have an establishments table, a features table, and then learn to do a join on both to get the features for a given establishment. sheesh, I'm on the verge of tears having read the above... cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] checking for elements in a list
J Cameron Cooper wrote: Just make sure that the elements of the list you're getting are what you think they are. If you ask about the integer 17 and the list actually has a string 17 they won't match. You can either adjust what you test or use something like the 'int' function to cast. Also make sure the list isn't too long, otherwise do it as a dictionary and use has_key... cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] checking for elements in a list
On 12/4/05, J Cameron Cooper [EMAIL PROTECTED] wrote: Christopher Rivard wrote: Hello, I'm am trying to check for the membership of items in a list and think I'm missing something. How is this done in dtml? List allids: [15,16,17,18] Check for multiple items in the list: dtml-in allids prefix=loop dtml-if expr=loop_item == 17 something dtml-elif expr=loop_item == 17 and loop_item != 18 doesn't work /dtml-if /dtml-in The goal is to check for combinations: 17 and not 18 18 only 17 only 17 and 15 18 and 16 ...combinations. I don't think that I really want to loop through the list, just want to check membership in the list. In Python, you can simply ask:: 17 in allids 18 not in allids and so forth as boolean expressions. He can do this in DTML too. dtml-if 17 in allids you're here! /dtml-if Just make sure that the elements of the list you're getting are what you think they are. If you ask about the integer 17 and the list actually has a string 17 they won't match. You can either adjust what you test or use something like the 'int' function to cast. --jcc -- Building Websites with Plone http://plonebook.packtpub.com/ ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] checking for elements in a list
Thanks Peter, The conditional within the dtml did the trick. This is a continuation of this issue (a bit cumbersome): http://groups.yahoo.com/group/zope/message/150345 The solution that I have come to is to simply set a cookie and serve up the correct fields based on the cookie: dtml-if 17 in list_map_dir_id and 21 not in list_map_dir_id dtml-call RESPONSE.setCookie(list_type,'lodge') dtml-elif 21 in list_map_dir_id and 17 not in list_map_dir_id dtml-call RESPONSE.setCookie(list_type,'resto') dtml-elif 21 in list_map_dir_id and 17 in list_map_dir_id dtml-call RESPONSE.setCookie(list_type,'restolodge') dtml-else dtml-call RESPONSE.setCookie(list_type,'other') /dtml-if dtml-in insert_listing1_sql id: dtml-var newid dtml-call REQUEST.set('list_map_list_id', newid) /dtml-in dtml-call insert_listing_map_sql dtml-call RESPONSE.redirect('add_listing2?list_id=%s'%(REQUEST['list_map_list_id'])) add_listing2 is the form that displays restaurant specific fields (price, cc's accepted) or lodge (type, price range, internet access) or both...those tricky motel/restaurants in rural NM... It seems that if I try this after the list is inserted, it comes out of MySQL as a string, not integer and therefore I could not iterate to check membership in the list. I am sure there are more elegant ways to do this - the client wanted the data in a RDBMS for portabilityyah yah yah Thanks for you help! Chris Christopher Rivard Clearwired Web Services 5345 Wyoming NE Suite 200C Albuquerque, NM 87109 office/ 505.217.3505 mobile/ 505.301.4010 toll-free/ 866.430.2832 fax/ 505.217.3506 e/ [EMAIL PROTECTED] w/ www.clearwired.com Peter Bengtsson wrote: On 12/4/05, J Cameron Cooper [EMAIL PROTECTED] wrote: Christopher Rivard wrote: Hello, I'm am trying to check for the membership of items in a list and think I'm missing something. How is this done in dtml? List allids: [15,16,17,18] Check for multiple items in the list: dtml-in allids prefix=loop dtml-if expr=loop_item == 17 something dtml-elif expr=loop_item == 17 and loop_item != 18 doesn't work /dtml-if /dtml-in The goal is to check for combinations: 17 and not 18 18 only 17 only 17 and 15 18 and 16 ...combinations. I don't think that I really want to loop through the list, just want to check membership in the list. In Python, you can simply ask:: 17 in allids 18 not in allids and so forth as boolean expressions. He can do this in DTML too. dtml-if 17 in allids you're here! /dtml-if Just make sure that the elements of the list you're getting are what you think they are. If you ask about the integer 17 and the list actually has a string 17 they won't match. You can either adjust what you test or use something like the 'int' function to cast. --jcc -- Building Websites with Plone http://plonebook.packtpub.com/ ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] checking for elements in a list
I suggest you try a little scripting language called Python. You can use in inside Zope by creating Python Scripts (formal name: Script (Python)) Try to stay away from DTML as much as possible. It's only about as good as PHP alone. On 12/4/05, Christopher Rivard [EMAIL PROTECTED] wrote: Thanks Peter, The conditional within the dtml did the trick. This is a continuation of this issue (a bit cumbersome): http://groups.yahoo.com/group/zope/message/150345 The solution that I have come to is to simply set a cookie and serve up the correct fields based on the cookie: dtml-if 17 in list_map_dir_id and 21 not in list_map_dir_id dtml-call RESPONSE.setCookie(list_type,'lodge') dtml-elif 21 in list_map_dir_id and 17 not in list_map_dir_id dtml-call RESPONSE.setCookie(list_type,'resto') dtml-elif 21 in list_map_dir_id and 17 in list_map_dir_id dtml-call RESPONSE.setCookie(list_type,'restolodge') dtml-else dtml-call RESPONSE.setCookie(list_type,'other') /dtml-if dtml-in insert_listing1_sql id: dtml-var newid dtml-call REQUEST.set('list_map_list_id', newid) /dtml-in dtml-call insert_listing_map_sql dtml-call RESPONSE.redirect('add_listing2?list_id=%s'%(REQUEST['list_map_list_id'])) add_listing2 is the form that displays restaurant specific fields (price, cc's accepted) or lodge (type, price range, internet access) or both...those tricky motel/restaurants in rural NM... It seems that if I try this after the list is inserted, it comes out of MySQL as a string, not integer and therefore I could not iterate to check membership in the list. I am sure there are more elegant ways to do this - the client wanted the data in a RDBMS for portabilityyah yah yah Thanks for you help! Chris Christopher Rivard Clearwired Web Services 5345 Wyoming NE Suite 200C Albuquerque, NM 87109 office/ 505.217.3505 mobile/ 505.301.4010 toll-free/ 866.430.2832 fax/ 505.217.3506 e/ [EMAIL PROTECTED] w/ www.clearwired.com Peter Bengtsson wrote: On 12/4/05, J Cameron Cooper [EMAIL PROTECTED] wrote: Christopher Rivard wrote: Hello, I'm am trying to check for the membership of items in a list and think I'm missing something. How is this done in dtml? List allids: [15,16,17,18] Check for multiple items in the list: dtml-in allids prefix=loop dtml-if expr=loop_item == 17 something dtml-elif expr=loop_item == 17 and loop_item != 18 doesn't work /dtml-if /dtml-in The goal is to check for combinations: 17 and not 18 18 only 17 only 17 and 15 18 and 16 ...combinations. I don't think that I really want to loop through the list, just want to check membership in the list. In Python, you can simply ask:: 17 in allids 18 not in allids and so forth as boolean expressions. He can do this in DTML too. dtml-if 17 in allids you're here! /dtml-if Just make sure that the elements of the list you're getting are what you think they are. If you ask about the integer 17 and the list actually has a string 17 they won't match. You can either adjust what you test or use something like the 'int' function to cast. --jcc -- Building Websites with Plone http://plonebook.packtpub.com/ ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] checking for elements in a list
Christopher Rivard wrote: Hello, I'm am trying to check for the membership of items in a list and think I'm missing something. How is this done in dtml? List allids: [15,16,17,18] Check for multiple items in the list: dtml-in allids prefix=loop dtml-if expr=loop_item == 17 something dtml-elif expr=loop_item == 17 and loop_item != 18 doesn't work /dtml-if /dtml-in The goal is to check for combinations: 17 and not 18 18 only 17 only 17 and 15 18 and 16 ...combinations. I don't think that I really want to loop through the list, just want to check membership in the list. In Python, you can simply ask:: 17 in allids 18 not in allids and so forth as boolean expressions. Just make sure that the elements of the list you're getting are what you think they are. If you ask about the integer 17 and the list actually has a string 17 they won't match. You can either adjust what you test or use something like the 'int' function to cast. --jcc -- Building Websites with Plone http://plonebook.packtpub.com/ ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] checking for elements in a list
Hello, I'm am trying to check for the membership of items in a list and think I'm missing something. How is this done in dtml? List allids: [15,16,17,18] Check for multiple items in the list: dtml-in allids prefix=loop dtml-if expr=loop_item == 17 something dtml-elif expr=loop_item == 17 and loop_item != 18 doesn't work /dtml-if /dtml-in The goal is to check for combinations: 17 and not 18 18 only 17 only 17 and 15 18 and 16 ...combinations. I don't think that I really want to loop through the list, just want to check membership in the list. Thanks in advance, Chris ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] checking for elements in a list
You should definitely move such *complex* logic into a PythonScript. DTML is made for generating content but not to implement such complex logic...and of course the elif part won't work because that's the semantic of if-elif. -aj --On 2. Dezember 2005 05:37:17 -0700 Christopher Rivard [EMAIL PROTECTED] wrote: Hello, I'm am trying to check for the membership of items in a list and think I'm missing something. How is this done in dtml? List allids: [15,16,17,18] Check for multiple items in the list: dtml-in allids prefix=loop dtml-if expr=loop_item == 17 something dtml-elif expr=loop_item == 17 and loop_item != 18 doesn't work /dtml-if /dtml-in The goal is to check for combinations: 17 and not 18 18 only 17 only 17 and 15 18 and 16 ...combinations. I don't think that I really want to loop through the list, just want to check membership in the list. Thanks in advance, Chris ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) pgp9sLSrLxqCK.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )