2021-12-12 Fred Gleason <fredg@paravelsystems.com>

* Added a 'SystemSettings()' type class to the 'rivwebpyapi' API.
	* Modified the 'rivwebpyapi.ListSystemSettings()' call to return
	a  'rivwebpyapi.SystemSettings' object.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2021-12-12 16:54:58 -05:00
parent 6b923ffbda
commit da9cb3eae3
3 changed files with 29 additions and 27 deletions

View File

@ -22779,3 +22779,7 @@
* Added a 'Service()' type class to the 'rivwebpyapi' API.
* Modified the 'rivwebpyapi.ListServices()' call to return
a list of 'rivwebpyapi.Service' objects.
2021-12-12 Fred Gleason <fredg@paravelsystems.com>
* Added a 'SystemSettings()' type class to the 'rivwebpyapi' API.
* Modified the 'rivwebpyapi.ListSystemSettings()' call to return
a 'rivwebpyapi.SystemSettings' object.

View File

@ -243,6 +243,19 @@ SERVICE_FIELDS={
'description': 'string'
}
SYSTEM_SETTINGS_FIELDS={
'realmName': 'string',
'sampleRate': 'integer',
'duplicateTitles': 'boolean',
'fixDuplicateTitles': 'boolean',
'maxPostLength': 'integer',
'isciXreferencePath': 'string',
'tempCartGroup': 'string',
'longDateFormat': 'string',
'shortDateFormat': 'string',
'showTwelveHourTime': 'boolean'
}
class RivWebPyApi_ListHandler(ContentHandler):
def __init__(self,base_tag,fields):
self.__output=[]
@ -450,6 +463,10 @@ class Service(RivendellType):
def __init__(self,values={}):
super().__init__(SERVICE_FIELDS,values)
class SystemSettings(RivendellType):
def __init__(self,values={}):
super().__init__(SYSTEM_SETTINGS_FIELDS,values)
class rivwebpyapi(object):
"""
Create a 'RivWebPyApi' object for accessing the Web API.
@ -1696,7 +1713,7 @@ class rivwebpyapi(object):
def ListSystemSettings(self):
"""
Returns Rivendell system settings (dictionary).
Returns Rivendell system settings (rivwebpyapi.SystemSettings object).
"""
#
@ -1718,22 +1735,11 @@ class rivwebpyapi(object):
#
# Generate the output dictionary
#
fields={
'realmName': 'string',
'sampleRate': 'integer',
'duplicateTitles': 'boolean',
'fixDuplicateTitles': 'boolean',
'maxPostLength': 'integer',
'isciXreferencePath': 'string',
'tempCartGroup': 'string',
'longDateFormat': 'string',
'shortDateFormat': 'string',
'showTwelveHourTime': 'boolean'
}
handler=RivWebPyApi_ListHandler(base_tag='systemSettings',fields=fields)
handler=RivWebPyApi_ListHandler(base_tag='systemSettings',
fields=SYSTEM_SETTINGS_FIELDS)
xml.sax.parseString(r.text,handler)
return handler.output()[0]
return SystemSettings(handler.output()[0])
def LockLog(self,log_name,operation,guid):
"""

View File

@ -59,7 +59,7 @@ if((not url)or(not username)):
#
webapi=rivwebpyapi.rivwebpyapi(url=url,username=username,password=password)
try:
setting=webapi.ListSystemSettings()
settings=webapi.ListSystemSettings()
except rivwebpyapi.RivWebPyError as err:
eprint('*** ERROR ***')
eprint('Response Code: '+str(err.responseCode))
@ -69,16 +69,8 @@ except rivwebpyapi.RivWebPyError as err:
sys.exit(1)
#
# Display the settings list
# Display the settings
#
print('realmName: '+str(setting['realmName']))
print('sampleRate: '+str(setting['sampleRate']))
print('duplicateTitles: '+str(setting['duplicateTitles']))
print('fixDuplicateTitles: '+str(setting['fixDuplicateTitles']))
print('maxPostLength: '+str(setting['maxPostLength']))
print('isciXreferencePath: '+str(setting['isciXreferencePath']))
print('tempCartGroup: '+str(setting['tempCartGroup']))
print('longDateFormat: '+str(setting['longDateFormat']))
print('shortDateFormat: '+str(setting['shortDateFormat']))
print('showTwelveHourTime: '+str(setting['showTwelveHourTime']))
for key in settings.values():
print(key+': '+str(settings.values()[key]))
print('')