~ubuntu-branches/ubuntu/hardy/gnue-common/hardy

« back to all changes in this revision

Viewing changes to src/rpc/parser/Parser.py

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-03-09 11:06:31 UTC
  • Revision ID: james.westby@ubuntu.com-20050309110631-8gvvn39q7tjz1kj6
Tags: upstream-0.5.14
ImportĀ upstreamĀ versionĀ 0.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# This file is part of GNU Enterprise.
 
3
#
 
4
# GNU Enterprise is free software; you can redistribute it
 
5
# and/or modify it under the terms of the GNU General Public
 
6
# License as published by the Free Software Foundation; either
 
7
# version 2, or (at your option) any later version.
 
8
#
 
9
# GNU Enterprise is distributed in the hope that it will be
 
10
# useful, but WITHOUT ANY WARRANTY; without even the implied
 
11
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 
12
# PURPOSE. See the GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public
 
15
# License along with program; see the file COPYING. If not,
 
16
# write to the Free Software Foundation, Inc., 59 Temple Place
 
17
# - Suite 330, Boston, MA 02111-1307, USA.
 
18
#
 
19
# Copyright 2001-2005 Free Software Foundation
 
20
#
 
21
# FILE:
 
22
# Parser.py
 
23
#
 
24
# DESCRIPTION:
 
25
# Class that implements the GParser XML parser framework for GNUe RPC.
 
26
#
 
27
# NOTES:
 
28
#
 
29
 
 
30
 
 
31
from gnue.common.definitions import GParser
 
32
 
 
33
import copy, types
 
34
from gnue.common.formatting import GTypecast
 
35
 
 
36
 
 
37
 
 
38
 
 
39
 
 
40
 
 
41
########
 
42
########  Please keep this file neat !!!
 
43
########
 
44
 
 
45
 
 
46
 
 
47
 
 
48
 
 
49
 
 
50
#######################################################
 
51
# This method loads a form from an XML file and returns
 
52
# a GFForm object.  If initialize is 1 (default), then
 
53
# the form is initialized and ready to go.
 
54
#
 
55
# (initialize=0 is currently not used -- will probably
 
56
#  be used in the Forms Designer package where we will
 
57
#  not want the loaded form to connect to databases, etc)
 
58
#######################################################
 
59
 
 
60
def loadDefinition(URL, initialize=0):
 
61
  return GParser.loadXMLObject (URL, xmlHandler, "RpGnuRpc", 'gnurpc',
 
62
           initialize, attributes={})
 
63
 
 
64
 
 
65
xmlElements = None
 
66
 
 
67
 
 
68
def getXMLelements():
 
69
 
 
70
  global xmlElements
 
71
 
 
72
  if xmlElements == None:
 
73
    import Objects
 
74
 
 
75
    xmlElements = {
 
76
      'gnurpc': {
 
77
         'BaseClass': Objects.GnuRpc,
 
78
         'Required': 1,
 
79
#         'SingleInstance': 1,
 
80
         'ParentTags': None },
 
81
 
 
82
      'service': {
 
83
         'BaseClass': Objects.RpcService,
 
84
         'Required': 1,
 
85
         'Attributes': {
 
86
            'name': {
 
87
               'Typecast': GTypecast.name,
 
88
               'Required': 1 },
 
89
            'binding': {
 
90
               'Typecast': GTypecast.name }, 
 
91
            'helptext': {
 
92
               'Typecast': GTypecast.name } },
 
93
         'ParentTags': ('gnurpc','service') },
 
94
 
 
95
      'method': {
 
96
         'BaseClass': Objects.RpcMethod,
 
97
         'Required': 1,
 
98
#         'SingleInstance': 1,
 
99
         'Attributes': {
 
100
            'name': {
 
101
               'Typecast': GTypecast.name,
 
102
               'Required': 1 },
 
103
            'return': {
 
104
               'Typecast': GTypecast.name },
 
105
            'helptext': {
 
106
               'Typecast': GTypecast.name } },
 
107
         'ParentTags': ('gnurpc','service','object') },
 
108
 
 
109
      'object': {
 
110
         'BaseClass': Objects.RpcObject,
 
111
#         'SingleInstance': 1,
 
112
         'Attributes': {
 
113
            'name': {
 
114
               'Typecast': GTypecast.name,
 
115
               'Required': 1 },
 
116
            'helptext': {
 
117
               'Typecast': GTypecast.name }}, 
 
118
         'ParentTags': ('gnurpc','service') },
 
119
 
 
120
      'argument': {
 
121
         'BaseClass': Objects.RpcArgument,
 
122
         'Attributes': {
 
123
            'name': {
 
124
               'Typecast': GTypecast.name,
 
125
               'Required': 1 },
 
126
            'type': {
 
127
               'Typecast': GTypecast.name,
 
128
               'Required': 1 },
 
129
            'default': {
 
130
               'Typecast': GTypecast.text },
 
131
            'helptext': {
 
132
               'Typecast': GTypecast.name } },
 
133
         'ParentTags': ('method',) },
 
134
 
 
135
      'attribute': {
 
136
         'BaseClass': Objects.RpcAttribute,
 
137
         'Attributes': {
 
138
            'name': {
 
139
               'Typecast': GTypecast.name,
 
140
               'Required': 1 },
 
141
            'type': {
 
142
               'Typecast': GTypecast.name,
 
143
               'Required': 1 },
 
144
            'readonly': {
 
145
               'Typecast': GTypecast.boolean,
 
146
               'Default': 0 },
 
147
            'writeonly': {
 
148
               'Typecast': GTypecast.boolean,
 
149
               'Default': 0 },
 
150
            'helptext': {
 
151
               'Typecast': GTypecast.name }  },
 
152
         'ParentTags': ('object',) },
 
153
 
 
154
      'exception': {
 
155
         'BaseClass': Objects.RpcException,
 
156
         'Attributes': {
 
157
            'name': {
 
158
               'Typecast': GTypecast.name,
 
159
               'Required': 1 },
 
160
            'helptext': {
 
161
               'Typecast': GTypecast.name }  },
 
162
         'ParentTags': ('gnurpc','service') },
 
163
 
 
164
      'raises': {
 
165
         'BaseClass': Objects.RpcRaises,
 
166
         'Attributes': {
 
167
            'name': {
 
168
               'References': (('exception','name'),),
 
169
               'Typecast': GTypecast.name,
 
170
               'Required': 1 } },
 
171
         'ParentTags': ('gnurpc','service') },
 
172
    }
 
173
 
 
174
 
 
175
  return xmlElements
 
176
 
 
177
 
 
178
#######################################################
 
179
#
 
180
# xmlHandler
 
181
#
 
182
# This class is called by the XML parser to
 
183
# process the xml file.
 
184
#
 
185
#######################################################
 
186
 
 
187
class xmlHandler (GParser.xmlHandler):
 
188
  def __init__(self):
 
189
 
 
190
    GParser.xmlHandler.__init__(self)
 
191
 
 
192
    self.xmlElements = getXMLelements()
 
193
 
 
194