Merge lp:~stefanor/ibid/autoload-plugins into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Merged
Approved by: Stefano Rivera
Approved revision: 589
Merged at revision: 590
Proposed branch: lp:~stefanor/ibid/autoload-plugins
Merge into: lp:~ibid-core/ibid/old-trunk-pack-0.92
Diff against target: None lines
To merge this branch: bzr merge lp:~stefanor/ibid/autoload-plugins
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Michael Gorven Approve
Ibid Core Team Pending
Review via email: mp+4571@code.launchpad.net
To post a comment you must log in.
lp:~stefanor/ibid/autoload-plugins updated
586. By Stefano Rivera

Allow restricting autoloading features within the plugin, and allow loading / skipping on a feature level

Revision history for this message
Michael Gorven (mgorven) wrote :

I'm not convinced about the feature level loading, particularly the
no_autoload attribute at module level. I won't be opposed to merging however
if everyone else is happy.
 review abstain

review: Abstain
Revision history for this message
Jonathan Hitchcock (vhata) wrote :

I can't make up my mind about this - I also think it's a bit messy.

Maybe some more discussion is needed... Whiteboard?

review: Abstain
lp:~stefanor/ibid/autoload-plugins updated
587. By Stefano Rivera

Plugin-level rather than feature-level

Revision history for this message
Stefano Rivera (stefanor) wrote :

r587 is plugin-level rather than feature-level

Revision history for this message
Michael Gorven (mgorven) wrote :

Looking better, but I don't like that adding a processor to the load list
causes other processors in that plugin not to be autoload.
 review needs_fixing

review: Needs Fixing
lp:~stefanor/ibid/autoload-plugins updated
588. By Stefano Rivera

Change loading / skipping logic to be more intuitive. Loading a single Processor doesn't block the rest from loading

589. By Stefano Rivera

Rename skip to noload

Revision history for this message
Michael Gorven (mgorven) wrote :

 review approve

review: Approve
Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/config.ini'
2--- ibid/config.ini 2009-03-16 21:33:13 +0000
3+++ ibid/config.ini 2009-03-17 07:19:20 +0000
4@@ -1,4 +1,3 @@
5-load = core, basic, info, log, http, irc, seen, identity, admin, auth, help, test, sources, config, bzr, network, factoid, roshambo, eval, crypto, tools, morse, dict, lookup, url, google, memo, karma, feeds, trac, buildbot, apt, misc, math, imdb
6 botname = Ibid
7 logging = logging.ini
8
9
10=== modified file 'ibid/core.py'
11--- ibid/core.py 2009-03-16 21:00:23 +0000
12+++ ibid/core.py 2009-03-17 07:19:20 +0000
13@@ -4,6 +4,7 @@
14 from os.path import join, expanduser
15
16 from twisted.internet import reactor, threads
17+from twisted.python.modules import getModule
18 from sqlalchemy import create_engine
19 from sqlalchemy.orm import sessionmaker, scoped_session
20
21@@ -122,8 +123,16 @@
22 self.load_source(source)
23
24 def load_processors(self):
25- for processor in ibid.config['load']:
26- self.load_processor(processor)
27+ if 'load' in ibid.config.plugins:
28+ plugins = set(ibid.config.plugins['load'])
29+ else:
30+ plugins = set(plugin.name.replace('ibid.plugins.', '') for plugin in getModule('ibid.plugins').iterModules())
31+
32+ if 'skip' in ibid.config.plugins:
33+ plugins -= set(ibid.config.plugins['skip'])
34+
35+ for plugin in plugins:
36+ self.load_processor(plugin)
37
38 def load_processor(self, name):
39 object = name
40
41=== modified file 'scripts/ibid-plugin'
42--- scripts/ibid-plugin 2009-03-16 20:55:20 +0000
43+++ scripts/ibid-plugin 2009-03-17 07:19:20 +0000
44@@ -10,6 +10,8 @@
45 except ImportError:
46 pass
47
48+from twisted.python.modules import getModule
49+
50 import ibid
51 import ibid.plugins
52 from ibid.config import FileConfig
53@@ -18,11 +20,13 @@
54
55 parser = OptionParser(usage="%prog [options...] [plugins...]")
56 parser.add_option("-a", "--all", dest="load_all", action="store_true",
57- help="Load all configured plugins")
58+ help="Load all available plugins")
59 parser.add_option("-o", "--only", dest="load_base", action="store_false", default=True,
60 help="Only load the specified plugins, not the common base plugins")
61 parser.add_option("-s", "--skip", dest="skip", action="append", metavar="PLUGIN",
62 help="Skip loading PLUGIN (may be specified more than once)")
63+parser.add_option("-c", "--configured", dest="load_configured", action="store_true",
64+ help="Load all all configured plugins")
65
66 (options, args) = parser.parse_args()
67
68@@ -50,10 +54,17 @@
69 ibid.sources[u'test_source'] = TestSource()
70
71 plugins = set(args)
72-if options.load_all:
73- plugins = set(ibid.config.get("load"))
74-if options.load_base:
75+if options.load_all or options.load_configured:
76+ plugins = set(module.name.replace('ibid.plugins.', '') for module in getModule('ibid.plugins').iterModules())
77+
78+if options.load_configured:
79+ if 'load' in ibid.config.plugins:
80+ plugins = set(ibid.config.plugins['load'])
81+ if 'skip' in ibid.config.plugins:
82+ plugins -= set(ibid.config.plugins['skip'])
83+elif options.load_base:
84 plugins |= set(("admin", "config", "core", "help", "test"))
85+
86 if options.skip:
87 plugins -= set(options.skip)
88

Subscribers

People subscribed via source and target branches