1 # this somehow is not used anymore - should it not be ?
2 from django.core.context_processors import csrf
3 from django.http import HttpResponseRedirect
4 from django.contrib.auth import authenticate, login, logout
5 from django.template import RequestContext
6 from django.shortcuts import render_to_response
7 from django.shortcuts import render
9 from unfold.loginrequired import FreeAccessView
11 from manifold.core.query import Query
12 from manifoldapi.manifoldapi import execute_query
13 from manifoldapi.manifoldresult import ManifoldResult
14 from ui.topmenu import topmenu_items, the_user
15 from myslice.configengine import ConfigEngine
17 from myslice.theme import ThemeView
19 class ExperimentView (FreeAccessView, ThemeView):
20 template_name = 'slice-tab-experiment.html'
22 def get (self, request, slicename, state=None):
24 username = self.request.user
26 split_slicename = slicename.split('.')
27 ple_slicename = split_slicename[0] + '8' + split_slicename[1] + '_' + split_slicename[2]
29 query_current_resources = Query.get('slice').select('resource').filter_by('slice_hrn','==',slicename)
30 current_resources = execute_query(request, query_current_resources)
32 formatted_resource_list=[]
34 for resources in current_resources:
35 list_res = resources['resource']
37 split_list = res.split('+') # split the resource urn
38 if [s for s in split_list if 'ple' in s]: # search only ple resources
39 res_hrn = split_list[-1] # last element is resource hrn
40 formatted_resource_list.append(res_hrn)
42 print "Exception in slicetabexperiment.py in ple resource search %s" % e
44 print "list of ple resource hrns"
45 print formatted_resource_list
47 return render_to_response(self.template, { 'theme' : self.theme,'slicename':slicename, 'ple_slicename':ple_slicename, 'username':username, 'ple_resources':formatted_resource_list }, context_instance=RequestContext(request))