[Zope3-checkins] CVS: Zope3/src/zope/app/pythonpage-__init__.py:1.7

Tim Peters tim at zope.com
Sat Apr 3 01:31:53 EST 2004


[Stephan]
> Okay, that makes sense on an OS level. But our "file" lives in the
> ZODB and the file name is much more a URL than a traditional
> filename. There are a couple of solutions I see for this problem:
>
> 1. Before passing the filename to the SyntaxError constructor,
> convert the forward slashes to os.path.sep.
>
> 2. Only pass the filename and not the directories to the SyntaxError
> constructor.
>
> What seems more correct to you?

Can't say -- the only use case I know of so far is the effort to get this
stinking test to pass <wink>.  Worse, I don't know why str(SyntaxError)
throws info out of the filename attribute, and I dislike that it does so
(independent of this test).

It sounds like the full "URL" is what's really wanted here.  If so, #1
sounds better than #2 -- despite that str() will chop it to its basename, at
least the filename attribute would still contain it.

Perhaps another alternative:

3. Pass filename.replace('/', '.') to the SyntaxError constructor.

Then str() wouldn't throw away any info, although it would present it in a
somewhat strained form.  Maybe replacing / with | would be better.




More information about the Zope3-Checkins mailing list