[Zope] Transparent Folders can unable SQL Methods...

Ghuo fquin@profile4u.com
Fri, 17 Nov 2000 11:28:52 +0100


Hi all,


I am using both transparent folders (created by Shane)  and sql methods.
SQL Methods are using "SQLConnectionIDs" method which return the list of
all the connections founded in the content of the current folder. I put
all my connections in a transparent folder and the "SQLConnectionIDs"
method returned always an empty list. I was not able any more to create
new sql methods... Here is a patch of this method located in the python
file "lib/python/Products/ZSQLMethods/SQL.py" which makes all work
well...


Frederic Quin
Profile For You SARL, France


PATCH
------------------------------------------------------------------------------------------------------

def TF_SQLConnectionIDs(self,ids):
    have_id=ids.has_key
    StringType=type('')

    if hasattr(self, 'objectValues'):
       for o in self.objectValues():
          if (hasattr(o,'_isAnSQLConnection') and o._isAnSQLConnection
and hasattr(o,'id')):
             id=o.id
             if type(id) is not StringType: id=id()
             if not have_id(id):
                if hasattr(o,'title_and_id'): o=o.title_and_id()
                else: o=id
                ids[id]=id

          if (hasattr(o,'meta_type') and (o.meta_type == 'Transparent
Folder')):
             ids = TF_SQLConnectionIDs(o,ids)

    return ids



def SQLConnectionIDs(self):
    """Find SQL database connections in the current folder and above

    This function return a list of ids.
    """
    ids={}
    have_id=ids.has_key
    StringType=type('')

    while self is not None:
        if hasattr(self, 'objectValues'):
            for o in self.objectValues():
                if (hasattr(o,'_isAnSQLConnection') and
o._isAnSQLConnection
                    and hasattr(o,'id')):
                    id=o.id
                    if type(id) is not StringType: id=id()
                    if not have_id(id):
                        if hasattr(o,'title_and_id'): o=o.title_and_id()

                        else: o=id
                        ids[id]=id

                if (o.meta_type == 'Transparent Folder'):
                   ids = TF_SQLConnectionIDs(o,ids)

        if hasattr(self, 'aq_parent'): self=self.aq_parent
        else: self=None

    ids=map(lambda item: (item[1], item[0]), ids.items())
    ids.sort()
    return ids

/ PATCH
-----------------------------------------------------------------------------------------------------