Gentoo Archives: gentoo-portage-dev

From: Brian Harring <ferringb@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] Plugin framework
Date: Mon, 14 Nov 2005 15:54:59
Message-Id: 20051114155356.GB11268@nightcrawler
In Reply to: Re: [gentoo-portage-dev] Plugin framework by Jason Stubbs
1 On Mon, Nov 14, 2005 at 10:38:28PM +0900, Jason Stubbs wrote:
2 > On Sunday 13 November 2005 11:57, Brian Harring wrote:
3 > > >   filenames.
4 OT, but return of the funky 'A's...
5 Curious if others are seeing it, or if my nano/mutt setup just plain
6 sucks.
7
8 > > > * portage.py edits to the config class to make use of the framework.
9 > > >
10 > > > Essentially, plugins.registry gives dict access to modules under
11 > > > plugins/. To give an example, the plugins.cache.anydbm.anydbm class can
12 > > > be accessed via plugins.repository["cache"]["anydbm"].
13 > >
14 > > Offhand... you're duplicating pythons "first found" for module
15 > > namespace, which I'm not particularly much for, at least for a
16 > > registry framework.
17 > >
18 > > If you're going to introduce a plugin registry, allow the plugins to
19 > > exist wherever they want in python namespace, and have the registry
20 > > entry point to it (preferably lifting code from 3.0 where possible
21 > > also).
22 >
23 > I'm not familiar with this. If it works better than what I've got now without
24 > having to hardcode what plugins are available, I'm all for it. Perhaps
25 > registry is the wrong word for what I was trying to do...
26
27 No... registry's probably apt. :)
28
29 If this were mainlined, I'd prefer a tool that registers the plugin
30 portage uses- do this, and /etc/portage/modules can go away, using a
31 generic framework instead.
32
33 I'm not much for on the fly determination via inspecting namespace-
34 too easy for it to bite users in the ass, imo.
35
36
37 > > Meanwhile, couple of code comments, then final comments...
38 > >
39 > > > diff -uNr portage-orig/pym/plugins/__init__.py
40 > > > portage-plugin-framework/pym/plugins/__init__.py ---
41 > > > portage-orig/pym/plugins/__init__.py 1970-01-01 09:00:00.000000000 +0900
42 > > > +++ portage-plugin-framework/pym/plugins/__init__.py 2005-11-12
43 > > > 21:52:15.000000000 +0900 @@ -0,0 +1,80 @@
44 > > > +class registry:
45 > > > +
46 > > > + class _plugin_loader:
47 > >
48 > > Shoving the _pluging_loader class into the registry class namespace
49 >
50 > Strange obsession with keeping the namespace empty.
51
52 __all__ is a useful module attribute if you're concerned about
53 from somemodule import *
54
55 > > makes it a bit hard for derivatives of registry to be implemented.
56 >
57 > I can't see any possible reason to want to derive from it. The point of it is
58 > that pulling external code in should be seamless. If it doesn't serve as is,
59 > I'd prefer that it be fixed rather than putting the functionality somewhere
60 > else.
61
62 Nothing real is lost by not hiding it. It probably will never be
63 derived from, but that doesn't mean we hide it blocking the possibility
64 from ever occuring either. :)
65
66 > > > + self._path = path
67 > > > + self._loaded = {}
68 > > > +
69 > > > + def __getitem__(self, name):
70 > >
71 > > This is not thread safe (addressed in 3.0)
72 >
73 > This is an interesting point. I wasn't thinking about thread-safety at all,
74 > but when should I be? Should everything be implemented with thread safety in
75 > mind? If not, at what point should the line be drawn?
76
77 My view on it is if you're implementing global objs, new stuff should
78 be thread safe if it's sane.
79
80 Plugin registry is something I'd define, at least for the imports, as
81 code that should be as defensive as possible (eg, atomic).
82
83 > $ python -c 'import plugins; print dir(plugins)'
84 > ['__builtins__', '__doc__', '__file__', '__name__', '__path__', 'registry']
85 >
86 > There's something attractive about the above, but I'm not married to it.
87 dir() isn't real useful aside from introspection/development imo;
88
89 Imo, appropriate pydoc strings tacked in ought to mitigate any issues
90 in terms of pollution/uglyness.
91
92 > > config.module_priority is _evil_ (yep, first I've noticed that gem).
93 > > If a user specified cache backend can't be loaded, falling to a
94 > > default is a great way to piss users off (that's a bad 'helpful'
95 > > feature). Meanwhile, back to your patch...
96 >
97 > Actually, that was also my mistaken addition. The original code uses
98 > module_priority but only tries loading the first found. More
99 > misguidedness. :(
100
101 Eh... module_priority should die, regardless if you've expanded upon
102 it or not.
103
104 Ironic I'm stating portage should be made dumber then it is, but
105 'helpfullness' when an app reverts user choices is something that
106 always has bugged the hell out of me. :)
107
108 > So, as I said before, the point is to unify plugin management. Instead of
109 > having the imports done wherever something can be plugged in, unify that and
110 > do it all in one place. The cache and elog plugin selection(s) come from user
111 > settings but emaint (and repoman whenever that happens (and possibly even
112 > emerge itself one day?)) needs to automatically detect what's available and
113 > use it.
114
115 User settings is system specific settings really; this is getting back
116 to why I think this should be an actual registry (as in on disk).
117
118 I'll take a look at ripping portage.plugins out of 3.0, and integrate
119 it into 2.0. The api differs, but wrapping it's base api with a dict
120 style class isn't too hard to do.
121 ~harring

Replies

Subject Author
Re: [gentoo-portage-dev] Plugin framework "Patrick Börjesson" <psycho@××××××××.cx>