Uploaded image for project: 'SX Spring Python'
  1. SX Spring Python
  2. SESPRINGPYTHONPY-127

Implement abstract objects

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.1.0.M2
    • IoC
    • None

    Description

      The idea is to implement abstract container managed objects, much like Java Spring supports it, so that, for instance, the syntax below would
      be supported.

      And the purpose of using such objects would be to keep the common configuration in the parent objects which would be subclassed and customized in the child ones.

      Here's the mailing list thread - http://lists.springsource.com/archives/springpython-users/2009-November/000155.html

      <object id="BaseServer" class="my.Server" abstract="true">
      <int id="admin-port">17200</int>
      <int id="emergency-port">27200</int>
      </object>

      <object id="DevServer" parent="BaseServer">
      <int id="http-port">8199</int>
      </object>

      <object id="TestServer" parent="BaseServer">
      <int id="http-port">8299</int>
      </object>

      ...

      object: BaseServer
      class: my.Server
      properties:

      • object: admin-port
        int: 17200
      • object: emergency-port
        int: 27200

      object: DevServer
      parent: BaseServer
      properties:

      • object: http-port
        int: 8199

      object: TestServer
      parent: BaseServer
      properties:

      • object: http-port
        int: 8299

      ...

      class Config(PythonConfig):

      @Object
      @abstract
      def base_server(self):
      server = my.Server()
      server.admin_port = 17200
      server.emergency_port = 27200

      return server

      @Object
      @parent("base_server")
      def dev_server(self, server=None):

      1. 'server' would be automatically provided by the 'parent' decorator
        server.http_port = 8199
        return server

      @Object
      @parent("base_server")
      def test_server(self, server=None):
      server.http_port = 8299
      return server

      ...

      Attachments

        Activity

          People

            dsuch Dariusz Suchojad
            dsuch Dariusz Suchojad
            Archiver:
            tmarshall Trevor Marshall

            Dates

              Created:
              Updated:
              Resolved:
              Archived: