Re: [jokosher-devel] Managing extensions



On 10/3/06, John Green <john thegreens co uk> wrote:
On Mon, Oct 02, 2006 at 04:41:00PM -0400, Laszlo Pandy wrote:
> One other thing to think about is: where should extensions keep their
> own config files? If we put them all in ~/.jokosher/extensions/ we will
> probably run into name conflicts. This makes having separate dirs even
> more appealing.
I think that having each extension in its own directory is cleaner. Maybe we
can have the startup() function always in a .py file with the same name as
the directory so we don't have to hunt for it. How about adding a
GetShortDescription() function to get a one-line description to display in
the ManageExtensions window.

OK, my thoughts on extension distribution, running, configuration, and
disabling. This is how I planned to do it.

Egg files are the standard Python way of distributing a module which
requires extra files or more than one Python file all in a single
package. It seems silly to me to do .tar.gz methods, because we'd
basically be re-inventing .egg files ourselves. The issues of "when do
we unpack them" are also a problem. Eggs are like Java .jar files. See
http://peak.telecommunity.com/DevCenter/PythonEggs for details about
them. Using egg files will make it easier to port to different
platforms, because the stuff to use them is already built in to
Python. An egg file can be imported as a module without unpacking,
which is the point of them, and Python files inside the .egg can load
other files inside the .egg (say, .glade files) also without
unpacking. Installation of a .tar.gz file is awkward, because you can
drag it into the extensions folder but can't then later drag it out
(because it will have been exploded into a directory) which is
confusing for users.

--------------------------------------------

Configuration: my thought was that we would provide two API functions,
getConfigParameter and setConfigParameter. Extensions use those to
save configuration. That way, an extension doesn't have to worry about
where those parameters are saved. I'd suggest that implementation of
those parameters is done something like this:

Extension calls setConfigParameter("username", "stuartl") (to save a username)
setConfigParameter looks for
.jokosher/extension-config/EXTENSIONNAME.config and finds that it
doesn't exist
Create a dictionary {"username", "stuartl"} and pickle it to the file
.jokosher/extension-config/EXTENSIONNAME.config

Extension calls setConfigParameter("password", "mypass")
setConfigParameter looks for
.jokosher/extension-config/EXTENSIONNAME.config and finds that it does
exist
pickle.load that file to a dictionary
add "password", "mypass" to that dictionary and repickle it back to the file

Extension calls getConfigParameter("username")
getConfigParameter looks for
.jokosher/extension-config/EXTENSIONNAME.config and finds that it does
exist
pickle.load it into a dictionary d
return d["username"]

Make sense? The reason we use pickle is that then people can set
config parameters to be complicated things like another dictionary:
setConfigParameter("somedata", {"wibble":"bar"}) should work.

--------------------------------------------

Disabling global extensions: I think that the easiest way to do this
is to have a .jokosher/extension-config/disabled file which lists
global extensions that should not be loaded. That, to me, seems a lot
better than losing the ability to have global extensions, or having a
rather unpleasant hack of having J "copy" extensions from a global dir
into your local dir when you run it. That idea also won't work all
that well because if you run J, it "copies" a global extension into
your .jokosher, you then delete that "copied" extension (to disable
it) and run J again, it'll copy it again! A "disabled" file explicitly
listing global extensions you don't want to run seems like the easiest
way, and being able to ship extensions with Jokosher is such a big win
that we don't want to step away from it if we can avoid it.

--------------------------------------------

Sorry I've been out of touch for a few days. Welcome to new people, too!

sil

--
If hard data were the filtering criterion you could fit the entire
contents of the Internet on a floppy disk.
            -- Cecil Adams



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]