This patch enables webUI Create-Retrieve-Updated-Delete-Search
operations for all api.Object plugins that:
1. implement all the required CRUDS methods
2. have a primary_key
Last night I realized that the upgrade to wehjit 0.2.0 broke the
installer, so I hurried this patch a bit, left out some niceties that
still need a bit more testing and tweaking.
From 073cea91cca082ec0f8d4d0644ff9db1961bfba9 Mon Sep 17 00:00:00 2001
From: Jason Gerard DeRose jder...@redhat.com
Date: Tue, 26 Jan 2010 06:39:00 -0700
Subject: [PATCH] Enabled CRUDS in webUI using wehjit 0.2.0
---
ipalib/plugable.py |2 +
ipalib/plugins/baseldap.py |7 +-
ipalib/plugins/user.py |3 +
ipaserver/rpcserver.py |3 +
ipawebui/engine.py | 124 +++---
ipawebui/widgets.py| 301 ++--
6 files changed, 241 insertions(+), 199 deletions(-)
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 3ee2bd5..ecccb79 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -531,6 +531,8 @@ class API(DictProxy):
value = getattr(options, key, None)
if value is not None:
overrides[key] = value
+if hasattr(options, 'prod'):
+overrides['webui_prod'] = options.prod
if context is not None:
overrides['context'] = context
self.bootstrap(**overrides)
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index 17db048..eeea7a6 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -133,6 +133,7 @@ class LDAPCreate(crud.Create):
Create a new entry in LDAP.
+
takes_options = (
Flag('raw',
cli_name='raw',
@@ -142,6 +143,7 @@ class LDAPCreate(crud.Create):
Flag('all',
cli_name='all',
doc='retrieve all attributes',
+exclude='webui',
),
Str('addattr*', validate_add_attribute,
cli_name='addattr',
@@ -291,14 +293,17 @@ class LDAPUpdate(LDAPQuery, crud.Update):
Update an LDAP entry.
+
takes_options = (
Flag('raw',
cli_name='raw',
doc='print entries as they are stored in LDAP',
+exclude='webui',
),
Flag('all',
cli_name='all',
doc='retrieve all attributes',
+exclude='webui',
),
Str('addattr*', validate_add_attribute,
cli_name='addattr',
@@ -456,6 +461,7 @@ class LDAPModMember(LDAPQuery):
Flag('raw',
cli_name='raw',
doc='print entries as they are stored in LDAP',
+exclude='webui',
),
)
@@ -751,4 +757,3 @@ class LDAPSearch(crud.Search):
def post_callback(self, ldap, entries, truncated, *args, **options):
pass
-
diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index 97641a4..1686d67 100644
--- a/ipalib/plugins/user.py
+++ b/ipalib/plugins/user.py
@@ -113,6 +113,9 @@ class user(LDAPObject):
cli_name='password',
label='Password',
doc='Set the user password',
+# FIXME: This is temporary till bug is fixed causing updates to
+# bomb out via the webUI.
+exclude='webui',
),
Int('uidnumber?',
cli_name='uid',
diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py
index a42c3d0..e84cb07 100644
--- a/ipaserver/rpcserver.py
+++ b/ipaserver/rpcserver.py
@@ -273,4 +273,7 @@ class jsonserver(WSGIExecutioner):
raise JSONError(
error='params[1] (aka options) must be a dict'
)
+options = dict((str(k), v) for (k, v) in options.iteritems())
+print 'args = %r' % (args,)
+print 'options = %r' % (options,)
return (method, args, options, _id)
diff --git a/ipawebui/engine.py b/ipawebui/engine.py
index a90a450..01b271a 100644
--- a/ipawebui/engine.py
+++ b/ipawebui/engine.py
@@ -65,7 +65,17 @@ class ParamMapper(object):
)
+def filter_params(namespace):
+for param in namespace():
+if param.exclude and 'webui' in param.exclude:
+continue
+yield param
+
+
class Engine(object):
+
+cruds = frozenset(['add', 'show', 'mod', 'del', 'find'])
+
def __init__(self, api, app):
self.api = api
self.app = app
@@ -86,11 +96,21 @@ class Engine(object):
)
def build(self):
-for cmd in self.api.Object.user.methods():
-self.pages[cmd.name] = self.build_page(cmd)
-for page in self.pages.itervalues():
-page.menu.label = 'Users'
-self.add_object_menuitems(page.menu, 'user')
+for obj in self.api.Object():
+if self.cruds.issubset(obj.methods) and obj.primary_key is not None:
+self.pages[obj.name] = self.build_cruds_page(obj)
+
+# Add landing page:
+