Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1.0.M2
    • Component/s: IoC
    • Labels:
      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

      ...

        Activity

        Hide
        gregturn Greg Turnquist added a comment -

        Replace:

        object_wrapper.is_prototype = (theScope == scope.PROTOTYPE)

        with:

        object_wrapper.scope = theScope

        Then, replace:

        if wrapper.func_name.startswith("object"):
        if wrapper.is_prototype:
        c = ObjectDef(id=name, factory=PythonObjectFactory(method, wrapper), scope=scope.PROTOTYPE, lazy_init=wrapper.lazy_init)
        else:
        c = ObjectDef(id=name, factory=PythonObjectFactory(method, wrapper), lazy_init=wrapper.lazy_init)

        with:

        if wrapper.func_name.startswith("object"):
        c = ObjectDef(id=name, factory=PythonObjectFactory(method, wrapper), scope=wrapper.scope, lazzy_init=wrapper.lazy_init)

        Show
        gregturn Greg Turnquist added a comment - Replace: object_wrapper.is_prototype = (theScope == scope.PROTOTYPE) with: object_wrapper.scope = theScope Then, replace: if wrapper.func_name.startswith("object"): if wrapper.is_prototype: c = ObjectDef(id=name, factory=PythonObjectFactory(method, wrapper), scope=scope.PROTOTYPE, lazy_init=wrapper.lazy_init) else: c = ObjectDef(id=name, factory=PythonObjectFactory(method, wrapper), lazy_init=wrapper.lazy_init) with: if wrapper.func_name.startswith("object"): c = ObjectDef(id=name, factory=PythonObjectFactory(method, wrapper), scope=wrapper.scope, lazzy_init=wrapper.lazy_init)
        Hide
        dsuch Dariusz Suchojad added a comment -

        Merged to trunk in r757.

        Show
        dsuch Dariusz Suchojad added a comment - Merged to trunk in r757.

          People

          • Assignee:
            dsuch Dariusz Suchojad
            Reporter:
            dsuch Dariusz Suchojad
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: