[Grok-dev] branches review before 0.11 release

Brandon Craig Rhodes brandon at rhodesmill.org
Tue Nov 6 01:05:30 EST 2007


"Lennart Regebro" <regebro at gmail.com> writes:

> 1. Which tests should we keep: The ftests Brandon did, or the
> unittests I did without realizing Brandon alsread had made some
> tests.  Mine test a bit more, but that can be merged.

I have destroyed my tests.  I like yours better.

> 2. I refactored the ZPT support.  ...  I have moved them to the
> simplified story, meaning that the ZPTs are now attributes on the
> grok classes.

I think that having the ZPT follow the same story as the rest is great!

> 3. There ... still a PageTemplateFile for BBB purposes. Should we
> keep it so, or deprecate it?

If it's not needed, I would destroy it.

> Oh, and I also realized during this work that we can add simple
> support for automatic refreshing to the GrokTemplate class...

All templates should automatically refresh, always, is my opinion. :-)

Since we want to release tomorrow, I'm going to try to keep these last
three comments to being nomenclature-only.

My three last thoughts before a merge tomorrow (or, wow, today!):

 - Can we rename "fromTemplate" to "fromString"?  The name
   "fromTemplate" is misleading since a template is what both
   "fromTemplate" and "fromFile" *return*, not what they *accept* as
   arguments.  They accept a string and a file; they each return a
   template.  (Ack!  I now see there is also a getTemplate() method,
   that is *not* the opposite of fromTemplate()!  This will deeply
   confuse me on some future date.)

 - Can we rename "fromFile" to "fromPath" or something?  The name
   "fromFile" in Python, by convention, should mean an actual file()
   object, not merely the name of a file.

 - I'm not sure we should store the template on behalf of the person
   writing the "from*()" and "render()" methods, because that makes
   their code a bit easier to read.  Looking at this bit of example:

 class ...(...):
     def fromTemplate(self, template):
         return MyTemplate(template)

     def render(self, view):
         return self.getTemplate().render(**self.getNamespace(view))

   it was not obvious to me, until I either read the rules or looked
   at the code, that the return value from "fromTemplate()" was what
   was gotten back later by the "self.getTemplate()" view.  I would
   find the above easier to read if the plugger wrote:

 class ...(...):
     def fromTemplate(self, template):
         _template = MyTemplate(template)

     def render(self, view):
         return self._template.render(**self.getNamespace(view))

   because then I can see clearly where the template is going and how
   it makes its appearance again to have its "render()" method called.

   Of course, I guess someone could always write their code like this
   second example anyway, as long as the base class doesn't mind
   "fromTemplate()" returning None, and then never having
   "getTemplate()" called. :-)

   Anyway: it's a much bigger deal to me to have the method names get
   fixed before we go live tomorrow, than it is for anyone to pay any
   attention to this third suggestion of mine that template instances
   not get saved invisibly and automatically. :-)

-- 
Brandon Craig Rhodes   brandon at rhodesmill.org   http://rhodesmill.org/brandon


More information about the Grok-dev mailing list