Install & Compatibility
Where this runs
tested against v0.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 2.4s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Proxy
✓ from proxy_tools import Proxy
module_property
✓ from proxy_tools import module_property
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]
from proxy_tools import module_property
# Example: Simulating a 'current_user' on a module
# In a real application, 'request' and 'User' would be defined elsewhere.
# For this example, we'll mock them.
class MockUser:
def __init__(self, user_id):
self.id = user_id
self.name = f"User_{user_id}"
def __repr__(self):
return f"<MockUser id={self.id}, name='{self.name}'>"
class MockRequest:
def __init__(self, user_id):
self.user_id = user_id
def get_current_user_from_request(request_obj):
# Simulate fetching user from a request context
return MockUser.find_by_id(request_obj.user_id)
# Patch MockUser to have a find_by_id method for the example
MockUser.find_by_id = lambda uid: MockUser(uid)
# Create a mock request object for the context
mock_request = MockRequest(user_id=123)
# Define a module-level property using module_property decorator
# This assumes a mechanism to get the current request, e.g., from a thread-local storage.
# For this quickstart, we'll directly use the mock_request in a closure.
class _ModuleContext:
current_request = None
@module_property
def current_user():
# In a real app, you'd get the request from a global/thread-local context
if _ModuleContext.current_request:
return get_current_user_from_request(_ModuleContext.current_request)
return None # Or raise an error if no request context
# Set the mock request in the context for demonstration
_ModuleContext.current_request = mock_request
# Now, access current_user as if it were a module attribute
print(f"Current user via module_property: {current_user}")
# Demonstrate Proxy class (more generic use case)
def greet_target(name):
return f"Hello, {name}!"
class MyProxy(Proxy):
def __init__(self, target):
super().__init__(target)
def __call__(self, *args, **kwargs):
print(f"Proxying call to: {self.__wrapped__.__name__} with args: {args}, kwargs: {kwargs}")
return super().__call__(*args, **kwargs)
my_proxy_instance = MyProxy(greet_target)
print(my_proxy_instance('World'))
Debug
Known issues
breakingThe library was last released in 2014 and explicitly classified for Python 2.7. It is highly likely that it contains Python 2 specific syntax or assumptions that are incompatible with Python 3+. Direct use in modern Python 3 environments may lead to syntax errors or runtime issues.fixReview the source code for Python 2 specific constructs (e.g., `print` statements, `long` type, `__cmp__`, `next()`) and manually port them to Python 3 compatible alternatives. Consider alternative, actively maintained libraries for proxying or module-level properties if a direct port is too complex.
affects: < 0.1.0
gotchaThe project appears to be unmaintained. The last PyPI release was in May 2014, and the GitHub repository has seen no significant activity since the same period. This means there will be no official updates, bug fixes, or compatibility improvements for newer Python versions or emerging issues.fixEvaluate the stability and criticality of its use in your project. If you encounter bugs or require new features, you will need to fork the repository and maintain the changes yourself. For new projects, it is strongly recommended to seek actively maintained alternatives.
affects: All versions (0.1.0 and earlier)
gotchaThe `Proxy` class and `module_property` rely on Python's introspection and attribute access mechanisms. Misuse, especially with complex object graphs or dynamic attribute resolution, could lead to unexpected behavior, infinite recursion, or performance overhead if not carefully managed.fixThoroughly test proxy implementations, especially in performance-critical paths. Understand the `__getattr__`, `__setattr__`, `__delattr__`, and `__call__` methods and how they interact with the wrapped object. Ensure that proxying logic explicitly handles attributes it intends to manage, delegating others correctly.
affects: All versions (0.1.0 and earlier)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'proxy_tools'
This error occurs when the `proxy-tools` library is not installed in the active Python environment or if there's a misspelling in the import statement.
fixEnsure the library is correctly installed using pip: `pip install proxy-tools`.
AttributeError: 'Proxy' object has no attribute 'some_method_or_attribute'
This error typically arises when you attempt to access an attribute or call a method on a `proxy-tools.Proxy` object that either the underlying proxied object does not possess, or the proxy itself doesn't transparently delegate as expected in a specific context.
fixVerify that the object being proxied actually has the 'some_method_or_attribute' you are trying to access. If the attribute should exist, ensure the proxy is correctly initialized and the underlying object is available when the attribute is accessed.
TypeError: 'Proxy' object is not callable
This error occurs if you try to call a `proxy_tools.Proxy` instance as a function when it has not been configured to proxy a callable object, or if the underlying proxied object is not callable itself.
fixEnsure that the object wrapped by the `Proxy` instance is callable if you intend to invoke it. If you initialized `p = Proxy()`, you must later bind it to a callable via `p(my_callable_object)` before attempting to call `p()`.
Upgrade
Version history
0.1.0latest on PyPI · released May 5, 2014
Audit
Dependencies
No dependency data recorded yet.