[Moin-devel] Re: new to theme modifying and need help

greg gregwh at gmail.com
Mon Apr 18 21:28:47 EDT 2005


OK.  I came up with a solution using what was in action.AttachFile. 
Not sure it's the best but it works.

        pagename = d['page_name'] # is this right?
        attach_dir = getAttachDir(request, pagename)
        files = []
        if os.path.isdir(attach_dir):
            files = os.listdir(attach_dir)

        add(link(request, quotedname + '?action=AttachFile',
                 _('Attachments', formatted=False) + " (%i)" % len(files)))

I also learned something new about python string interpolation.  Doh.

On 4/17/05, greg <gregwh at gmail.com> wrote:
> I've been using the sincor4moin theme I got from the ThemeMarket and I
> want to make what seems like a very small modificaiton.  Right now
> there is a panel in the left side bar.  It has the "Edit", "Get Info",
> and the More Actions pull down.  I want to add a "Attachments (#)"
> where # is the number of attachments.
> 
> It looks like this panel is formed in Theme.editbar.  Just working by
> example, I added.
> 
>         add(link(request, quotedname + '?action=AttachFile',
>                  _('Attachments', formatted=False)))
> 
> So far, so good.  I have "Attachments" text in the sidebar.  Now how
> do I get the number of attachments?  I thought I could use a method of
> the page objects to get a list of attachments or something similar,
> but couldn't find anything promising.  Looking around the source code,
> II found text like "%s(attach_count)s" that looks promising but I
> haven't figured out quite how to use it.  Do I pass this to a function
> that decodes it or does it go in the return of editbar and get decoded
> downstream?
> 
> Any help is appreciated.  Thanks for MoinMoin.  So far it looks great
> -- clean with hidden and exensible power.  Well it's python.
> 
> Thanks,
> Greg
> 
> BTW, in case it's not the convention for themes, the context for the
> snippet above is:
> 
>  _ =  self.request.getText
>  link = wikiutil.link_tag
>  links = []
>  add = links.append
>  items = '\n'.join(['<li>%s</li>' % item for item in links if item != '']
>  html = u'<ul class="editbar">\n%s\n</ul>\n' % items
>  return html
>




More information about the Moin-devel mailing list