def upgradewiki(self, byuser=u'admin'): """Upgrade the database fields supporting wiki markup to the latest zwiki version""" from zeta.config.environment import tlcomp, srchcomp msession = meta.Session() wikis = self.get_wiki() wcmts = self.get_wikicomment() cnt_wcmt = len(wcmts) cnt_wcnt = 0 while wikis: with msession.begin(subtransactions=True): w = wikis.pop(0) wcnts = self.get_content(w, all=True) cnt_wcnt += len(wcnts) for wcnt in wcnts: wcnt.texthtml = wcnt.translate(wiki=w, cache=True) # To HTML while wcmts: with msession.begin(subtransactions=True): wcmt = wcmts.pop(0) wcmt.texthtml = wcmt.translate() # To HTML # Database Post processing tlcomp.log(byuser, "Upgraded wiki contents and comments to latest wiki") return (cnt_wcnt, cnt_wcmt)
def remove_tag(self, tag, byuser=None): """Remove existing tag entry.""" from zeta.config.environment import tlcomp tag = self.get_tag(tag) tagname = tag and tag.tagname or '' msession = meta.Session() with msession.begin(subtransactions=True): tag and msession.delete(tag) # Database Post processing tlcomp.log(byuser, 'deleted tag, `%s`' % tagname)
def upgradewiki(self, byuser=None): """Upgrade the database fields supporting wiki markup to the latest zwiki version""" from zeta.config.environment import tlcomp, srchcomp msession = meta.Session() staticwikis = self.get_staticwiki() with msession.begin(subtransactions=True): for sw in staticwikis: sw.texthtml = sw.translate(wiki=sw) # To HTML # Database Post processing tlcomp.log(byuser, "Upgraded static wiki pages") return len(staticwikis)
def create_wikitype(self, wiki_typenames, byuser=None): """Create wiki_typename entries for the wiki_typenames specified by, `wiki_typenames` which can be, a string specifying the wiki_typename name or a list of such strings""" from zeta.config.environment import tlcomp, srchcomp if isinstance(wiki_typenames, (str, unicode)): wiki_typenames = [wiki_typenames] logs = [] msession = meta.Session() with msession.begin(subtransactions=True): [msession.add(WikiType(unicode(wt))) for wt in wiki_typenames] # Database Post processing tlcomp.log(byuser, 'added wiki type names, `%s`' % ', '.join(wiki_typenames))
def create_vcstype(self, vcs_typenames, byuser=None): """Create vcs_typename entries for the vcs_typenames specified by, `vcs_typenames` which can be, a string specifying the vcs_typename name or a list of such strings""" from zeta.config.environment import tlcomp if isinstance(vcs_typenames, (str, unicode)): vcs_typenames = [vcs_typenames] logs = [] msession = meta.Session() with msession.begin(subtransactions=True): [msession.add(VcsType(unicode(t))) for t in vcs_typenames] # Database Post processing tlcomp.log( byuser, 'added version control types, `%s`' % \ ', '.join(vcs_typenames) )
def create_tag(self, tagname, byuser=None): """Create a new tag entry.""" from zeta.config.environment import tlcomp tag = None log = '' msession = meta.Session() if self.is_tagnamevalid(tagname): with msession.begin(subtransactions=True): if not self.tag_exists(tagname): tag = Tag(tagname) msession.add(tag) log = 'created new tag, `%s`' % tagname else: raise ZetaTagError('Duplicate tag entry %s' % tagname) # Database Post processing log and tlcomp.log(byuser, log, tag=tag) return tag
def onclose(tlcomp, byuser, log): log and tlcomp.log(byuser, log)
def onclose(tlcomp, srchcomp, byuser, log, idxreplace): tlcomp.log(byuser, log) srchcomp.indexstaticwiki([sw], replace=idxreplace)
def onclose(tlcomp, project, byuser, log): tlcomp.log(byuser, log, project=project)
def onclose(tlcomp, srchcomp, attach, log, byuser): srchcomp.indexattach([attach], replace=True) log and tlcomp.log(byuser, log, attach=attach)
def onclose(tlcomp, vcs, byuser, log): tlcomp.log(byuser, log, project=vcs.project)
def onclose(tlcomp, mount, byuser, log): log and tlcomp.log(byuser, log, project=mount.vcs.project)
def onclose(tlcomp, srchcomp, license, byuser, log, idxreplace): log and tlcomp.log(byuser, log, license=license) srchcomp.indexlicense([license], replace=idxreplace)
def onclose(tlcomp, vcs, byuser, log): log and tlcomp.log(byuser, log, vcs=vcs)
def onclose(tlcomp, srchcomp, attach, log, byuser): # TODO : Delete this attachment. #srchcomp.indexattach( [attach], replace=True ) log and tlcomp.log(byuser, log)
def onclose(tlcomp, license, log, byuser): log and tlcomp.log(byuser, log, license=license)
def onclose(tlcomp, byuser, log): tlcomp.log(byuser, log)
def onclose(tlcomp, srchcomp, wiki, author, log): tlcomp.log(author, log, wiki=wiki) srchcomp.indexwiki([wiki], replace=True)
def onclose(tlcomp, srchcomp, wiki, byuser, log): log and tlcomp.log(byuser, log, wiki=wiki) log and srchcomp.indexwiki([wiki], replace=True)
def onclose(tlcomp, wiki, user, log): tlcomp.log(user, log, wiki=wiki)
def onclose(tlcomp, wiki, byuser, log): log and tlcomp.log(byuser, log, wiki=wiki)
def onclose(tlcomp, licname, byuser): tlcomp.log(byuser, 'deleted license %s' % licname)
def onclose(tlcomp, srchcomp, attach, uploader, log): srchcomp.indexattach([attach]) log and tlcomp.log(uploader, log, attach=attach)