1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""ExportRM
15
16 Export RelationshipManager objects from a zope database
17
18 $Id: ExportRM.py,v 1.1 2003/04/23 21:25:58 edahl Exp $"""
19
20 __version__ = "$Revision: 1.1 $"[11:-2]
21
22 import sys
23
24 import Globals
25
26 from Products.ZenUtils.ZCmdBase import ZCmdBase
27 from Products.ZenRelations.RelationshipManager import RelationshipManager
28
30
32 ZCmdBase.__init__(self)
33 if not self.options.outfile:
34 self.outfile = sys.stdout
35 else:
36 self.outfile = open(self.options.outfile, 'w')
37
38
40 """basic options setup sub classes can add more options here"""
41 ZCmdBase.buildOptions(self)
42 self.parser.add_option('-o', '--outfile',
43 dest="outfile",
44 help="output file for export default is stdout")
45 self.parser.add_option('--ignore', action="append",
46 dest="ignorerels", default=[],
47 help="relations that should be ignored can be many")
48
49
51 if not root:
52 root = self.dataroot
53 if hasattr(root, "exportXml"):
54 self.outfile.write("""<?xml version="1.0"?>\n""")
55 self.outfile.write("<objects>\n")
56 root.exportXml(self.outfile,self.options.ignorerels,True)
57 self.outfile.write("</objects>\n")
58 else:
59 print "ERROR: root object not a exportable (exportXml not found)"
60
61
62
63 if __name__ == '__main__':
64 ex = ExportRM()
65 ex.export()
66