shorturl.cgi
changeset 9 a0a13d5e406c
parent 6 d9d1f8e5f384
child 12 c2d8e9a754a1
equal deleted inserted replaced
8:4e71e1b670bc 9:a0a13d5e406c
    16 db = shelve.open('shorturls2', 'r')
    16 db = shelve.open('shorturls2', 'r')
    17 
    17 
    18 try :
    18 try :
    19     type, dirpath, fname = db[key]
    19     type, dirpath, fname = db[key]
    20 
    20 
       
    21     if type == 'img' :
       
    22         fname += '.html'
       
    23     elif type == 'dir' :
       
    24         fname = ''
       
    25 
    21     if index :
    26     if index :
    22         if index > 1 : 
    27         if index > 1 : 
    23             fname += 'index_%s.html' % (index - 1)
    28             fname = 'index_%s.html' % (index - 1)
    24 
    29 
    25         dirpath = '../%s' % dirpath
    30         dirpath = '../%s' % dirpath
    26     
       
    27     if type == 'img' :
       
    28         fname += '.html'
       
    29 
    31 
    30     path = os.path.join(dirpath, fname)
    32     path = os.path.join(dirpath, fname)
    31 finally :
    33 finally :
    32     db.close()
    34     db.close()
    33 
    35