Re: [gentoo-portage-dev] Plugin framework

2005-11-14 Thread Jason Stubbs
On Monday 14 November 2005 23:17, Marius Mauch wrote:
 On Mon, 14 Nov 2005 22:38:28 +0900

 Jason Stubbs [EMAIL PROTECTED] wrote:
  The cache and elog plugin selection(s) come from user settings but
  emaint (and repoman whenever that happens (and possibly even emerge
  itself one day?)) needs to automatically detect what's available and
  use it.

 The last part I consider questionable, while they shouldn't come from
 the user config directly I'd be very careful with a use everything
 possible policy. Not saying that it's flat wrong or that I have a
 better plan right now, but having this as a primary design goal seems
 wrong.

That's why there's the issubclass() check. That guarantees that modules found 
in a certain path (of a certain plugin type) provide a prespecified API. 
Utilizing that API, it's then possible to inspect the plugin in any way 
necessary. My goal at this level is just to provide an easy way to enumerate 
what plugins are available and have some assurance that a certain API is 
available.

If you're talking with regard to emaint specifically. The goal is to have 
plugins detected at runtime and available as extra targets beyond the current 
world. That would allow things such as revdep-rebuild to be integrated 
without the need for special handling on the emaint side.

--
Jason Stubbs
-- 
gentoo-portage-dev@gentoo.org mailing list



Re: [gentoo-portage-dev] Plugin framework

2005-11-14 Thread Brian Harring
On Mon, Nov 14, 2005 at 10:38:28PM +0900, Jason Stubbs wrote:
 On Sunday 13 November 2005 11:57, Brian Harring wrote:
   ?? filenames.
OT, but return of the funky 'A's...
Curious if others are seeing it, or if my nano/mutt setup just plain 
sucks.

   * portage.py edits to the config class to make use of the framework.
  
   Essentially, plugins.registry gives dict access to modules under
   plugins/. To give an example, the plugins.cache.anydbm.anydbm class can
   be accessed via plugins.repository[cache][anydbm].
 
  Offhand... you're duplicating pythons first found for module
  namespace, which I'm not particularly much for, at least for a
  registry framework.
 
  If you're going to introduce a plugin registry, allow the plugins to
  exist wherever they want in python namespace, and have the registry
  entry point to it (preferably lifting code from 3.0 where possible
  also).
 
 I'm not familiar with this. If it works better than what I've got now without 
 having to hardcode what plugins are available, I'm all for it. Perhaps 
 registry is the wrong word for what I was trying to do...

No... registry's probably apt. :)

If this were mainlined, I'd prefer a tool that registers the plugin 
portage uses- do this, and /etc/portage/modules can go away, using a 
generic framework instead.

I'm not much for on the fly determination via inspecting namespace- 
too easy for it to bite users in the ass, imo.  


  Meanwhile, couple of code comments, then final comments...
 
   diff -uNr portage-orig/pym/plugins/__init__.py
   portage-plugin-framework/pym/plugins/__init__.py ---
   portage-orig/pym/plugins/__init__.py  1970-01-01 09:00:00.0 
   +0900
   +++ portage-plugin-framework/pym/plugins/__init__.py  2005-11-12
   21:52:15.0 +0900 @@ -0,0 +1,80 @@
   +class registry:
   +
   + class _plugin_loader:
 
  Shoving the _pluging_loader class into the registry class namespace
 
 Strange obsession with keeping the namespace empty.

__all__ is a useful module attribute if you're concerned about 
from somemodule import *

  makes it a bit hard for derivatives of registry to be implemented.
 
 I can't see any possible reason to want to derive from it. The point of it is 
 that pulling external code in should be seamless. If it doesn't serve as is, 
 I'd prefer that it be fixed rather than putting the functionality somewhere 
 else.

Nothing real is lost by not hiding it.  It probably will never be 
derived from, but that doesn't mean we hide it blocking the possibility 
from ever occuring either. :)

   + self._path = path
   + self._loaded = {}
   +
   + def __getitem__(self, name):
 
  This is not thread safe (addressed in 3.0)
 
 This is an interesting point. I wasn't thinking about thread-safety at all, 
 but when should I be? Should everything be implemented with thread safety in 
 mind? If not, at what point should the line be drawn?

My view on it is if you're implementing global objs, new stuff should 
be thread safe if it's sane.

Plugin registry is something I'd define, at least for the imports, as 
code that should be as defensive as possible (eg, atomic).

 $ python -c 'import plugins; print dir(plugins)'
 ['__builtins__', '__doc__', '__file__', '__name__', '__path__', 'registry']
 
 There's something attractive about the above, but I'm not married to it.
dir() isn't real useful aside from introspection/development imo;

Imo, appropriate pydoc strings tacked in ought to mitigate any issues 
in terms of pollution/uglyness.

  config.module_priority is _evil_ (yep, first I've noticed that gem).
  If a user specified cache backend can't be loaded, falling to a
  default is a great way to piss users off (that's a bad 'helpful'
  feature).  Meanwhile, back to your patch...
 
 Actually, that was also my mistaken addition. The original code uses 
 module_priority but only tries loading the first found. More
 misguidedness. :(

Eh... module_priority should die, regardless if you've expanded upon 
it or not.

Ironic I'm stating portage should be made dumber then it is, but 
'helpfullness' when an app reverts user choices is something that 
always has bugged the hell out of me. :)

 So, as I said before, the point is to unify plugin management. Instead of 
 having the imports done wherever something can be plugged in, unify that and 
 do it all in one place. The cache and elog plugin selection(s) come from user 
 settings but emaint (and repoman whenever that happens (and possibly even 
 emerge itself one day?)) needs to automatically detect what's available and 
 use it.

User settings is system specific settings really; this is getting back 
to why I think this should be an actual registry (as in on disk).

I'll take a look at ripping portage.plugins out of 3.0, and integrate 
it into 2.0.  The api differs, but wrapping it's base api with a dict 
style class isn't too hard to do.
~harring


pgpdQlmVfTpMW.pgp
Description: PGP signature


Re: [gentoo-portage-dev] Plugin framework

2005-11-14 Thread Patrick Börjesson
On 05/11/14 09:53, Brian Harring wrote:
 On Mon, Nov 14, 2005 at 10:38:28PM +0900, Jason Stubbs wrote:
  On Sunday 13 November 2005 11:57, Brian Harring wrote:
  filenames.
 OT, but return of the funky 'A's...
 Curious if others are seeing it, or if my nano/mutt setup just plain 
 sucks.

I don't see them in Jason's emails, but in your replies they're there...
Don't know why, but maybe some sort of locale- or encoding-setting
somewhere in your mutt config?

-- 
Regards,
 Patrick Börjesson

PGP signature: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0x21792A5D
PGP fingerprint: 74AF D4EF 6BDE CF77 16BE  6A29 CDB8 7607 2179 2A5D

()  The ASCII Ribbon Campaign - against HTML Email
/\   and proprietary formats.


pgpC5PDTTn8oK.pgp
Description: PGP signature