[xslt] [ENHANCEMENT REQUEST] give URI Resolver hooks in Python API accessto per-invocation data


I have finally gotten a chance to try out the new resolver hook:


This is a good start: I would like to propose an enhancement that
would give the resolver function access to per-invocation data.

The way it is today, I can only give the resolver access to module
scoped data.  This greatly restricts its power and genericity.

There are two possible approaches:

A) Provide a Resolver class that can be subclassed

class MyResolver(libxml.UriResolver):
   def resolve(self, URI, ID, context):
      # do something
      return resolvedURI

   MyResolver resolver(some, data, i, need, later)

B) Make it possible for the resolver to be a bound function,
and provide an extra parameter where invocation-specific data
can be passed:

   class FOO:

     def resolve(self, URI, ID, context, extra):
           return extra

      def doStuff(self):
         extra = "<foo/>"
         libxml2.setEntityLoader(self.resolve, extra)


Of the two, I believe (A) is the more powerful approach, but
(B) is equally acceptable, and might be easier to implement.

Also, I am not clear on how multiple invocations of
setEntityLoader() will work.  Will each new invocation
cause the old resolver to be replaced with the new, passed-in
one?  That would be the preferred behavior.

Thanks very much,


PS   Should I log this in bugzilla?

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]