/usr/lib/thuban/Thuban/Model/extension.py is in thuban 1.2.2-12build3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | # Copyright (c) 2001, 2002 by Intevation GmbH
# Authors:
# Jan-Oliver Wagner <jan@intevation.de>
#
# This program is free software under the GPL (>=v2)
# Read the file COPYING coming with Thuban for details.
__version__ = "$Revision: 2355 $"
from Thuban import _
from messages import EXTENSION_CHANGED, EXTENSION_OBJECTS_CHANGED
from base import TitledObject, Modifiable
class Extension(TitledObject, Modifiable):
"""Represent a extension. A extension is a package of additional
functionality to Thuban and contains a number of Objects
that can be freely defined in an extension.
Each object must a a TitleObject with additional set "object.name".
Furthermore, each object must implement the methods Subscribe,
Unsubscribe and Destroy (i.e. derive from Modifiable).
Extension objects send the following message types:
EXTENSION_CHANGED -- Something in the extension has changed.
EXTENSION_OBJECTS_CHANGED -- Something in the objects has changed.
"""
forwarded_channels = (EXTENSION_CHANGED, EXTENSION_OBJECTS_CHANGED)
def __init__(self, title):
"""Initialize the extension."""
TitledObject.__init__(self, title)
self.objects = []
def Destroy(self):
for object in self.objects:
object.Destroy()
Modifiable.Destroy(self)
def AddObject(self, object):
self.objects.append(object)
for channel in self.forwarded_channels:
object.Subscribe(channel, self.forward, channel)
self.changed(EXTENSION_OBJECTS_CHANGED, self)
def RemoveObject(self, object):
for channel in self.forwarded_channels:
object.Unsubscribe(channel, self.forward, channel)
self.layers.remove(layer)
self.changed(EXTENSION_OBJECTS_CHANGED, self)
object.Destroy()
def Objects(self):
return self.objects
def HasObjects(self):
return len(self.objects) > 0
def FindObject(self, title):
"""Find an object by title. If found, return it, else return None."""
for object in self.objects:
if object.title == title:
return object
return None
def forward(self, *args):
"""Reissue events"""
if len(args) > 1:
args = (args[-1],) + args[:-1]
apply(self.issue, args)
def WasModified(self):
"""Return true if something of the extension was modified"""
if self.modified:
return 1
else:
return 0
def UnsetModified(self):
"""Unset the modified flag of the extension"""
Modifiable.UnsetModified(self)
def TreeInfo(self):
return (_("Extension: %s") % self.title,
["%s: %s" % (object.title, object.name)
for object in self.objects])
|