{"library":"proxy-tools","title":"Proxy Tools","description":"The `proxy-tools` library provides a simple yet useful proxy implementation for Python, based on the Gang of Four (GoF) design pattern. It was lovingly extracted from the `werkzeug` project to be applicable outside the web context, for example, to enable `@property` like behavior on modules. The current version is 0.1.0, with its last release in 2014, suggesting a maintenance or inactive release cadence. [4, 8]","language":"python","status":"maintenance","last_verified":"Sun May 17","install":{"commands":["pip install proxy-tools"],"cli":null},"imports":["from proxy_tools import Proxy","from proxy_tools import module_property"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from proxy_tools import module_property\n\n# Example: Simulating a 'current_user' on a module\n# In a real application, 'request' and 'User' would be defined elsewhere.\n# For this example, we'll mock them.\n\nclass MockUser:\n    def __init__(self, user_id):\n        self.id = user_id\n        self.name = f\"User_{user_id}\"\n\n    def __repr__(self):\n        return f\"<MockUser id={self.id}, name='{self.name}'>\"\n\nclass MockRequest:\n    def __init__(self, user_id):\n        self.user_id = user_id\n\ndef get_current_user_from_request(request_obj):\n    # Simulate fetching user from a request context\n    return MockUser.find_by_id(request_obj.user_id)\n\n# Patch MockUser to have a find_by_id method for the example\nMockUser.find_by_id = lambda uid: MockUser(uid)\n\n# Create a mock request object for the context\nmock_request = MockRequest(user_id=123)\n\n# Define a module-level property using module_property decorator\n# This assumes a mechanism to get the current request, e.g., from a thread-local storage.\n# For this quickstart, we'll directly use the mock_request in a closure.\n\nclass _ModuleContext:\n    current_request = None\n\n@module_property\ndef current_user():\n    # In a real app, you'd get the request from a global/thread-local context\n    if _ModuleContext.current_request:\n        return get_current_user_from_request(_ModuleContext.current_request)\n    return None # Or raise an error if no request context\n\n# Set the mock request in the context for demonstration\n_ModuleContext.current_request = mock_request\n\n# Now, access current_user as if it were a module attribute\nprint(f\"Current user via module_property: {current_user}\")\n\n# Demonstrate Proxy class (more generic use case)\ndef greet_target(name):\n    return f\"Hello, {name}!\"\n\nclass MyProxy(Proxy):\n    def __init__(self, target):\n        super().__init__(target)\n\n    def __call__(self, *args, **kwargs):\n        print(f\"Proxying call to: {self.__wrapped__.__name__} with args: {args}, kwargs: {kwargs}\")\n        return super().__call__(*args, **kwargs)\n\nmy_proxy_instance = MyProxy(greet_target)\nprint(my_proxy_instance('World'))","lang":"python","description":"The `proxy-tools` library provides a `Proxy` class for general object delegation and a `module_property` decorator to enable `@property`-like behavior on modules. The quickstart demonstrates how to define a `module_property` that can dynamically return a value (e.g., a current user based on a request context) and a basic `Proxy` usage with a wrapped callable. [8]","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"0.1.0","pypi_latest":"0.1.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.4,"avg_import_s":0,"wheel_type":"sdist"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"proxy-tools","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"19.2M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"proxy-tools","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":1.9,"import_time_s":0,"mem_mb":0,"disk_size":"20M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"proxy-tools","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0,"mem_mb":0.1,"disk_size":"21.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"proxy-tools","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":2,"import_time_s":0,"mem_mb":0.1,"disk_size":"22M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"proxy-tools","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0,"mem_mb":0.1,"disk_size":"11.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"proxy-tools","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":3,"import_time_s":0,"mem_mb":0.1,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"proxy-tools","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0,"mem_mb":0.3,"disk_size":"11.3M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"proxy-tools","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":2.7,"import_time_s":0,"mem_mb":0.1,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"proxy-tools","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"18.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"proxy-tools","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":2.2,"import_time_s":0,"mem_mb":0,"disk_size":"19M"}]}}