Skip to content

fix: lazy init and recursion fixes#35

Open
vimzoomer wants to merge 1 commit intopycasbin:masterfrom
vimzoomer:fix/infinite-recursion
Open

fix: lazy init and recursion fixes#35
vimzoomer wants to merge 1 commit intopycasbin:masterfrom
vimzoomer:fix/infinite-recursion

Conversation

@vimzoomer
Copy link

Hi, I have two fixes for the adapter:

  1. Accessing database in ready is discouraged by Django, since ProxyEnforcer lazy-initializes Casbin anyway, initialization should be removed from CasbinAdapterConfig.
  2. Infinite recursion in __getattribute__(self, name) caused by self.db_alias. Also, If enforcer is imported in testing environment it breaks Django's test runner which calls __class__ on every imported module during test discovery.

@CLAassistant
Copy link

CLAassistant commented Mar 12, 2026

CLA assistant check
All committers have signed the CLA.

@vimzoomer vimzoomer changed the title ProxyEnforcer: Lazy Init & Recursion Fixes fix: lazy init and recursion fixes Mar 12, 2026
@vimzoomer vimzoomer force-pushed the fix/infinite-recursion branch from 9b8966a to e66f52b Compare March 12, 2026 17:59
- Remove CasbinAdapterConfig initialization in ready
- Fix infinite recursion in __getattribute__
- Prevent test runner crash in testing environment
@vimzoomer vimzoomer force-pushed the fix/infinite-recursion branch from e66f52b to fa53bcf Compare March 13, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants