print "ok"
if not sessions:
print "GetSession failed", sessions_result.error()
- print "first"
+ return
+ print "first", sessions
session = sessions[0]
print "SESSION=", session
request.session['manifold'] = {'auth': api.auth, 'person': person, 'expires': session['expires']}
except Exception, e:
print "E: manifoldbackend", e
+ import traceback
+ traceback.print_exc()
return None
try:
def __init__(self, **kwargs):
- print "KWARGS=", kwargs
# Checks
given = set(kwargs.keys())
- print "given=", given
cstr_success = set(['code', 'origin', 'value']) <= given
cstr_error = set(['code', 'type', 'origin', 'description']) <= given
assert given <= self.ALLOWED_FIELDS, "Wrong fields in ResultValue constructor: %r" % (given - self.ALLOWED_FIELDS)
def ok_value(self):
return self['value']
+ def error(self):
+ err = "%r" % self['description']
+
@staticmethod
def to_html (raw_dict):
return pprint.pformat (raw_dict).replace("\\n","<br/>")
return ResultValue(**result)
except Exception,error:
+ # XXX Connection refused for example
+ print "** API ERROR **"
+ import traceback
+ traceback.print_exc()
if debug: print "KO (unexpected exception)",error
raise ManifoldException ( ManifoldResult (code=ManifoldCode.UNKNOWN_ERROR, output="%s"%error) )
result = manifold_api.forward(manifold_query.to_dict())
# XXX TEMP HACK
- result [ 'description' ] = [ ResultValue.to_html (x) for x in result['description'] ]
+ if 'description' in result and result['description'] and isinstance(result['description'], (tuple, list, set, frozenset)):
+ result [ 'description' ] = [ ResultValue.to_html (x) for x in result['description'] ]
json_answer=json.dumps(result)
# if in debug mode we save this so we can use offline mode later
return HttpResponse (json_answer, mimetype="application/json")
except:
+ print "** PROXY ERROR **"
import traceback
traceback.print_exc()
def topmenu_items (current,request=None):
result=deepcopy(standard_topmenu_items)
+ has_user=request.user.is_authenticated()
+ if has_user:
+ result.append({ 'label':'Request a slice', 'href': '/portal/slice/request/'})
for d in result:
- if d['label'].lower().find(current)>=0: d['is_active']=True
+ #if d['label'].lower()find(current)>=0: d['is_active']=True
+ if d['label'] == current: d['is_active']=True
+ print "CURRENT=", current
if not request: return result
- has_user=request.user.is_authenticated()
# result.append (login_out_items [ has_user] )
return result
GoogleMap : GoogleMap
});
+ /* Events */
+ $this.on('show.GoogleMaps', methods.show);
+
+
/* Subscribe to query updates */
jQuery.subscribe('/results/' + options.query_uuid + '/changed', {instance: $this}, update_map);
jQuery.subscribe('/update-set/' + options.query_uuid, {instance: $this}, on_resource_changed);
class Tabs (Composite):
def requirements (self):
- return { 'js_files' : 'js/bootstrap.js',
+ return { 'js_files' : ['js/tabs.js', 'js/bootstrap.js'],
'css_files' : ['css/bootstrap.css', 'css/tabs.css', ]
}
# see Composite.py for the details of template_env, that exposes global
# 'sons' as a list of sons with each a set of a few attributes
+ def json_settings_list (self):
+ return []
+
+ def export_json_settings(self):
+ return True
# Slow...
#slice_query = Query().get('slice').filter_by('user.user_hrn', 'contains', user_hrn).select('slice_hrn')
- slice_query = Query().get('user').filter_by('user_hrn', '==', user_hrn).select('slice.slice_hrn')
+ slice_query = Query().get('user').filter_by('user_hrn', '==', user_hrn).select('user_hrn', 'slice.slice_hrn')
auth_query = Query().get('network').select('network_hrn')
page.enqueue_query(slice_query)
page.enqueue_query(auth_query)
# more general variables expected in the template
context['title'] = 'Test view that combines various plugins'
# the menu items on the top
- context['topmenu_items'] = topmenu_items('dashboard', self.request)
+ context['topmenu_items'] = topmenu_items('Dashboard', self.request)
# so we can sho who is logged
context['username'] = the_user(self.request)
main_query.select(
'slice_hrn',
'resource.resource_hrn', 'resource.hostname', 'resource.type', 'resource.authority',
- 'lease.urn',
+ #'lease.urn',
'user.user_hrn',
# 'application.measurement_point.counter'
)
# more general variables expected in the template
template_env [ 'title' ] = 'Test view that combines various plugins'
# the menu items on the top
- template_env [ 'topmenu_items' ] = topmenu_items('slice', request)
+ template_env [ 'topmenu_items' ] = topmenu_items('Slice', request)
# so we can sho who is logged
template_env [ 'username' ] = the_user (request)