def __init__(self, milestone_name, mstn_number, description, closing_remark=u'', completed=False, cancelled=False, due_date=None): self.milestone_name = milestone_name self.mstn_number = mstn_number self.description = description self.completed = completed self.cancelled = cancelled self.due_date = due_date if closing_remark: self.closing_remark = closing_remark # hitch wiki translation for 'description', 'closing_remark' self.translate = h.hitch(self, Milestone, h.translate, cacheattr='description') self.crtranslate = h.hitch(self, Milestone, h.translate, cacheattr='closing_remark')
def file(self, url, revno=None): """Manufacture VcsFile object for `url` at `revno`, optionally annotated""" vfile = VcsFile(self, url, revno=revno) vfile.info = h.hitch(vfile, VcsFile, self.vcsmod.info, url=url) vfile.cat = h.hitch(vfile, VcsFile, self.vcsmod.cat, url) vfile.diff = h.hitch(vfile, VcsFile, self.vcsmod.diff, url) return vfile
def _init_on_load(self): # hitch wiki translation for `description`, 'closing_remark' self.translate = h.hitch(self, Milestone, h.translate, cacheattr='description') self.crtranslate = h.hitch(self, Milestone, h.translate, cacheattr='closing_remark')
def open_repository(vcs): """Create repository interface and bind the adapter""" if vcs: vcsmod = vcsmods[vcs.type.vcs_typename] vrep = VcsRepository(vcs, vcsmod) vrep.info = h.hitch(vrep, VcsRepository, vcsmod.info) vrep.list = h.hitch(vrep, VcsRepository, vcsmod.list) vrep.logs = h.hitch(vrep, VcsRepository, vcsmod.logs) vrep.diff = h.hitch(vrep, VcsRepository, vcsmod.diff) else: vrep = None return vrep
def __init__(self, text): self.text = text # hitch wiki translation for `text` self.translate = h.hitch(self, TicketComment, h.translate, cacheattr='text')
def __init__(self, description): self.description = description # hitch wiki translation for `description` self.translate = h.hitch(self, ProjectInfo, h.translate, cacheattr='description')
def test_hitch(self): """Testing the hitch functionality""" log.info("Testng h.hitch ...") refargs = () refkw = {} class O(object): pass def checkhitch(self, *args, **kwargs): assert_equal( args, refargs, 'Mismatch in Variable arguments, \n args : %s \n refargs : %s' % (args, refargs)) assert_equal( kwargs, refkw, 'Mismatch in Keyword arguments, \n kwargs : %s \n refkw : %s' % (kwargs, refkw)) return 'hello world' o = O() refargs = (0, 1, 2) args = (3, 4, 5) refkw = {'arg1': 'hello', 'world': 'how are you'} kwargs = {'world': 10, 'kwarg2': 20} o.fhitch = h.hitch(o, O, checkhitch, *refargs, **refkw) refargs = refargs + args refkw.update(kwargs) assert_equal(o.fhitch(*args, **kwargs), 'hello world', 'Mismatch in the return value of the hitched function')
def __init__(self, licensename, summary, text, source): self.licensename = licensename self.summary = summary self.text = text self.source = source # hitch wiki translation for `text` self.translate = h.hitch(self, License, h.translate, cacheattr='text')
def __init__(self, path, text): self.path = path self.text = text # hitch wiki translation for `text` self.translate = h.hitch(self, StaticWiki, h.translate, cacheattr='text')
def __init__(self, version_id, text): self.version_id = version_id self.text = text # hitch wiki translation for `text` self.translate = h.hitch(self, WikiComment, h.translate, cacheattr='text')
def __init__(self, text, author=u''): self.text = text self.author = author # hitch wiki translation for `text` self.translate = h.hitch(self, self.__class__, h.translate, cacheattr='text')
def _text_wikipreview(self): # TEXT """ TEXT : HTML content of wiki markup text""" o = h.Preview() text = request.POST.get('text', '') setattr(o, 'text', text) o.translate = h.hitch(o, h.Preview, h.translate, cacheattr='text') html = o.translate(wtype=c.previewtype, wiki=c.wiki) return html
def _text_swpreview(self): # TEXT """Translate wiki markup text into HTML and send back to browser""" o = h.Preview() text = request.POST.get('text', '') setattr(o, 'text', text) o.translate = h.hitch(o, h.Preview, h.translate, cacheattr='text') html = o.translate(wtype=c.previewtype, wiki=c.swiki) return html
def __init__(self, ticket_number, summary, description): self.ticket_number = ticket_number self.summary = summary self.description = description # hitch wiki translation for `description` self.translate = h.hitch(self, Ticket, h.translate, cacheattr='description')
def __init__(self, position, text, approved=False): self.position = position self.text = text self.approved = approved # hitch wiki translation for `text` self.translate = h.hitch(self, ReviewComment, h.translate, cacheattr='text')
def __init__(self, componentname, comp_number, description): self.componentname = componentname self.comp_number = comp_number self.description = description # hitch wiki translation for `description` self.translate = h.hitch(self, PrjComponent, h.translate, cacheattr='description')
def __init__(self, version_name, ver_number, description): self.version_name = version_name self.ver_number = ver_number self.description = description # hitch wiki translation for `description` self.translate = h.hitch(self, Version, h.translate, cacheattr='description')
def _init_on_load(self): # hitch wiki translation for `text` self.translate = h.hitch(self, self.__class__, h.translate, cacheattr='text')
def _init_on_load(self): # hitch wiki translation for `text` self.translate = h.hitch(self, License, h.translate, cacheattr='text')
def vcs_file(self, environ, projectname, vcsid, filepath): """Create / config / delete VCS entries URLS : /p/{projectname}/s/{vcsid}/*(filepath)?revno=<num> """ from zeta.config.environment import projcomp c.rclose = h.ZResp() # Setup context for page rendering c.projsummary = c.project.summary fileurl = join(c.vcs.rooturl, filepath) c.fileerror = '' c.vfile = c.vrep.file(fileurl, revno=c.revno) c.sourceurl = c.pathinfo + '?wikifile=1' try: c.fileinfo = c.vfile.info(revno=c.revno) c.filelines = c.vfile.cat(revno=c.revno, annotate=True) h.url_filedownl = self.url_vcsfiledown(projectname, vcsid, repopath=filepath, revno=c.revno) except: c.fileinfo = {} c.filelines = [] c.fileerror = "Unable to obtain file %s at revision %s" % \ ( fileurl, c.revno ) if c.wikifile: text = '\n'.join(map(lambda l: l[1], c.filelines)) o = h.Preview() setattr(o, 'text', text) o.translate = h.hitch(o, h.Preview, h.translate, cacheattr='text') html = o.translate( wtype=h.CNTTYPE2WIKITYPE.get(c.cnttype, MNT_TEXTCONTENT)) else: try: c.filelogs = c.vrep.logs(fileurl) c.filelogs = sorted(c.filelogs, key=lambda x: x[1], reverse=True) # Create revision url for each log. fn = lambda l: l.append( self.url_vcsrev(projectname, vcsid, revno=l[1])) map(fn, c.filelogs) # Create file-url for each revision where the file was modified. fn = lambda l: [ self.url_vcsfile(projectname, vcsid, filepath=filepath.lstrip('/'), revno=l[1]), str(l[1]) ] c.sel_frevs = map(fn, c.filelogs) except: c.fileerror = ( "Unable to obtain the history for file %s " +\ "at revision %s") % ( fileurl, c.revno ) c.sel_frevs = [] c.filelogs = [] h.url_reviewvfile = self.url_revwfile(projectname, fileurl, c.vfile.revno) c.vcseditable = h.authorized(h.HasPermname('VCS_CREATE')) c.title = '%s:r%s' % (basename(filepath), c.revno) # Html page generation html = render('/derived/projects/vcsfile.html') c.rclose.append(html) return c.rclose
def mount(self, environ, projectname, mid, murl=''): """Repository mount point URLS : /p/<projectname>/mnt/<mid>/*(murl) """ from zeta.config.environment import projcomp, vcscomp c.rclose = h.ZResp() # Setup context for page generation c.repospath = murl.lstrip('/') c.projsummary = c.project.summary c.mnt = vcscomp.get_mount(int(mid), attrload=['vcs']) if mid else None c.id = mid c.title = 'mount:%s' % getattr(c.mnt, 'name', '') try: cprefix = commonprefix([c.repospath, c.mnt.vcs.rooturl]) c.vrep = va.open_repository(getattr(c.mnt, 'vcs', None)) c.repurl = c.repospath and \ ( c.repospath if cprefix == c.mnt.vcs.rooturl else join( c.mnt.vcs.rooturl, c.repospath ) ) \ or c.mnt.vcs.rooturl c.vfile = c.vrep.file(c.repurl) except: c.vfile = None if c.vfile == None: c.content = '<b>Error in reading path</b>' c.rendertype = c.mnt.content if c.mnt else h.MNT_TEXTCONTENT elif c.vfile.mimetype == 'text/directory': listing = {} dlist = c.vrep.list(c.repurl) [listing.setdefault(f[1], []).append(f) for f in dlist] fn = lambda f: [ self.url_mount(projectname, mid, f[6]), basename(f[2]), ] dirs = map(fn, listing.get('text/directory', [])) files = map(fn, listing.get('text/file', [])) c.content = [ '<li><a href="%s">%s</a></li>' % tuple(d) for d in dirs ] + \ [ '<li><a href="%s">%s</a></li>' % tuple(f) for f in files ] c.content = '\n'.join(c.content) c.rendertype = 'dir' else: c.content = '\n'.join([l[1] for l in c.vfile.cat()]) c.rendertype = c.mnt.content try: o = h.Preview() setattr(o, 'text', c.content) o.translate = h.hitch(o, h.Preview, h.translate, cacheattr='text') c.content = o.translate(wtype=h.CNTTYPE2WIKITYPE[c.rendertype]) except: c.content = u'' try: c.content = unicode(c.content) except: c.content = u'Unicoded file content' c.rclose.append(render('/derived/projects/projmount.html')) return c.rclose
def _init_on_load(self): # hitch wiki translation for `text` self.translate = h.hitch(self, ReviewComment, h.translate, cacheattr='text')
def _init_on_load(self): # hitch wiki translation for `description` self.translate = h.hitch(self, Ticket, h.translate, cacheattr='description')