[lxml-dev] Failure with custom resolvers and relative xsl:import
Stefan Behnel
stefan_ml at behnel.de
Tue Aug 19 21:45:36 CEST 2008
Hi,
Sidnei da Silva wrote:
> On Mon, Aug 18, 2008 at 4:04 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
>> The problem here is that lxml currently only takes the .name attribute of a
>> file object to determine the file name. The right thing to do would be to use
>> os.path.abspath(f.name) instead to retrieve the absolute path name of the file.
>>
>> Using resolve_filename(filename) instead of resolve_file(open(filename))
>> provides a more efficient work around, though.
>
> Okay, I think that solves one of the problems, when the filename is
> local. I suspect it won't solve the other problem I had, which was
> when the file comes from urlopen(). Since the files are relatively
> small though I can keep using resolve_string() for now.
here's a patch that tries making filenames absolute when users pass a
file-like object. This only works for file objects (and maybe compatible
objects), but "file://..." URLs should be provided as absolute URLs anyway.
Is there anything that's missing? You mentioned problems with urlopen(), but
didn't elaborate on them any further.
Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: absolute-filenames.patch
Type: text/x-patch
Size: 3484 bytes
Desc: not available
Url : http://codespeak.net/pipermail/lxml-dev/attachments/20080819/cf24f3c5/attachment-0001.bin
More information about the lxml-dev
mailing list