Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-wiki
Commits
cd60dfde
Commit
cd60dfde
authored
Aug 20, 2012
by
benjaoming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removing after refactor
parent
8d7f6064
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
88 deletions
+0
-88
wiki/core/plugins/plugins_load.py
+0
-38
wiki/core/plugins/plugins_registry.py
+0
-50
No files found.
wiki/core/plugins/plugins_load.py
deleted
100644 → 0
View file @
8d7f6064
# -*- coding: utf-8 -*-
"""
Credits to ojii, functions get_module and load are from:
https://github.com/ojii/django-load.
Thanks for the technique!
"""
from
django.conf
import
settings
from
django.utils.importlib
import
import_module
def
get_module
(
app
,
modname
,
verbose
,
failfast
):
"""
Internal function to load a module from a single app.
"""
module_name
=
'
%
s.
%
s'
%
(
app
,
modname
)
try
:
module
=
import_module
(
module_name
)
except
ImportError
,
e
:
if
failfast
:
raise
e
elif
verbose
:
print
"Could not load
%
r from
%
r:
%
s"
%
(
modname
,
app
,
e
)
return
None
if
verbose
:
print
"Loaded
%
r from
%
r"
%
(
modname
,
app
)
return
module
def
load
(
modname
,
verbose
=
False
,
failfast
=
False
):
"""
Loads all modules with name 'modname' from all installed apps.
If verbose is True, debug information will be printed to stdout.
If failfast is True, import errors will not be surpressed.
"""
for
app
in
settings
.
INSTALLED_APPS
:
get_module
(
app
,
modname
,
verbose
,
failfast
)
def
load_wiki_plugins
():
load
(
'wiki_plugin'
,
verbose
=
False
)
wiki/core/plugins/plugins_registry.py
deleted
100644 → 0
View file @
8d7f6064
# -*- coding: utf-8 -*-
from
django.utils.importlib
import
import_module
_cache
=
{}
_settings_forms
=
[]
_markdown_extensions
=
[]
_article_tabs
=
[]
_sidebar
=
[]
def
register
(
PluginClass
):
"""
Register a plugin class. This function will call back your plugin's
constructor.
"""
if
PluginClass
in
_cache
.
keys
():
raise
Exception
(
"Plugin class already registered"
)
plugin
=
PluginClass
()
_cache
[
PluginClass
]
=
plugin
settings_form
=
getattr
(
PluginClass
,
'settings_form'
,
None
)
if
settings_form
:
if
isinstance
(
settings_form
,
basestring
):
klassname
=
settings_form
.
split
(
"."
)[
-
1
]
modulename
=
"."
.
join
(
settings_form
.
split
(
"."
)[:
-
1
])
form_module
=
import_module
(
modulename
)
settings_form
=
getattr
(
form_module
,
klassname
)
_settings_forms
.
append
(
settings_form
)
if
getattr
(
PluginClass
,
'article_tab'
,
None
):
_article_tabs
.
append
(
plugin
)
if
getattr
(
PluginClass
,
'sidebar'
,
None
):
_sidebar
.
append
(
plugin
)
_markdown_extensions
.
extend
(
getattr
(
PluginClass
,
'markdown_extensions'
,
[]))
def
get_plugins
():
return
_cache
def
get_markdown_extensions
():
return
_markdown_extensions
def
get_article_tabs
():
"""Returns plugin classes that should connect to the article tab menu"""
return
_article_tabs
def
get_sidebar
():
"""Returns plugin classes that should connect to the sidebar"""
return
_sidebar
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment