Hi again,

Is there a reason that there are so many related functions grouped as
methods of the Parser class (template.py 64--460) instead of them being
in a separate template module? Is it OK if I untangle that and put all
those things in their own module?

Greetings,

Hraban

On Sat, Oct 10, 2009 at 16:00 +0200, Hraban Luyat wrote:
> 
> Hi Anand,
> 
> Thanks for your quick reply.
> 
> Github: http://github.com/hraban/webpy
> 
> I will be continuing the work there.
> 
> Cheers,
> 
> Hraban
> 
> On Sat, Oct 10, 2009 at 14:44 +0530, Anand Chitipothu wrote:
> > 
> > Hraban Luyat,
> > 
> > Thanks for you efforts. I haven't looked at the code very carefully
> > but here are some quick comments.
> > 
> > * Getting rid of slicing and making everything unicode is nice.
> > 
> > * web.py is compatible with Python 2.3+. You are using collections
> > module which is introduced in Python 2.4. You should to avoid using
> > that.
> > 
> > * I don't think reading entire file into memory is an issue as it is
> > done only once and discard later. In fact it might be the most
> > efficient way. Same thing applies for decoding the text and
> > normalizing it.
> > 
> > Do you mind forking webpy github repository and adding your changes
> > there? It will be easier to pull changes that way.
> > 
> > Anand
> > 
> > 
> > On Sat, Oct 10, 2009 at 1:34 PM, Hraban Luyat <[email protected]> wrote:
> > >
> > > Hello everybody,
> > >
> > > A week or two ago I got the idea to rewrite the template.py file. I
> > > worked on it for a weekend (and then left it there for a while, but
> > > that is another story) and now that most doctests pass I would like to
> > > ask you for comments.
> > >
> > > The modifications are all done on web/template.py. I present you the
> > > output from the following command:
> > >
> > > $ git diff  "c1b4ae6bf7ab29ffa9d2c28a39fc93bc0f5ca690" -- web/
> > > template.py
> > >
> > > Which, I believe, is the latest commit by Anand, the 5th of September.
> > > I uploaded the output to pastebin.com: <http://pastebin.com/f28e95b3d>
> > > (HTML) and <http://pastebin.com/pastebin.php?dl=f28e95b3d> (plain
> > > text). I am not familiar with git or bazaar and only a little bit with
> > > mercurial: this is probably a very cumbersome way of sharing code
> > > changes, if anybody can tell me how this is normally done without
> > > access to the repository I would love to hear it.
> > >
> > > ## Goals
> > >
> > > In order of personal preference:
> > > - supporting other encodings than just utf-8
> > > - making the code more obvious to read
> > > - making it more memory and CPU efficient.
> > >
> > > ## My impression of template.py's current state
> > >
> > > Correct me if I am wrong: it reads the entire template file at once as
> > > a raw byte string, does a /lot/ of splicing on it (this is usually
> > > very inefficient but I did not time it so I can not legally comment on
> > > it) and, important note, handles the raw byte string it reads as text
> > > encoded in utf-8 (hard-coded throughout the file to utf-8 and us-
> > > ascii).
> > >
> > > ## My changes so far
> > >
> > > Most significant changes:
> > > - Decode the template source file immediately when reading it
> > > - using unicode objects everywhere internally
> > > - update documentation and docstrings accordingly
> > > - step through the template line by line instead of compilation step
> > > by compilation step.
> > >
> > > The last step is done through extensive use of iterators: there is
> > > much less splicing of strings and the template engine does not need
> > > the entire file in memory anymore (although it does keep the compiled
> > > result in memory---I did not touch that part). For example: the
> > > splitline() function is never called anymore (it is completely removed
> > > from the code).
> > >
> > > This has not been tested extensively. Two doctests still fail: these
> > > are both related to old-style '$var x: 1' notation. Aside from the
> > > doctests, I did as good as no testing. And I did not compare the
> > > performance of both versions. I see this version mostly as a
> > > checkpoint that I illustrates my intentions enough to at least ask for
> > > some feedback, not a serious patch intended for the code base.
> > >
> > > I tried to leave as much of the current structure intact. Classes,
> > > functions, the big picture is still relatively the same. This is NOT a
> > > rewrite (yet), this is a big change to the implementation details.
> > >
> > > ## Plans for the future
> > >
> > > I want to start making more rigorous changes to the entire structure
> > > of template.py. At least some clear documentation on the steps that
> > > the code goes through is in order, as well as splitting the file into
> > > clearly seperate parts. I think more than that can be done, though. To
> > > be very honest: I am not entirely sure on what this will mean
> > > specifically, so I want to start by looking at how to best achieve the
> > > afore-mentioned goals.
> > >
> > > ## My request to the web.py community
> > >
> > > I would like to ask anybody who has read this far ;) a few questions.
> > > Please comment on any subset of these questions if you can find the
> > > motivation.
> > >
> > > - What do you think about the current templating system? On an
> > > abstract level: the documentation, the specification, the way it
> > > works, etc. Also on a practical level: performance, bugs, error
> > > messages, handling of encoding, etc. Any comments you have I would
> > > like to hear them.
> > >
> > > - What do you think about the changes I proposed (under "Goals"), and
> > > about this entire effort in general? Please do not hold back---if you
> > > think I should stop, I would rather hear it now than spend more time
> > > on something that will not be accepted.
> > >
> > > - What do you think about the code itself? Official template.py and
> > > mine, any comments you have.
> > >
> > > - Anything else you have to say!
> > >
> > > Greetings,
> > >
> > > Hraban
> > > >
> > >
> > 
> > 
> 
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to