At 01:59 PM 12/10/01 -0800, Tavis Rudd wrote:
>Geoff,
>going back to your class-based config syntax...
>
>The reason we'd need to subclass SettingsContainer is that it is
>possible to have settings that are in fact classes and don't begin
>with an underscore:
>
>##
>from SettingsManager import SettingsContainer as SC
>class Applications(SC):
>     class MyApp(SC):
>         class Dirs:  # virtual dirs like <location> in Apache
>             Services = '/home/tavis/MyApp/Services'
>             Products = '/home/tavis/MyApp/Products'
>         from Foo import Bar as ApplicationClass
>         from Foo import Whiz as RequestClass
>         from Foo import Bang as SessionStoreClass
>##

It seems very odd to me to have a value in a config file be an actual class 
object.  I was expecting settings to be things like ints, strings, lists, 
dictionaries, tuples, etc. but all basically constants that didn't depend 
on code.

I would propose that to specify a class as a config setting, you would 
specify a string like "Package.Module:Class" where you can leave off the 
":Class" part if the class name is the same as the module name.  PSP uses 
this convention for importing stuff and specifying base classes.  So your 
example would be:

class Applications:
     class MyApp:
         class Dirs:  # virtual dirs like <location> in Apache
             Services = '/home/tavis/MyApp/Services'
             Products = '/home/tavis/MyApp/Products'
         ApplicationClass = 'Foo:Bar'
         RequestClass = 'Foo:Whiz'
         SessionStoreClass = 'Foo:Bang'

The advantage is that you can import the config file without having to 
actually import the class.  Perhaps you're just running a config file 
pretty-printing utility, and you don't want it to have to actually do the 
import.


--

- Geoff Talvola
   [EMAIL PROTECTED]

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

Reply via email to