velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Revusky <jrevu...@terra.es>
Subject Re: template encodings
Date Mon, 16 Jul 2001 14:03:22 GMT
"Geir Magnusson Jr." wrote:
> 
> Jonathan Revusky wrote:
> >
> > "Geir Magnusson Jr." wrote:
> > >
> > > And then what?  Do we have to support the alphabet soup of possibilities
> > > for Window's [broken] file system?   First look at C:, then D:, then E:,
> > > then F:, then... Or do we force people to only use UNC under windows?
> >
> > You're just being argumentative. Your code is broken in this instance.
> > This has absolutely nothing to do with cross-platform issues because the
> > core java libraries already handle it!
> 
> 1) Not argumentative. Take my word for it.  I have better things to do
> than debate you for the fun of it.

Well, your behavior suggests otherwise. If you did have better things to
do, you'd be doing them.

> 
> 2) The code is not 'broken' as it works as specified and as designed.
> You may disagree with the design constraints we set up, but nonetheless,
> it works properly.

There is no condition under which the default behavior makes any sense.
Furthermore, it is defined in such a way that it will inevitably confuse
people. To me, that qualifies as "broken". 

> 
> 3) How would the 'core libraries' handle, as you just suggested, we go
> wandering around trying to satisfy the users request....

Straw man. I did not suggest that you go "wandering around". I said
specifically that if somebody gives a fully specified filename and the
file is present, the template engine should use it!

If you downloaded an XML parser and stuck a file in your file system
called: /home/geir/test/somefile.xml

and you wrote code saying:
XMLParser.parse("/home/geir/test/somefile.xml");

and said file exists, then I believe that it should really parse that
file. It should not (at least as a default behavior) second-guess
whether you really mean to parse that file! At least that should be the
default behavior!  To define a *default* behavior that is different from
the above will *inevitably* create a situation that confuses people.

> 
> What if a windows user did
> 
> Template t = Velocity.getTemplate("\\templates\\foobar.vm");
> 
> then what?  Spin the wheel and choose a letter?  "Today, we choose the
> 'F:' drive..."

No, because that's not an absolute file location. In Windows-land, an
*absolute* file location starts with C:\ or D:\ or something like that.
I would just go with the File.isAbsolute() call in the core java API's.
In the above case, it would return false. The next logical thing for Mr.
Newbie to try would be to specify the drive letter as well and then,
voila, it would work. But if a newbie user specifies the file location
as completely as is possible and the engine does not load the file, this
will cause frustration and confusion.

> 
> >
> > Specifically in FileResourceLoader.getResourceStream(templateName) you
> > should specifically check whether someone has passed in an absolute
> > path. Here's the code:
> >
> > File f = new File(templateName);
> > if (f.isAbsolute() && f.exists()) {
> >    return new BufferedInputStream(new FileInputStream(f));
> > }
> 
> No - like I said - we don't do root unless specifically specified as a
> valid template path.  

I know that's what you do. I am suggesting that the default behavior is
wrong.

> This rule is so popular, WebMacro is going to add
> it as well.



> 
> > > What about the Mac?
> > >
> >
> > You're talking out of your hat.
> 
> I would have said "ass".
> 
> > The core java libraries deal with this.
> > The above code snippet also works on the mac or unix.
> 
> Yes, but as I keep trying to tell you, we currently don't let the
> FileResourceLoader do this by default.  You can easily make it do that,
> by adding root to your valid template paths.

Yes, but if I'm a newbie, I have to know where the config entry is
etcetera. I have to muck around a bit. I am specifically talking about
having out-of-the-box defaults such that a new user will get going as
quickly as possible.

I don't have any stake in this, because I have already written a
CustomResourceLoader that Niggle uses in conjunction with Velocity that
has a default policy that IMO makes more sense.

As for the comments below (snipped) about your history of participation,
okay, I take your word for it. In any case, it is right and proper that
you take pride in your hard work, but my perception is that there is an
extreme resistance to being told things. 

If you guys really have pride and confidence in your work, then you
shouldn't need to be so on the defensive.

Jonathan Revusky
--
available for Java/Delphi/Internet consulting
If you want to...
- make your .class files double-clickable with SmartJ
- do Delphi/Java mixed programming with easy-to-use JNI wrapper classes
- build robust web applications with the Niggle Application Framework
then...
check out the Revusky Hacks Page: http://www.revusky.com/hacks/

Mime
View raw message