List Info

Thread: objectizing pagelist?




objectizing pagelist?
user name
2007-11-07 16:26:28
I've been thinking of writing a recipe to implement the
YouSendIt clone I
mentioned on the list a few months ago. In my mind, what
would be ideal would
be to have an (:attachlist... and a
(:filelist ... directive
that would
use much of the same code as pagelist, and have most of the
same features,
including the fmt=... option.

Looking over the pagelist.php code, it seems clear that it
mostly does what I
want, but in a way that makes it hard to reuse. So, I've
been wondering if I
shouldn't rewrite it to use php classes in order to make it
easier to repurpose.

Right now the only thing stopping me is fear that there was
some good reason
it wasn't done this way in the first place. I've not worked
with php's classes
much (although I'm completely familiar with object oriented
programming) so I
don't know if there are major overhead issues or nasty
gotchas involved in how
classes work under PHP.

If it were any other directive than pagelist, I wouldn't
worry about it, but
thats one routine that gets very heavy use in PmWiki, and
I'd hate to degrade
its performance in any significant way.






_______________________________________________
pmwiki-devel mailing list
pmwiki-develpmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-devel

Re: objectizing pagelist?
country flaguser name
United States
2007-11-08 13:24:43
On Wed, Nov 07, 2007 at 05:26:28PM -0500, Stirling Westrup
wrote:
> I've been thinking of writing a recipe to implement the
YouSendIt clone I
> mentioned on the list a few months ago. In my mind,
what would be ideal would
> be to have an (:attachlist... and a
(:filelist ... directive
that would
> use much of the same code as pagelist, and have most of
the same features,
> including the fmt=... option.

The big problem with using (:pagelist for things
like attachlist
or filelist is that pagelist is really built to work with
lists of
pages (and all of the associated page properties), whereas 
attachlist/filelist would need to deal with lists of
attachments
or files (and a different set of properties).  While this
may sound 
like a minor difference, in terms of implementation I've
found it 
to be very significant -- especially since pagelist is one
of the
most intensive operations we have.

I think the biggest difference between the two is that
attachments
don't have "page variables" in the same way that
pages do, thus
it's very difficult to use things like {$Name} or {$Group}
for
display or sorting criteria.  We'd probably need to come up
with
a set of "attachment variables", and they probably
should not
use the {$var} page variable syntax.  It might make sense
for them
to possibly use the {$$var} template syntax, but then we'll
also
be looking for things like {=$$var} and {<$$var} and that
starts
to get really confusing.

The other big difference is that attachments don't have the
same
access control mechanism that pages do, so much of what
pagelist
is trying to do is irrelevant to an attachment context. 
Even
things like pagelist caching don't seem to make much sense
in
an attachment context, since we're caching completely
different
types of data.

So, I really think that attachlist/filelist are
fundamentally
different beasts from pagelist, and any attempt to get one
routine
to handle both would be more superficial than helpful.

One possible exception to this would be if the whole of
PmWiki
became very heavily object oriented, where both pages and
attachments are internally represented as objects that share

some common interfaces.  That might make it easier to
develop a
common base for pagelist/filelist, and there could be some
other
advantages.  However, it's certainly not likely to happen
anytime
soon, and I'm not sure that the supposed advantage would
actually
be all that useful in the overall scheme of things.

Please correct me if I'm wrong, but I think the main reason
that people are so interested in trying to re-use
(:pagelist
code for attachments is to gain the flexibility we
currently
have with pagelist templates.  But that's really more a
function
of the templating code than of (:pagelist, and the
templating
functions in PmWiki have been factored out into re-usable 
subroutines.  So, if we're just looking for a templatable
attachlist, we just need a driver that builds a list of
attachments
according to whatever filtering/ordering criteria we want,
and then have it perform template substitutions with the
appropriate variables set.  And we need to figure out what
those variables are going to be.  

Hope this helps explain why I haven't tried to unify
pagelist/attachlist in the codebase.  Ultimately I find
there
are just too many differences in the underlying data
components
to make a single routine have that much benefit.

Pm

_______________________________________________
pmwiki-devel mailing list
pmwiki-develpmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-devel

Re: objectizing pagelist?
user name
2007-11-08 13:33:17
Patrick R. Michaud wrote:

> Hope this helps explain why I haven't tried to unify
> pagelist/attachlist in the codebase.  Ultimately I find
there
> are just too many differences in the underlying data
components
> to make a single routine have that much benefit.

Thanks. Its always helpful to have your take on these
things. So maybe I'll
try to write a parallel attachlist that re-uses some of the
pagelist stuff for
output purposes. I'll let you know if I run into any major
problems re-using
the pagelist code.


_______________________________________________
pmwiki-devel mailing list
pmwiki-develpmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-devel

Re: objectizing pagelist?
country flaguser name
United States
2007-11-08 13:52:23
On Thu, Nov 08, 2007 at 02:33:17PM -0500, Stirling Westrup
wrote:
> Patrick R. Michaud wrote:
> 
> > Hope this helps explain why I haven't tried to
unify
> > pagelist/attachlist in the codebase.  Ultimately I
find there
> > are just too many differences in the underlying
data components
> > to make a single routine have that much benefit.
> 
> Thanks. Its always helpful to have your take on these
things. So maybe I'll
> try to write a parallel attachlist that re-uses some of
the pagelist stuff for
> output purposes. I'll let you know if I run into any
major problems re-using
> the pagelist code.

Personally, I'd be very surprised if any of the _pagelist_
code is
very helpful here.  The algorithms may be useful, but I
wouldn't think
that calls to the code would be all that helpful.

The functions that I think are going to be most helpful
are:

    FmtTemplateVars() -- replace occurrences of {$$key} in a
template
    RetrieveAuthSection() -- retrieve a section of another
page (e.g.,
       from a fmt= parameter)

There's not any generic code for handling (:template first
... 
(:template each ... yet, but
I've been considering factoring it
out into a common set of subroutines.  But even if we do
that,
there's still the issue of figuring out how to handle
expressions
like {<$...}, {=$...}, and {>$...} for things that
aren't really 
page variables.  Currently that's a very _pagelist_
specific
thing because '<', '=', and '>' get replaced by
pagenames and
transate into calls to PageVar() .

Pm

_______________________________________________
pmwiki-devel mailing list
pmwiki-develpmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-devel

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )