GangaBox
The
GangaBox was coded as a response to
Bug 46033; and should allow a user to store any Ganga Object in an easy to understand way, associating a custom name with each object
User Interface
The Box implements and exports most of the python dict methods:
__getitem__, __setitem__, __delitem__, __len__, __contains__, clear, get, has_key, items, keys, values
This means most commands that work on dicts also work on the box.
Renaming objects is currently not possible, one simple idea would be:
box.rename(old_name, new_name)
Typing 'box' on the command line prints the contents of the box:
Out[4]: Contents of the box:
Name | Category | Type
--------------------------------------
test | applications | AthenaMC
myLCG | backends | LCG
It additionally has a help() method, that prints a short summary:
To show the contents of the box, just type 'box'
To put an object in the box, type:
box['precious object'] = object
To access an object in the box, type:
box['interesting thing']
To remove an object from the box, type:
del box['worthless stuff']
(the names of the objects can be freely chosen)
Technical Summary
- The GangaBox has its own XML repository at gangadir/box.xml
- There can be multiple boxes with different names, but at the moment only one box, named 'box' is defined.
- The Box saves the repository on exit, on object insertion or every 30 seconds (in case of a crash)
- It has simple timestamp locking, so one box will only be available from one ganga session.
- The code is only 200 lines
The
GangaBox class is available at
http://homepages.physik.uni-muenchen.de/~Johannes.Ebke/GangaBox.py and should be included in some
init.py file after all modules are loaded (so that all Ganga Object definitions are available).
Major updates:
--
JohannesEbke - 04 May 2009
Responsible:
--
JohannesEbke - 04 May 2009