PKΒM:5addcomment/__init__.pyPKΝl6βχˆˆaddcomment/__init__.pyc;ς /Ec@sdS(N((((s8build/bdist.darwin-8.8.1-i386/egg/addcomment/__init__.pys?sPKKl6mW–ΊΊaddcomment/macro.py# vim: expandtab from trac.core import * from trac.wiki.macros import WikiMacroBase import trac.perm from StringIO import StringIO from trac.wiki.formatter import wiki_to_html from trac.wiki.model import WikiPage from trac.util import Markup from trac.util import TracError from trac.web.chrome import add_link from trac.util.text import to_unicode import re, time class AddCommentMacro(WikiMacroBase): """A macro to add comments to a page.""" def render_macro(self, req, name, content): return execute(req.hdf, content, self.env) def _render_macro(self, req, name, content): pass # Fill in a deuglified version here def process_macro_post(self, req): self.log.debug('AddCommentMacro: Got a POST') def execute(hdf, args, env): # prevents from multiple inclusions if hdf.has_key('addcommentmacro'): raise TracError('\'AddComment\' macro cannot be included twice') hdf['addcommentmacro'] = True authname = hdf.getValue("trac.authname", "anonymous") db = env.get_db_cnx() perm = trac.perm.PermissionCache(env, authname) pagename = hdf.getValue("wiki.page_name", "WikiStart") page = WikiPage(env, pagename, None, db) wikipreview = hdf.getValue("wiki.preview", "") appendonly = (args == 'appendonly') readonlypage = int(hdf.getValue("wiki.readonly", "0")) # Can this user add a comment to this page? cancomment = not readonlypage # Is this an "append-only" comment or are we an administrator? if perm.has_permission('WIKI_ADMIN') or appendonly: cancomment = True if not cancomment: raise TracError('Error: Insufficient privileges to AddComment') disabled = '' comment = Markup(to_unicode(hdf.getValue("args.addcomment", ""))).unescape() preview = hdf.getValue("args.previewaddcomment", "") cancel = hdf.getValue("args.canceladdcomment", "") submit = hdf.getValue("args.submitaddcomment", "") if not cancel: authname = hdf.getValue("args.authoraddcomment", authname) # Ensure [[AddComment]] is not present in comment, so that infinite # recursion does not occur. comment = re.sub('(^|[^!])(\[\[AddComment)', '\\1!\\2', comment) out = StringIO() if wikipreview or not (perm.has_permission('WIKI_MODIFY') or appendonly): disabled = ' disabled="disabled"' # If we are submitting or previewing, inject comment as it should look if cancomment and comment and (preview or submit): if preview: out.write("
\n") out.write("

Comment by %s on %s

\n

\n%s\n

\n" % (authname, time.strftime('%c', time.localtime()), wiki_to_html(comment, env, None))) if preview: out.write("
\n") # When submitting, inject comment before macro if comment and submit: submitted = False newtext = StringIO() for line in page.text.splitlines(): if line.find('[[AddComment') == 0: newtext.write("==== Comment by %s on %s ====\n%s\n\n" % (authname, time.strftime('%c', time.localtime()), comment)) submitted = True newtext.write(line + "\n") if submitted: # XXX Is this the dodgiest hack ever? This is needed in # "appendonly" mode when the page is readonly. XXX # if appendonly: # perm.expand_meta_permission('WIKI_ADMIN'); # TODO: How do we get remote_addr from a macro? page.text = newtext.getvalue() page.save(authname, 'Comment added', None) comment = "" else: out.write("
ERROR: [[AddComment]] macro call must be the only content on its line. Could not add comment.
\n") out.write("
\n" % env.href.wiki(pagename)) out.write("
\nAdd comment\n") out.write("
\n\n") out.write("
\n") out.write('
\n\n
\n
' % authname) out.write("
\n\n" % disabled) out.write("\n" % disabled) out.write("\n
\n" % disabled) out.write('' % hdf['htdocs_location']) out.write("
\n
\n") return out.getvalue()# + "
" + hdf.dump() + "
" PKΝl6Α’~΄yyaddcomment/macro.pyc;ς ίότEc@s­dkTdklZdkZdklZdklZdkl Z dk l Z dk l Z dk lZd klZdkZdkZd efd „ƒYZd „ZdS( (s*(s WikiMacroBaseN(sStringIO(s wiki_to_html(sWikiPage(sMarkup(s TracError(sadd_link(s to_unicodesAddCommentMacrocBs)tZdZd„Zd„Zd„ZRS(s"A macro to add comments to a page.cCst|i||iƒSdS(N(sexecutesreqshdfscontentsselfsenv(sselfsreqsnamescontent((s5build/bdist.darwin-8.8.1-i386/egg/addcomment/macro.pys render_macroscCsdS(N((sselfsreqsnamescontent((s5build/bdist.darwin-8.8.1-i386/egg/addcomment/macro.pys _render_macroscCs|iidƒdS(NsAddCommentMacro: Got a POST(sselfslogsdebug(sselfsreq((s5build/bdist.darwin-8.8.1-i386/egg/addcomment/macro.pysprocess_macro_posts(s__name__s __module__s__doc__s render_macros _render_macrosprocess_macro_post(((s5build/bdist.darwin-8.8.1-i386/egg/addcomment/macro.pysAddCommentMacros   cCs|idƒotdƒ‚nt|d<|iddƒ} |iƒ}t i i || ƒ} |iddƒ}t ||t|ƒ}|iddƒ}|d j}t|id d ƒƒ}| } | id ƒp|o t} n| otd ƒ‚nd}tt|iddƒƒƒiƒ}|iddƒ}|iddƒ} |iddƒ}| o|id| ƒ} nti dd|ƒ}t!ƒ} |p| idƒp| o d}n| o|o |p|ol|o| i#dƒn| i#d| t$i%dt$i&ƒƒt'||tƒfƒ|o| i#dƒqGn|o|oΚt(}t!ƒ}xt|i+i,ƒD]c}|i.dƒdjo6|i#d| t$i%dt$i&ƒƒ|fƒt}n|i#|dƒqtW|o,|i/ƒ|_+|i0| dtƒd}q| i#d ƒn| i#d!|i1i2|ƒƒ| i#d"ƒ| i#d#|ƒ|o| i#d$ƒn| o| i#|ƒn| i#d%ƒ| i#dƒ| i#d&| ƒ| i#d'|ƒ| i#d(|ƒ| i#d)|ƒ| i#d*|d+ƒ| i#d,ƒ| i/ƒSdS(-Nsaddcommentmacros+'AddComment' macro cannot be included twices trac.authnames anonymousswiki.page_names WikiStarts wiki.previewss appendonlys wiki.readonlys0s WIKI_ADMINs,Error: Insufficient privileges to AddCommentsargs.addcommentsargs.previewaddcommentsargs.canceladdcommentsargs.submitaddcommentsargs.authoraddcomments(^|[^!])(\[\[AddComment)s\1!\2s WIKI_MODIFYs disabled="disabled"s$
s=

Comment by %s on %s

%s

s%cs
s [[AddCommentis"==== Comment by %s on %s ==== %s s s Comment addeds‘
ERROR: [[AddComment]] macro call must be the only content on its line. Could not add comment.
s0
s(
Add comment sf

sc
sJ sG
sBshtdocs_locations
(3shdfshas_keys TracErrorsTruesgetValuesauthnamesenvs get_db_cnxsdbstracspermsPermissionCachespagenamesWikiPagesNonespages wikipreviewsargss appendonlysints readonlypages cancommentshas_permissionsdisabledsMarkups to_unicodesunescapescommentspreviewscancelssubmitsressubsStringIOsoutswritestimesstrftimes localtimes wiki_to_htmlsFalses submittedsnewtextstexts splitlinesslinesfindsgetvaluessaveshrefswiki(shdfsargssenvscomments wikipreviews appendonlysdisabledsnewtextssubmitsauthnamescancelsoutsperms cancommentspreviewsdbspagenameslines readonlypages submittedspage((s5build/bdist.darwin-8.8.1-i386/egg/addcomment/macro.pysexecutes~    $  8 ,      (s trac.corestrac.wiki.macross WikiMacroBases trac.permstracsStringIOstrac.wiki.formatters wiki_to_htmlstrac.wiki.modelsWikiPages trac.utilsMarkups TracErrorstrac.web.chromesadd_linkstrac.util.texts to_unicodesrestimesAddCommentMacrosexecute( s WikiMacroBasesWikiPagestracsStringIOs TracErrorsMarkups wiki_to_htmlsexecutesAddCommentMacrosresadd_linkstimes to_unicode((s5build/bdist.darwin-8.8.1-i386/egg/addcomment/macro.pys?s          PKΝl6“Χ2EGG-INFO/dependency_links.txt PKΝl6Θ«8Έ44EGG-INFO/entry_points.txt[trac.plugins] addcomment.macro = addcomment.macro PKΝl6ΜΥ4CCEGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: TracAddCommentMacro Version: 0.2 Summary: Macro to add comments to a wiki page. Home-page: http://trac-hacks.org/wiki/AddCommentMacro Author: Alec Thomas Author-email: UNKNOWN License: BSD Description: UNKNOWN Keywords: trac plugin macro comments Platform: UNKNOWN Classifier: Framework :: Trac PKΝl6q° ͺ EGG-INFO/requires.txtTracMacroPostPKΝl6m¦§88EGG-INFO/SOURCES.txtsetup.py TracAddCommentMacro.egg-info/PKG-INFO TracAddCommentMacro.egg-info/SOURCES.txt TracAddCommentMacro.egg-info/dependency_links.txt TracAddCommentMacro.egg-info/entry_points.txt TracAddCommentMacro.egg-info/requires.txt TracAddCommentMacro.egg-info/top_level.txt addcomment/__init__.py addcomment/macro.py PKΝl6m ;0 EGG-INFO/top_level.txtaddcomment PKΝl6“Χ2EGG-INFO/zip-safe PKΒM:5€addcomment/__init__.pyPKΝl6βχˆˆ€4addcomment/__init__.pycPKKl6mW–ΊΊ€ρaddcomment/macro.pyPKΝl6Α’~΄yy€άaddcomment/macro.pycPKΝl6“Χ2€‡+EGG-INFO/dependency_links.txtPKΝl6Θ«8Έ44€Γ+EGG-INFO/entry_points.txtPKΝl6ΜΥ4CC€.,EGG-INFO/PKG-INFOPKΝl6q° ͺ € -EGG-INFO/requires.txtPKΝl6m¦§88€ΰ-EGG-INFO/SOURCES.txtPKΝl6m ;0 €J/EGG-INFO/top_level.txtPKΝl6“Χ2€‰/EGG-INFO/zip-safePK εΉ/