[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

RE: [pygame] pygweb milestone 1 released



> -----Original Message-----
> From: owner-pygame-users@xxxxxxxx [mailto:owner-pygame-users@xxxxxxxx]
> On Behalf Of jug
> Sent: Monday, June 01, 2009 3:12 PM
> To: pygame-users@xxxxxxxx
> Subject: Re: [pygame] pygweb milestone 1 released
> 
> Noah Kantrowitz wrote:
> > Look at http://trac.edgewall.org/wiki/TracInterfaceCustomization for
> > information on basic customization. If you end up needing more than
> that I
> > can explain how to write a full theme replacement.
> >
> I thought you wanted to do that because you already know how it works.
> After reading the docs, some /trial and error we may manage that, but
> we have enough to do before.
> /

If you (or someone feeling artistic) can take the HTML for a Trac page, say
the wiki, and make it look the way you want, I can make Trac do that.

> > As for plugins, check out trac-hacks.org.
> Sure, I already had a look at it and bookmarked some plugins that may
> be
> useful for us.
> > Making a Django filter for Trac markup probably wouldn't be too too
> hard.
> > Are you running both in the same interpreter?
> The same interpreter? On the testing installation both run over (their
> own) cgi.
> I think we can use formatter.format_to_html
> (http://trac.edgewall.org/browser/tags/trac-
> 0.11.4/trac/wiki/formatter.py#L1109)
> but I don't know what the arguments are (context, wikidom).

You would need to do a few things:

1) Open the Trac environment: env =
trac.env.open_environment('/path/to/trac/env', use_cache=True)

2) Make a fake request:
http://trac.edgewall.org/browser/tags/trac-0.11.4/trac/wiki/tests/formatter.
py#L112
 Href is in trac.web.api, Mock and MockPerm are in trac.test

3) Make a context with the fake req:
http://trac.edgewall.org/browser/tags/trac-0.11.4/trac/wiki/tests/formatter.
py#L118

A context is a tuple of (realm, id, version, parent). You can ignore the
version and parent for this, but you will want to invent a new realm
probably, so context = Context.from_request(req, 'pygweb',
pagename_from_django_or_something)

4) Run the render: format_to_html(env, content, content_from_django)

You can adjust the details of that as you want to, but it should get you
most of the way. Depending on how you want to handle permissions, you may
not want to use MockPerm, but actually load user permissions from Trac:
trac.perm.PermissionCache(env, username)

--Noah