[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, master, updated. 016db4e7560fc8ef5ccdb6357745ef691650d94a
Naparuba
naparuba at gmail.com
Wed Nov 16 10:03:11 UTC 2011
The following commit has been merged in the master branch:
commit 1ec01bd9c41774ba0fba697c4a64667a66b4df7b
Author: Naparuba <naparuba at gmail.com>
Date: Mon Nov 14 11:44:32 2011 +0100
Add : comments in the dummy webui plugin.
diff --git a/shinken/webui/plugins/dummy/dummy.py b/shinken/webui/plugins/dummy/dummy.py
index 580d507..a5d4a3a 100644
--- a/shinken/webui/plugins/dummy/dummy.py
+++ b/shinken/webui/plugins/dummy/dummy.py
@@ -1,19 +1,60 @@
+#!/usr/bin/env python
+#Copyright (C) 2009-2011 :
+# Gabes Jean, naparuba at gmail.com
+# Gerhard Lausser, Gerhard.Lausser at consol.de
+# Gregory Starck, g.starck at gmail.com
+# Hartmut Goebel, h.goebel at goebel-consult.de
+# Andreas Karfusehr, andreas at karfusehr.de
+#
+#This file is part of Shinken.
+#
+#Shinken is free software: you can redistribute it and/or modify
+#it under the terms of the GNU Affero General Public License as published by
+#the Free Software Foundation, either version 3 of the License, or
+#(at your option) any later version.
+#
+#Shinken is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#GNU Affero General Public License for more details.
+#
+#You should have received a copy of the GNU Affero General Public License
+#along with Shinken. If not, see <http://www.gnu.org/licenses/>.
+
+
+from shinken.webui.bottle import redirect
+
### Will be populated by the UI with it's own value
app = None
-# Our page
+# Our page. If the useer call /dummy/TOTO arg1 will be TOTO.
+# if it's /dummy/, it will be 'nothing'
def get_page(arg1='nothing'):
- return get_data(arg1)
-
-
-
-def get_data(arg1):
+ # First we look for the user sid
+ # so we bail out if it's a false one
user = app.get_user_auth()
+ if not user:
+ redirect("/user/login")
+ return
- return {'host_name' : arg1, 'valid_user' : True, 'user' : user}
+ # Here we can call app.datamgr beause when the webui "loaded" us, it
+ # populated app with it's own value.
+ my_host = app.datamgr.get_host(arg1)
+ # we return values for the template (view). But beware, theses values are the
+ # only one the tempalte will have, so we must give it an app link and the
+ # user we are loggued with (it's a contact object in fact)
+ return {'app' : app, 'user' : user, 'host' : my_host}
+# This is the dict teh webui will try to "load".
+# *here we register one page with both adresses /dummy/:arg1 and /dummy/, both addresses
+# will call the function get_page.
+# * we say taht for this page, we are using the template file dummy (so view/dummy.tpl)
+# * we said this page got some static stuffs. So the webui will match /static/dummy/ to
+# the dummy/htdocs/ directory. Bewere : it will take the plugin name to match.
+# * optional : you can add 'method' : 'POST' so this adress will be only available for
+# POST calls. By default it's GET. Look at the lookup module for sample about this.
pages = {get_page : { 'routes' : ['/dummy/:arg1', '/dummy/'], 'view' : 'dummy', 'static' : True}}
--
UNNAMED PROJECT
More information about the Pkg-nagios-changes
mailing list