Changeset 36 for storage

Show
Ignore:
Timestamp:
07/10/06 16:44:02 (2 years ago)
Author:
ploum
Message:

you can now open a Conseil XML file in directly in tabs (file>open)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • storage/bookmarks_store.py

    r35 r36  
    6262                        self.listing.insert_before(None, [title, bmark.toxml()]) 
    6363                return 1 
     64         
     65        def open_file(self,zefile) : 
     66                #programmation défensive needed ici !!! 
     67                # !!!!!!!! 
     68                array=[] 
     69                f = open(zefile,mode='r') 
     70                # sanitize the pretty XML 
     71                stringed = f.read().replace('\n','').replace('\t','') 
     72                try : 
     73                        doc = xml.dom.minidom.parseString(stringed) 
     74                except : 
     75                        return array 
     76                for bmark in doc.getElementsByTagName("bookmark") : 
     77                        array.append(bmark.toxml()) 
     78                return array 
    6479 
    6580         
     
    106121class bookmark :  
    107122        # constructor take the path to the bug in the store. 
    108         def __init__(self,path) : 
     123        def __init__(self,path,descr) : 
    109124                zbug = 0 
    110125                zsearch = '' 
    111126                zproduct = '' 
    112127                ztitle = '' 
    113                 zetuple = path.get_selection().get_selected() 
    114                 string = zetuple[0].get_value(zetuple[1],1) 
     128                if path != None : 
     129                        zetuple = path.get_selection().get_selected() 
     130                        string = zetuple[0].get_value(zetuple[1],1) 
     131                else : 
     132                        string = descr 
    115133                doc2 = xml.dom.minidom.parseString(string) 
    116134                bmark = doc2.getElementsByTagName("bookmark")[0]