tcalmant / ipopo

iPOPO: a Service-Oriented Component Model for Python
https://ipopo.readthedocs.io/
Apache License 2.0
69 stars 28 forks source link

Normalize HTTP server port in its validate() method #37

Closed tcalmant closed 9 years ago

tcalmant commented 9 years ago

When instantiating an HTTP service component using the instantiate shell command, the port property must be converted to an integer, else Python 3 fails with the error below. Also, the invalidate method must be protected to avoid using a None reference.

$ instantiate pelix.http.service.basic.factory httpd pelix.http.port=9000
Component 'httpd' : error calling callback method for event VALIDATE
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\pelix\ipopo\instance.py", line 522, in safe_callback
    return self.__callback(event, *args, **kwargs)
  File "C:\Python34\lib\site-packages\pelix\ipopo\instance.py", line 472, in __callback
    result = comp_callback(self.instance, *args, **kwargs)
  File "C:\Python34\lib\site-packages\pelix\http\basic.py", line 796, in validate
    if self._port is None or self._port < 0:
TypeError: unorderable types: str() < int()
Component 'httpd' : error calling callback method for event INVALIDATE
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\pelix\ipopo\instance.py", line 522, in safe_callback
    return self.__callback(event, *args, **kwargs)
  File "C:\Python34\lib\site-packages\pelix\ipopo\instance.py", line 472, in __callback
    result = comp_callback(self.instance, *args, **kwargs)
  File "C:\Python34\lib\site-packages\pelix\http\basic.py", line 867, in invalidate
    self._server.shutdown()
AttributeError: 'NoneType' object has no attribute 'shutdown'
Component 'httpd' instantiated.