Skip to content

Commit

Permalink
json/admin/config/Plugin/Section displays option dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
greghaynes committed May 28, 2010
1 parent ddc7178 commit f1dcde3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/pyscripts/plugins/JSONAPI/admin/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from xsbs.http.jsonapi import JsonAdminSite
from xsbs.settings import pluginNames, pluginSections, sectionOptions, setOption
from xsbs.settings import pluginNames, pluginSections, sectionOptionValues, setOption

try:
import json
Expand All @@ -23,11 +23,15 @@ def __init__(self, plugin_name, section_name):
JsonAdminSite.__init__(self)
self.plugin_name = plugin_name
self.section_name = section_name
optvals = sectionOptionValues(plugin_name, section_name)
self.options = {}
for option, value in optvals:
self.options[option] = value
def render_admin_JSON(self, request, user):
return json.dumps({
'plugin': self.plugin_name,
'section': self.section_name,
'options': sectionOptions(self.plugin_name, self.section_name)
'options': self.options
})

class ConfigSite(JsonAdminSite):
Expand Down
5 changes: 2 additions & 3 deletions src/pyscripts/xsbs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ def pluginNames():
def pluginSections(plugin_name):
return remove_dups(strip_arr(session.query(ConfigOption.section).filter_by(plugin=plugin_name)))

def sectionOptions(plugin_name, section):

return remove_dups(strip_arr(session.query(ConfigOption.section).filter_by(plugin=plugin_name).filter_by(section=section)))
def sectionOptionValues(plugin_name, section):
return session.query(ConfigOption.name, ConfigOption.value).filter_by(plugin=plugin_name).filter_by(section=section)

def setOption(plugin_name, section, option, value):
pass
Expand Down

0 comments on commit f1dcde3

Please sign in to comment.