I think I've got it!  see below

I don't think I know what "Dependencies" is for though, and so that part is
probably wrong.  But the revision and date seem correct!!

PageRevision.py

from MoinMoin import wikiutil
from MoinMoin.wikiutil import get_unicode, get_bool, get_int, get_float
from MoinMoin.logfile import editlog

Dependencies = []
generates_headings = False

def macro_PageRevision(macro):

    request = macro.request
    pagename = request.page.page_name

    Dependencies = ["pages"] # is this right??

    log = editlog.EditLog(request, rootpagename=pagename)
    for line in log.reverse():
        rev = str(int(line.rev))
        tim = 
request.user.getFormattedDateTime(wikiutil.version2timestamp(line.ed_time_usecs))
        break
    return macro.formatter.text("Rev "+rev+" at "+tim)


On Thu, Dec 10, 2009 at 3:41 PM, Kirby Moyers <kdmoy...@gmail.com> wrote:
> I'm having trouble making a macro to tell the page rev number
> and last rev date.  My short poor attempt is listed below.  I am a
> fairly experienced coder, but have never worked with python before.
>
> The calculation of the rev number works sometimes, but
> other times makes an error "unsubscriptable", I guess
> because the expression did not return a list.  Is there
> a more reliable way to get the rev number?
>
> The rev date calculation is just me taking shots
> in the dark.  I have no firm idea how to find this value.
>
> Anyone got an idea how to find these two values?
>
> As last ditch, I guess I could try to go find the edit-log
> file and read out the last line, but that seemed to violate
> the general flow of the 1.8.5 moinmoin code.
>
> Thanks in advance for any help!!
> -Kirby
>
>
> from MoinMoin.wikiutil import get_unicode, get_bool, get_int, get_float
>
> Dependencies = []
> generates_headings = False
>
> def macro_PageRevision(macro):
>    # arguments passed in can be None or a unicode object
>
>    Dependencies = ["pages"] # is this right??
>
>    # saw suggestion: macro.form.get("rev")   which sometimes produces [u'25']
>    # saw suggestion: macro.request.page.rev  which always produces 0
>
>    thisrev = int(macro.form.get("rev")[0])+1   # this actually worked 
> sometimes
>    thistim = macro.form.get('time', [''])[0]   # this never worked
>
>    return macro.formatter.text("Rev "+thisrev+" "+thistim)
>

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Moin-user mailing list
Moin-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/moin-user

Reply via email to