| 1 | ################################################################################
|
|---|
| 2 | # _enummanager.py
|
|---|
| 3 | #
|
|---|
| 4 | # This program is free software; you can redistribute it and/or
|
|---|
| 5 | # modify it under the terms of the GNU General Public License
|
|---|
| 6 | # as published by the Free Software Foundation; either version 2
|
|---|
| 7 | # of the License, or (at your option) any later version.
|
|---|
| 8 | #
|
|---|
| 9 | # This program is distributed in the hope that it will be useful,
|
|---|
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | # GNU General Public License for more details.
|
|---|
| 13 | #
|
|---|
| 14 | # You should have received a copy of the GNU General Public License
|
|---|
| 15 | # along with this program; if not, write to the Free Software
|
|---|
| 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|---|
| 17 | ################################################################################
|
|---|
| 18 |
|
|---|
| 19 | # Imports.
|
|---|
| 20 | from App.Common import package_home
|
|---|
| 21 | # Product Imports.
|
|---|
| 22 | import _xmllib
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 | ################################################################################
|
|---|
| 26 | ################################################################################
|
|---|
| 27 | ###
|
|---|
| 28 | ### class EnumManager
|
|---|
| 29 | ###
|
|---|
| 30 | ################################################################################
|
|---|
| 31 | ################################################################################
|
|---|
| 32 | class EnumManager:
|
|---|
| 33 |
|
|---|
| 34 | # ----------------------------------------------------------------------------
|
|---|
| 35 | # EnumManager.__init__:
|
|---|
| 36 | #
|
|---|
| 37 | # Constructor
|
|---|
| 38 | # ----------------------------------------------------------------------------
|
|---|
| 39 | def __init__(self):
|
|---|
| 40 | pass
|
|---|
| 41 |
|
|---|
| 42 | # ----------------------------------------------------------------------------
|
|---|
| 43 | # EnumManager.getValues:
|
|---|
| 44 | #
|
|---|
| 45 | # Returns values for enumeration specified by Id.
|
|---|
| 46 | # ----------------------------------------------------------------------------
|
|---|
| 47 | getValues__roles__ = None
|
|---|
| 48 | def getValues(self, id, path=None):
|
|---|
| 49 | if path is None:
|
|---|
| 50 | path = package_home(globals())+'/import/'
|
|---|
| 51 | filename = path + 'enum.%s.xml'%id
|
|---|
| 52 | xml = open(filename)
|
|---|
| 53 | builder = _xmllib.XmlAttrBuilder()
|
|---|
| 54 | v = builder.parse(xml)
|
|---|
| 55 | xml.close()
|
|---|
| 56 | if type(v) is dict:
|
|---|
| 57 | l = map(lambda x: (v[x], x), v.keys())
|
|---|
| 58 | l.sort()
|
|---|
| 59 | v = []
|
|---|
| 60 | for i in l:
|
|---|
| 61 | v.append([i[1],i[0]])
|
|---|
| 62 | return v
|
|---|
| 63 |
|
|---|
| 64 | ################################################################################
|
|---|