Skip to content

Commit

Permalink
fix: load idp plugin in diff project
Browse files Browse the repository at this point in the history
  • Loading branch information
nannan00 committed Oct 16, 2023
1 parent 30b54f9 commit ab88e15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/idp-plugins/idp_plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
def load_plugins():
"""加载插件"""
# 插件目录(即当前目录)
plugin_base_dir = Path(__file__).resolve().parent
# Note: 这里不能使用Path(__file__).resolve(),因为resolve后会指向软链接目标目录,而非当前目录的真实目录
plugin_base_dir = Path(__file__).parent
# 当前包
package = f"{plugin_base_dir.parent.name}.{plugin_base_dir.name}"

# 子目录列表(即各个插件目录名)
sub_dirs = [name for name in os.listdir(plugin_base_dir) if os.path.isdir(plugin_base_dir / name)]
# 遍历加载各个插件
Expand Down
4 changes: 4 additions & 0 deletions src/idp-plugins/idp_plugins/local/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from django.db import models


# Note: 由于idp_plugins模块会被不同项目引入,model为了被Django App 加载,需要添加app_label,
# 同时由于不同项目自定义app不一样,所以这里直接使用公共的django.contrib.auth
class DataSourceUser(models.Model):
data_source_id = models.BigIntegerField("数据源")
code = models.CharField("用户标识", max_length=128)
Expand All @@ -24,6 +26,7 @@ class DataSourceUser(models.Model):
phone_country_code = models.CharField("手机国际区号", max_length=16, null=True, blank=True)

class Meta:
app_label = "django.contrib.auth"
db_table = "data_source_datasourceuser"
ordering = ["id"]

Expand All @@ -43,4 +46,5 @@ class LocalDataSourceIdentityInfo(models.Model):
username = models.CharField("用户名", max_length=128)

class Meta:
app_label = "django.contrib.auth"
db_table = "data_source_localdatasourceidentityinfo"

0 comments on commit ab88e15

Please sign in to comment.