Uploaded image for project: 'Motor'
  1. Motor
  2. MOTOR-339

Don't obfuscate full module name when generating framework-specific API classes

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.1
    • Affects Version/s: None
    • Component/s: None
    • None

      Currently, we shorten/obfuscate the module name when dynamically generating our framework-specific public API classes. E.g. when we create AsyncIOMotorClient we do:

      def create_asyncio_class(cls):
          return create_class_with_framework(cls, asyncio_framework, 'motor_asyncio')
      
      AsyncIOMotorClient = create_asyncio_class(core.AgnosticClient)
      

      with the factory function defined as:

      def create_class_with_framework(cls, framework, module_name):
          motor_class_name = framework.CLASS_PREFIX + cls.__motor_class_name__
          cache_key = (cls, motor_class_name, framework)
          cached_class = _class_cache.get(cache_key)
          if cached_class:
              return cached_class
      
          new_class = type(str(motor_class_name), cls.__bases__, cls.__dict__.copy())
          new_class.__module__ = module_name
          new_class._framework = framework
          ...
          ...
      

      Consequently, AsyncIOMotorClient appears to belong (as per its _module_ value) to the motor_asyncio module, even though it actually resides in motor.motor_asyncio. This creates problems when we attempt to use intersphinx to link to the MOTOR documentation as seen in MOTOR-338.

      Unless there is a good rationale for fudging the _module_ of these classes, we should change the code so that it reflects the actual path.

            Assignee:
            Unassigned Unassigned
            Reporter:
            prashant.mital Prashant Mital (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: