On Fri, 2002-04-26 at 18:56, Tavis Rudd wrote:
> On April 26, 2002 06:06 pm, Terrel Shumway wrote:
> > http://webware.colorstudy.net/twiki/bin/view/Webware/UriMapping is for a
> > concrete implementation that can go into Webware RSN that can replace
> > the current filesystem-centric mapping strategy.
> 
> Tangent 1
> -----------
> 
> This URI topic is somewhat related to how contexts/packages are loaded into 
> WebKit.  The current implementation of ServletFactory relies on the 'imp' 
> module and thus can't take any advantage of custom import hooks.  As a 
> result, you have to create a new servlet factory for .tmpl files, .psp files, 
> etc., in addition to any import hooks you've written. 
 
Yes, and you SHOULD have to create a new ServletFactory.  

  class ServletFactory(Object):
        """ServletFactory is an abstract class that defines the protocol
        for all servlet factories.
        ..."""
 
PythonServletFactory is designed for creating Servlet instances from
Python modules. period.

  class PythonServletFactory(ServletFactory):
        '''
        This is the factory for ordinary, Python servlets whose
        extensions are empty or .py. The servlets are unique per 
        file since the file itself defines the servlet.
        '''

This doc string certainly does not apply to all useful servlets.



> The code in ServletFactory.importAsPackage() and 
> ServletFactory._importModuleFromDirectory could be refactored to allow it to 
> work with import hooks and remove the need for a separate ServletFactory for 
> each extension.  It should be possible to use a single ServletFactory for 
> .py, .psp, and .tmpl servlets once the refactoring has been done and an 
> import hook has been written for .psp files.  


An even better idea would be to factor out the import code (remove
importAsPackage entirely from the ServletFactory interface or move it
down into PythonServletFactory), separate it from imp (as you
suggested), and make it available as a Loader class, to which
PythonServletFactory and others could delegate as necessary.

Removing the need for separate ServletFactory for each extension would
defeat the primary purpose of its design.




_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to