Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1000

Incorect value for HOST & PORT properties of MongoClient object

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Works as Designed
    • Affects Version/s: 3.0.3
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Environment:

      Description

      The following code illustrates the problem. Essentially print str(MongoClient) returns the expected output but the HOST and PORT properties do not.

      from pymongo import MongoClient
       
      c = MongoClient("localhost", 27017)
      print c
      print c.HOST
      print str(c.PORT)
      c.close()
       
      c = MongoClient("mongodb://localhost:30001/test")
      print c
      print c.HOST
      print str(c.PORT)
       
      c = MongoClient("localhost.localdomain", 30001)
      print c
      print c.HOST
      print str(c.PORT)
       
      c = MongoClient(host="localhost", port=30001)
      print c
      print c.HOST
      print str(c.PORT)
      

      Output is as follows...

      <pre>
      MongoClient('localhost', 27017)
      localhost
      27017
      MongoClient('localhost', 30001)
      localhost
      27017
      MongoClient('localhost.localdomain', 30001)
      localhost
      27017
      MongoClient('localhost', 30001)
      localhost
      27017
      </pre>

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: