Re: new to theme modifying and need help

greg <[email protected]> Tue, 19 Apr 2005 00:28:32 -0400
Newsgroups gmane.comp.web.wiki.moin.devel
Message-ID <[email protected]>
OK.  I came up with a solution using what was in action.AttachFile.=20
Not sure it's the best but it works.

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

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

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

On 4/17/05, greg <[email protected]> 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.
>=20
> It looks like this panel is formed in Theme.editbar.  Just working by
> example, I added.
>=20
>         add(link(request, quotedname + '?action=3DAttachFile',
>                  _('Attachments', formatted=3DFalse)))
>=20
> 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?
>=20
> Any help is appreciated.  Thanks for MoinMoin.  So far it looks great
> -- clean with hidden and exensible power.  Well it's python.
>=20
> Thanks,
> Greg
>=20
> BTW, in case it's not the convention for themes, the context for the
> snippet above is:
>=20
>  _ =3D  self.request.getText
>  link =3D wikiutil.link_tag
>  links =3D []
>  add =3D links.append
>  items =3D '\n'.join(['<li>%s</li>' % item for item in links if item !=3D=
 '']
>  html =3D u'<ul class=3D"editbar">\n%s\n</ul>\n' % items
>  return html
>


-------------------------------------------------------
This SF.Net email is sponsored by: New Crystal Reports XI.
Version 11 adds new functionality designed to reduce time involved in
creating, integrating, and deploying reporting solutions. Free runtime info,
new features, or free trial, at: http://www.businessobjects.com/devxi/728