# HG changeset patch # User paulb # Date 1130262699 0 # Node ID ff10afb9263b5ad83337acc14e6e5fed70ea30b2 # Parent 2b2b93f32e2b005e9803b1f37d46cdeaf6f351e6 [project @ 2005-10-25 17:51:39 by paulb] Made the resource more general, adding a special function which retrieves a suitably configured resource class. Made collections start with zero elements. diff -r 2b2b93f32e2b -r ff10afb9263b examples/Common/QtConfigurator/__init__.py --- a/examples/Common/QtConfigurator/__init__.py Tue Oct 25 17:50:19 2005 +0000 +++ b/examples/Common/QtConfigurator/__init__.py Tue Oct 25 17:51:39 2005 +0000 @@ -1,10 +1,8 @@ #!/usr/bin/env python -import XSLForms.PyQt -import QtConfigurator.Forms import os -class Configurator(QtConfigurator.Forms.Configurator, XSLForms.PyQt.XSLFormsResource): +class ConfiguratorResource: # Standard attributes. @@ -35,8 +33,6 @@ # Initialisation. def __init__(self, *args, **kw): - QtConfigurator.Forms.Configurator.__init__(self, *args, **kw) - self.factory = XSLForms.PyQt.Factory(self.prepare_template("configuration")) # Get field data. # NOTE: This would be done for whole page updates in a Web application. @@ -45,6 +41,9 @@ self.populate_list(self.keyboard, self.get_elements("keyboard")) self.populate_list(self.mouse, self.get_elements("mouse")) self.populate_list(self.screen, self.get_elements("screen")) + self.reset_collection(self.hard_disks) + self.reset_collection(self.memory_units) + self.reset_collection(self.storage_units) # General functionality. @@ -167,4 +166,22 @@ def exportConfig(self): print "configuration.exportConfig(): Not implemented yet" +def get_resource_class(resource_type): + + if resource_type == "PyQt": + import XSLForms.PyQt + import QtConfigurator.Forms + class Configurator(ConfiguratorResource, QtConfigurator.Forms.Configurator, XSLForms.PyQt.XSLFormsResource): + def __init__(self, *args, **kw): + QtConfigurator.Forms.Configurator.__init__(self, *args, **kw) + self.factory = XSLForms.PyQt.Factory(self.prepare_template("configuration")) + ConfiguratorResource.__init__(self, *args, **kw) + else: + import XSLForms.Resources + class Configurator(ConfiguratorResource, XSLForms.PyQtWeb.XSLFormsResource): + def __init__(self, *args, **kw): + ConfiguratorResource.__init__(self, *args, **kw) + + return Configurator + # vim: tabstop=4 expandtab shiftwidth=4