Edgewall Software

Ticket #729: patch

File patch, 1.8 KB (added by nslater@…, 7 years ago)

unified diff patch file for trac-admin

  • trac-admin

    old new  
    585585         
    586586    ## Wiki 
    587587    _help_wiki = [('wiki list', 'List wiki pages'), 
     588                  ('wiki remove <name>', 'Remove wiki page'), 
    588589                  ('wiki export <page> [file]', 
    589590                   'Export wiki page to file or stdout'), 
    590591                  ('wiki import <page> [file]', 
     
    602603        if line[-1] == ' ': # Space starts new argument 
    603604            argc += 1 
    604605        if argc==2: 
    605             comp = ['list','import','export','dump','load'] 
     606            comp = ['list','remove','import','export','dump','load'] 
    606607        else: 
    607608            if argv[1] in ['dump','load']: 
    608609                comp = self.get_dir_list(argv[-1], 1) 
     
    618619        try: 
    619620            if arg[0]  == 'list': 
    620621                self._do_wiki_list() 
     622            elif arg[0] == 'remove'  and len(arg)==2: 
     623                name = arg[1] 
     624                self._do_wiki_remove(name) 
    621625            elif arg[0] == 'import' and len(arg) == 3: 
    622626                title = arg[1] 
    623627                file = arg[2] 
     
    645649                               ' FROM wiki GROUP BY name ORDER BY name') 
    646650        ldata = [(d[0], d[1], time.ctime(d[2])) for d in data] 
    647651        self.print_listing(['Title', 'Edits', 'Modified'], ldata) 
     652 
     653    def _do_wiki_remove(self, name): 
     654        cnx = self.db_open() 
     655        cursor = cnx.cursor () 
     656        cursor.execute('SELECT name FROM wiki WHERE name=%s', name) 
     657        data = cursor.fetchone() 
     658        if not data: 
     659            raise Exception("No such wiki page '%s'" % name) 
     660        data = self.db_execsql("DELETE FROM wiki WHERE name='%s'" 
     661                               % (name)) 
    648662 
    649663    def _do_wiki_import(self, filename, title, cursor=None): 
    650664        if not os.path.isfile(filename):