[Zope] question about the attribute of results from a ZSQL method?

Terry terry@taipeitimes.com
Mon, 21 Jan 2002 18:27:05 +0800


Dear list,

Iam struggle with a question(probably very easy for you), anyone caould 
help me ?
I would like inster the items relative to my news article, and keep 
almost same distance in the same article.

Here is my Pyton Script
 #    To make the photo, pull, or box
   def make_up(item):
         if (item.ph_id > 0 ):
            return 'PHOTO<br>'   
         elif (item.pl_id > 0 ):
            return 'PULL<br>'
         elif (item.bx_id > 0 ):
               return 'BOX<br>'   
## sql_Photo .. prefix sql mean my ZSQL method
photo=script.sql_Photos(ar_id=ar_id) 
pull=script.sql_Pulls(ar_id=ar_id) 
box=script.sql_Boxes(ar_id=ar_id) 

    temp_glue = []
    if (len(photo) > 0 and len(photo) >= len(pull) and len(photo) >= 
len(box) ):
        for i in range(len(photo)):
            temp_glue.append(photo[i])
            if len(pull) >= i+1:
                temp_glue.append(pull[i])
            if len(box) >= i+1:
                temp_glue.append(box[i])
        
    elif (len(pull) > 0 and len(pull) >= len(photo) and len(pull) >= 
len(box)):
        for i in range(len(pull)):
            temp_glue.append(pull[i])
            if len(photo) >= i+1:
                temp_glue.append(photo[i])
            if len(box) >= i+1:
                temp_glue.append(box[i])

    elif (len(box) > 0 and len(box) >= len(photo) and len(box) >= 
len(pull)):
        for i in range(len(box)):
            temp_glue.append(box[i])
            if len(photo) >= i+1:
                temp_glue.append(photo[i])
            if len(pull) >= i+1:
                temp_glue.append(pull[i])       


Then I will glue the   "temp_glue" with my article.


Here is my question?

The "def make_up()" dose work.

I have attribute ph_id in photo, pl_id in pull, bx_id in box

But how to identify which one I'm processing ?

Thanks in  Advance


Terry