Diez is right on all counts.
At its simplest, this is how I see a simple command-line example:
ls foobar # look -at- a file or folder
ls foobar/ # look -into- a folder -- won't work with files
In HTTP, the following:
GET /foobar # look -at- this file
GET /foobar/ # look -into- this folder
Apache will automatically correct you if it knows the "file" you are
attempting to get is actually a folder. It'll add the slash. It
will not do the reverse; all scripting languages can retrieve the
"path" after the script. Apache has no way of knowing if this is
actually what you want.
TG functions seemed to me to emulate directories, because, a) they
don't have extensions...
All of my scripting, for some time now, has not had extensions.
Extensions make -filenames- in one language non-portable to another
language. And as time progresses and languages evolve, I -have- been
converting Perl scripts to PHP scripts to Python. Not having to
break everyone's links during these changes is a wonderful thing.
Also, despite how much I love the languages I work in at the time, my
love has faded for most of them. I would rather not advertise for
lost loves. XP
and b) you can pass parameters to them by giving them after a slash.
As for pretending to be a directory, well, PHP scripts do it too -
and silently, I might add. Write the following into a file named
phpinfo.php, then navigate to the script phpinfo.php/foobar... now
how strange does -that- url look?
<? phpinfo(); ?>
And it does work with a trailing slash! In unix, you can't do this:
[EMAIL PROTECTED]:~$ ls tpsettings.xml/
ls: tpsettings.xml/: Not a directory
See my previous LS example.
The difference only bites you when you least expect it, when other
function, I suppose, sends you to a relative URL instead of
absolute. I think it would be better if TG consistently treated
functions as either urls or files, and without slash making magical
difference, but I'm rather new to TG so I could be completely wrong
and this might just be
one of those good, practical trade-offs with minor downsides.. I
really have no idea. Since nobody else ran into this, I guess
that's the case.
I did not run into this because I understood the way Apache deals
with URLs from back in the day I used real on-disk files. ^_^
Think of it this way, as an analogue to on-disk concepts:
1. A controller -class- is a folder.
2. A controller -method- is a file.
3. A method can appear as a folder by passing positional arguments.
This is identical to PHP, CGI Perl, etc. when using on-disk folders
and files.
In my CMS, for example, each "page" you create is a new instance of a
controller class, thus every "page" appears to be a folder. Methods
are "views" into the object. E.g.:
http://example.com/contact/
http://example.com/contact/modify
http://example.com/contact/properties
Despite appearing to break the "page as page, not folder" rule, it is
correct - contact is a class instance, not method.
Thanks for your help, much appreciated!
To force a method to not accept positional arguments, the easiest way
is to turn:
def foo(self, tg_errors, **kw):
pass
Into:
def foo(self, **kw):
tg_errors = kw.pop('tg_errors', None)
pass
This way there -are- no positional arguments.
Matthew Bevan, Systems Administrator
Top Floor Computer Systems Ltd.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---