Changeset 4724
- Timestamp:
- 05/01/09 09:51:50 (12 years ago)
- Location:
- MILK/trunk/milk_server/milk_server
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
MILK/trunk/milk_server/milk_server/config/milkMiddleware.py
r4625 r4724 161 161 # extend the granulite example link - to add a valid location 162 162 g.example_granulite = g.example_granulite.replace('HREF', \ 163 h.url_for(controller = 'atom_editor/listatom', \ 164 action='showExampleGranulite')) 163 h.url_for('example')) 165 164 166 165 -
MILK/trunk/milk_server/milk_server/controllers/atom_editor/editatom.py
r4697 r4724 5 5 @author: C Byrom, Tessella Sep 2008 6 6 ''' 7 import logging, traceback, sys, cgi, xmlrpclib 8 from paste.request import parse_querystring 7 import logging, traceback, sys, cgi 9 8 from xml.parsers.expat import ExpatError 10 9 from formencode import Invalid … … 14 13 from milk_server.models.form import * 15 14 from milk_server.lib import mailer 16 from milk_server.lib.ndgInterface import ndgInterface17 15 import milk_server.lib.htmlUtilities as utils 18 from milk_server.lib.atomutilities import savePageAndRender19 from ndgUtils import ndgObject20 16 from ndgUtils.models.Atom import Atom, Person, Link, Category 21 from ndgUtils.eXistConnector import eXistConnector22 17 from ndgUtils.lib.atomvalidator import ValidationError 23 18 import ndgUtils.lib.existdbclient as edc … … 27 22 from ndgUtils.lib.granulite import granulite 28 23 from editorconstants import * 29 30 class EditatomController(BaseController): 24 from atomeditorcontroller import AtomEditorController 25 26 class EditatomController(AtomEditorController): 31 27 ''' 32 28 Provides the pylons controller for editing NDG Atom documents. 33 29 ''' 34 ADD_ASSOCIATIONS = 335 REMOVE_ASSOCIATIONS = 436 37 def __setup(self,uri=None):38 ''' Common setup stuff for all the actions on this controller '''39 logging.info("Setting up EditatomController")40 self.cf=request.environ['ndgConfig']41 42 if uri:43 try:44 self.ndgObject = ndgObject(uri, config=self.cf)45 except ValueError,e:46 return e47 48 self.inputs=dict(parse_querystring(request.environ))49 50 logging.info("EditatomController set up")51 return 052 53 54 def __unpackErrors(self, e):55 '''56 Add exception errors to the common error structures - for use57 in templates58 @param e: Exception to add59 '''60 errorMessage = e.message61 if g.debugAtomEditor:62 errorMessage = traceback.format_exc()63 64 c.xml = escapeSpecialCharacters('Unexpected error loading page [%s]' \65 %str(errorMessage))66 c.doc = ''67 68 # unpack errors, if possible - NB, the c.errors value is used by the template69 # function, displayErrors, which is used by most of the editor templates70 if isinstance(e, xmlrpclib.Fault):71 # strip out the exception type - NB, this is usually native library code72 # and is of no real interest - and will just confuse viewers73 c.errors['Unexpected error'] = e.faultString.split(':')[-1]74 if hasattr(e, 'unpack_errors'):75 c.errors.update(e.unpack_errors())76 77 else:78 c.errors['Unexpected error'] = [c.xml]79 80 # tidy up errors - escaping any xml tags, if necessary81 for key, errors in c.errors.items():82 newErrors = []83 for error in errors:84 for err in error.split('<br/>'):85 newErrors.append(escapeSpecialCharacters(err))86 c.errors[key] = newErrors87 88 89 def __handleError(self, e, template='atom_editor/error'):90 '''91 Handle exceptions thrown; if debug mode on, display full stack trace92 in output, otherwise just show basic error message in error template93 @param e: Exception to process94 @keyword template: template to render - 'error' is the default - NB, if95 an alternative is specified it should have a div with class set to 'error'96 containing the variable, c.xml to display properly97 '''98 self.__unpackErrors(e)99 logging.error(c.xml)100 response.status_code = 400101 return render("genshi", template)102 103 104 30 def upload(self, uri): 105 31 ''' … … 110 36 ''' 111 37 logging.info("Uploading file...") 112 self.__setup(uri=uri) 113 inputs = self.__getTidyInputs() 38 self._setup(uri=uri) 114 39 115 40 granFile = request.POST.get('upload_granulite') … … 117 42 118 43 # check whether we can replace existing atoms 119 replaceAtom = inputs.get('replaceAtom')44 replaceAtom = self.inputs.get('replaceAtom') 120 45 121 46 # NB, need to turn from string to boolean - there doesn't seem a reliable … … 146 71 logging.info("Validating inputs") 147 72 validator = LoadGranuliteFormSchema() 148 validator.to_python( inputs)73 validator.to_python(self.inputs) 149 74 logging.info("- inputs valid") 150 75 151 76 useCSMLID = True 152 c.atom = None153 77 if uri: 154 self.prepareDataModel(uri)155 78 useCSMLID = False 156 79 … … 171 94 # data or just the CSML/CDML data 172 95 # NB, we'll be creating the atom in the default local eXist 173 eXistClient = self._ _getExistClient('local')96 eXistClient = self._getExistClient('local') 174 97 gran = granulite(fileContents, granuleAtom = c.atom, \ 175 98 eXistClient = eXistClient, \ 176 99 csmlOrCdmlFile = csmlOrCdmlFile, \ 177 timeAxis = inputs.get('timeAxis'), \178 datasetID = inputs.get('datasetID'), \100 timeAxis = self.inputs.get('timeAxis'), \ 101 datasetID = self.inputs.get('datasetID'), \ 179 102 useCSMLID = useCSMLID, \ 180 103 replaceAtom = replaceAtom) … … 192 115 193 116 # Now set up the ndgObject with the created atom's vals 194 self._ _setup(uri=c.atom.ndgURI)117 self._setup(uri=c.atom.ndgURI, loadAtom = False) 195 118 c.atom.ndgObject = self.ndgObject 196 119 except edc.DuplicateError, e: … … 227 150 except Exception, e: 228 151 c.errors['WARNING'] = ['Error loading data: the displayed data will not be saved - please fix problem and retry'] 229 self._ _unpackErrors(e)152 self._unpackErrors(e) 230 153 except SystemExit, ee: 231 154 # NB, some of the CSML libraries just sys.exit on problems - catch errors here 232 155 c.errors['ERROR'] = ['Problem encountered whilst transforming the CDML data into CSML'] 233 self._ _unpackErrors(ee)156 self._unpackErrors(ee) 234 157 235 158 if c.atom and hasattr(c.atom, 'ndgURI'): 236 159 self.pathInfo = self.pathInfo.replace('upload', 'editAtom') 237 return self.edit(c.atom.ndgURI) 160 161 h.redirect_to(h.url_for('edit', uri = c.atom.ndgURI)) 238 162 elif uri: 239 163 # something has gone wrong here... 240 164 return render("genshi", 'atom_editor/error') 241 165 else: 242 return self.createGranule(**inputs) 243 244 245 def __getTidyInputs(self): 246 ''' 247 The inputs can be used generically to specify atom attributes - however 248 some inputs should not be set against the Atom object since they use slots 249 so cannot be pickled - which means saving the atom in the session with fail. 250 This method clears out any unwanted inputs 251 ''' 252 logging.debug("Getting pickleable input data") 253 inputs = request.params 254 tidyInputs = {} 255 for key, val in inputs.items(): 256 if not isinstance(val, cgi.FieldStorage): 257 tidyInputs[key] = val 258 logging.debug("Pickleable data extracted") 259 return tidyInputs 166 return self.createGranule(**self.inputs) 260 167 261 168 … … 269 176 c.errors = {} 270 177 try: 271 self.prepareDataModel(uri) 272 except SystemError, e: 273 return self.__handleError(e) 274 275 inputs = request.params 276 178 self._setup(uri) 179 except Exception, e: 180 return self._handleError(e) 181 277 182 # save atom association changes 278 183 if int(saveLevel) == self.ADD_ASSOCIATIONS: 279 atomLinks = self.extractAtomAssociations( inputs)184 atomLinks = self.extractAtomAssociations(self.inputs) 280 185 c.atom.addUniqueRelatedLinks(atomLinks) 281 186 elif int(saveLevel) == self.REMOVE_ASSOCIATIONS: 282 atomLinks = self.extractAtomAssociations( inputs)187 atomLinks = self.extractAtomAssociations(self.inputs) 283 188 c.atom.removeRelatedLinks(atomLinks) 284 189 else: 285 authors = self.extractAuthorDetails( inputs)190 authors = self.extractAuthorDetails(self.inputs) 286 191 c.atom.addAuthors(authors) 287 192 288 onlineRefs = self.extractOnlineReferenceDetails( inputs)193 onlineRefs = self.extractOnlineReferenceDetails(self.inputs) 289 194 c.atom.addOnlineReferences(onlineRefs) 290 195 291 params = self.extractParameterDetails( inputs)196 params = self.extractParameterDetails(self.inputs) 292 197 # NB, the atom type and subtype are added to the categories when the 293 198 # atom is exported to XML - so don't need to worry about overwriting … … 295 200 c.atom.parameters = params 296 201 297 if inputs.get('subtype'):202 if self.inputs.get('subtype'): 298 203 c.atom.subtype = self.getLatestTermURLFromDropDownInput( \ 299 inputs.get('subtype'))204 self.inputs.get('subtype')) 300 205 c.atom.subtypeID = c.atom.subtype.split('/')[-1] 301 206 … … 308 213 self.saveAtomToExist(c.atom) 309 214 except Exception, e: 310 self._ _unpackErrors(e)215 self._unpackErrors(e) 311 216 logging.info("- input invalid") 312 217 return self.edit(uri) … … 314 219 # now do redirection - NB, this ensures that current atom contents are 315 220 # reloaded and displayed 316 h.redirect_to(controller = 'atom_editor/editatom', action='edit', \ 317 uri = c.atom.ndgURI) 318 319 320 def prepareDataModel(self, uri): 321 ''' 322 Set up the underlying atom data model - loading the bulk from eXist 323 then updating any input fields appropriately 324 ''' 325 logging.info("Preparing underlying data model") 326 status=self.__setup(uri=uri) 327 if status: 328 c.xml='<p>%s</p>'%status 329 response.status_code = 400 330 raise SystemError('Problem experienced setting up data model') 331 332 logging.info("Retrieving document to edit") 333 # NB, don't use the cache as docs are likely to change 334 # quite a lot during editing; ensure you've always got 335 # the latest updates loaded 336 interface = ndgInterface() 337 status,x = interface.GetXML(uri, useCache=False) 338 339 if not status: 340 code=400 341 if x.startswith('<p> Access Denied'): 342 code=401 343 344 c.xml='%s'%x 345 response.status_code = code 346 raise SystemError('Problem experienced retrieving atom doc from eXist') 347 348 # NB, passing in the inputs will overwrite any original values with the 349 # user input ones 350 inputs = self.__getTidyInputs() 351 352 c.atom = Atom(xmlString=str(x), ndgObject = self.ndgObject, **dict(inputs)) 353 354 # save the current atom - to avoid this needing be recreated by the 355 # asynch viewAssociatedData call 356 session['currentAtom'] = c.atom 357 session.save() 358 logging.info("Data model set up") 221 h.redirect_to(h.url_for(controller = 'atom_editor/editatom', action='edit', \ 222 uri = c.atom.ndgURI)) 359 223 360 224 … … 370 234 # - in this case keep original data 371 235 if not c.atom: 372 self. prepareDataModel(uri)236 self._setup(uri) 373 237 374 238 c.title= EDIT_TITLE %c.atom.ndgURI 375 239 c.uri = c.atom.ndgURI 376 240 377 c.saveLink = h.url_for(controller='atom_editor/editatom',action='saveAtom', \ 378 saveLevel='1', uri = c.atom.ndgURI) 379 c.saveLink2 = h.url_for(controller='atom_editor/editatom',action='saveAtom', saveLevel='2') 380 c.saveAssoc = h.url_for(controller='atom_editor/editatom',action='saveAtom', \ 381 saveLevel = self.REMOVE_ASSOCIATIONS) 382 c.deploymentsURL = h.url_for(controller='browse/retrieve', \ 383 action='viewAssociatedData', \ 384 type = VTD.DEPLOYMENT_TERM, \ 241 c.saveLink = h.url_for('save', saveLevel = self.STANDARD_SAVE, uri = c.atom.ndgURI) 242 c.saveAssoc = h.url_for('save', saveLevel = self.REMOVE_ASSOCIATIONS, uri = c.atom.ndgURI) 243 c.deploymentsURL = h.url_for('view', type = VTD.DEPLOYMENT_TERM, \ 385 244 uri = c.atom.ndgURI) 386 c.dataEntitiesURL = h.url_for(controller='browse/retrieve', \ 387 action='viewAssociatedData', \ 388 type = VTD.DE_TERM, \ 245 c.dataEntitiesURL = h.url_for('view', type = VTD.DE_TERM, \ 389 246 uri = c.atom.ndgURI) 390 247 … … 395 252 atomType = g.vtd.DEPLOYMENT_TERM 396 253 397 c.addEntityLink = h.url_for( controller='atom_editor/listatom',action='list', searchData = '0', \254 c.addEntityLink = h.url_for('list', searchData = '0', \ 398 255 associatedAtomID = c.atom.ndgURI, \ 399 256 associatedAtomType = atomType, 400 257 associationType = utils.ENTITY_ASSOCIATION) 401 258 402 c.addGranuleLink = h.url_for( controller='atom_editor/listatom',action='list', searchData = '0', \259 c.addGranuleLink = h.url_for('list', searchData = '0', \ 403 260 associatedAtomID = c.atom.ndgURI, \ 404 261 associatedAtomType = atomType, 405 262 associationType = utils.GRANULE_ASSOCIATION) 406 263 407 c.addDeploymentLink = h.url_for( controller='atom_editor/listatom',action='list', searchData = '0', \264 c.addDeploymentLink = h.url_for('list', searchData = '0', \ 408 265 associatedAtomID = c.atom.ndgURI, \ 409 266 associatedAtomType = atomType, … … 417 274 c.subTypes = utils.getVocabTermDataDropdown(listVals, \ 418 275 selected=c.atom.subtype) 419 276 self.__setDropDownSelectVal('subtype', c.atom.subtype, listVals) 420 277 self.addRelatedLinksDropDowns() 278 279 280 def __setDropDownSelectVal(self, name, val, vtds): 281 ''' 282 Given a list of vocab terms, with the name of a 'select' tag and the selected 283 value, set the proper value in the inputs dict to allow htmlfill to correctly 284 display the list 285 @param name: name of select element to set the select value of 286 @param val: value of the selected item - NB, this need not be the current vocab 287 term url - but should start with the main stem and end with the termID 288 @param vtds: list of vocab term definition objects 289 ''' 290 if not val: 291 return 292 for vtd in vtds: 293 if val.endswith(vtd.termID) and \ 294 val.startswith(vtd.vocabURL): 295 self.inputs[name] = utils.getVocabTermDataSelectValue(vtd) 296 return 297 421 298 422 299 … … 430 307 try: 431 308 logging.info("Deleting atom, '%s'" %uri) 432 self. prepareDataModel(uri)433 eXistClient = self._ _getExistClient('local')309 self._setup(uri) 310 eXistClient = self._getExistClient('local') 434 311 gran = granulite(None, granuleAtom = c.atom, \ 435 312 eXistClient = eXistClient, \ … … 437 314 438 315 gran.deleteGranuleAndDEReferences() 439 raise Exception('blah')440 316 c.deleteResult = "Atom deleted successfully." 441 317 logging.info("- atom deleted") … … 451 327 def edit(self, uri): 452 328 ''' 453 Edit the specifieduri329 Edit the atom with the specified ndg uri 454 330 ''' 455 331 logging.info("Setting up atom edit template") 456 332 try: 457 333 self.prepareEditForm(uri) 458 return savePageAndRender(self.pathInfo, "atom_editor/atom_editor") 334 335 # NB, there appears to be a bug in htmlfill which automagically 336 # clears out content from textarea - so need to set the content 337 # explicitly for htmlfill to use 338 self.inputs['Content'] = c.atom.Content 339 self.inputs['Summary'] = c.atom.Summary 340 return self.savePageAndRender("atom_editor/atom_editor", **self.inputs) 459 341 460 342 except ExpatError, e: … … 463 345 logging.error("Error retrieving [%s] - XML content: %s" % (uri, e)) 464 346 except SystemError, e: 465 return self._ _handleError(e)347 return self._handleError(e) 466 348 except Exception, e: 467 349 errorMessage = traceback.format_exc() … … 481 363 # values 482 364 logging.debug("Setting up drop down lists for related links") 483 c.relatedLinkTerms = utils.getVocabTermDataDropdown(\ 484 g.vtd.getValidTypes(g.vtd.ONLINE_REF_CATEGORY)) 485 486 c.relatedLinkSelectedLists = {} 487 for link in c.atom.relatedLinks: 365 vtds = g.vtd.getValidTypes(g.vtd.ONLINE_REF_CATEGORY) 366 c.relatedLinkTerms = utils.getVocabTermDataDropdown(vtds) 367 368 # ensure we have set up the correct inputs to allow htmlfill to show 369 # the correct selected value 370 for i, link in enumerate(c.atom.relatedLinks): 488 371 logging.debug("Adding dropdown for related link, '%s'" %(str(link))) 489 c.relatedLinkSelectedLists[str(link)] = \ 490 utils.getVocabTermDataDropdown(g.vtd.getValidTypes(g.vtd.ONLINE_REF_CATEGORY), \ 491 selected=link.rel) 372 refLabel = Atom.ONLINE_REF_LABEL + "." + str(i) + '.rel' 373 374 # get the value of the selected list 375 self.__setDropDownSelectVal(refLabel, link.rel, vtds) 492 376 493 377 logging.debug("Finished setting up drop down lists") … … 673 557 ''' 674 558 logging.info("Saving changes to eXist") 675 eXist = self._ _getExistClient(atom.ME.providerID)559 eXist = self._getExistClient(atom.ME.providerID) 676 560 createdAtom = eXist.createAtomInExist(atom) 677 561 logging.info("Changes successfully saved to eXist") 678 562 return createdAtom 679 680 681 def __getExistClient(self, providerID):682 '''683 Use the config data to set up and return an eXist client684 '''685 logging.info("Setting up eXist client to provider, '%s'" %providerID)686 # firstly check if there is a current connection available687 eXistClient = g.eXistDBCons.get(providerID)688 if eXistClient:689 logging.info("- found existing client to provider - returning this")690 return eXistClient691 692 # lookup the eXist DB to use according to the provider ID for the693 # data - NB, this is specified in the milk.config file694 existHost = self.cf.get('NDG_EXIST', providerID)695 configFile = self.cf.get('NDG_EXIST','passwordFile')696 eXistClient = edc.eXistDBClient(eXistDBHostname = existHost, \697 configFile = configFile)698 # add the client to the global variables for re-use699 g.eXistDBCons[providerID] = eXistClient700 logging.info("Returning eXist client")701 return eXistClient702 563 703 564 … … 706 567 Create a new atom 707 568 ''' 569 self._setup() 708 570 if saveData: 709 571 logging.info("Validating input") 710 572 try: 711 inputs = self.__getTidyInputs()712 573 validator = CreateAtomFormSchema() 713 validator.to_python( inputs)574 validator.to_python(self.inputs) 714 575 logging.info("- input valid") 715 576 716 577 logging.info("Creating basic atom") 717 self.__setup() 718 atomTypeID = inputs.get('atomTypeID').split('--')[1] 719 inputs['atomTypeID'] = atomTypeID 578 atomTypeID = self.inputs.get('atomTypeID').split('--')[1] 579 self.inputs['atomTypeID'] = atomTypeID 720 580 721 581 # activity deployments should have subtype deployment specified automatically 722 582 if atomTypeID == g.vtd.ACTIVITY_DEPLOYMENT_TERM: 723 inputs['subtypeID'] = g.vtd.DEPLOYMENT_TERM 724 inputs['atomTypeID'] = g.vtd.ACTIVITY_TERM 725 726 inputs['providerID'] = inputs.get('providerID').split('--')[1] 727 atom = self.saveAtomToExist(Atom(**dict(inputs))) 728 729 h.redirect_to(controller = 'atom_editor/editatom', action='edit', 730 uri = atom.ndgURI) 583 self.inputs['subtypeID'] = g.vtd.DEPLOYMENT_TERM 584 self.inputs['atomTypeID'] = g.vtd.ACTIVITY_TERM 585 586 self.inputs['providerID'] = self.inputs.get('providerID').split('--')[1] 587 atom = self.saveAtomToExist(Atom(**dict(self.inputs))) 588 url = h.url_for('edit', uri = atom.ndgURI, saveData=None) 589 590 # NB, the redirect throws an exception, so be careful not to catch it 591 h.redirect_to(url) 731 592 except Invalid, e: 732 593 c.errors = e.unpack_errors() … … 738 599 # set up the drop down content - NB, add special case, 'deployment activity' 739 600 # - this is just a specialised activity - i.e. with subtype preset 740 c.atomTypes = utils.getVocabTermDataDropdown(g.vtd.getValidTypes(g.vtd.ATOM_CATEGORY), 741 selected = inputs.get('atomTypeID')) 742 c.providerIDs = utils.getVocabTermDataDropdown( 743 g.vtd.getValidTypes(g.vtd.PROVIDER_CATEGORY), 744 selected = inputs.get('providerID')) 601 c.atomTypes = utils.getVocabTermDataDropdown(g.vtd.getValidTypes(g.vtd.ATOM_CATEGORY)) 602 c.providerIDs = utils.getVocabTermDataDropdown(g.vtd.getValidTypes(g.vtd.PROVIDER_CATEGORY)) 745 603 746 604 try: 747 return s avePageAndRender(self.pathInfo, 'atom_editor/atom_creator', **inputs)605 return self.savePageAndRender('atom_editor/atom_creator', **self.inputs) 748 606 749 607 except Exception, e: 750 return self._ _handleError(e)608 return self._handleError(e) 751 609 752 610 … … 759 617 c.errors = {} 760 618 try: 761 return s avePageAndRender(self.pathInfo,'atom_editor/atom_granulator', **inputs)619 return self.savePageAndRender('atom_editor/atom_granulator', **inputs) 762 620 763 621 except Exception, e: 764 return self._ _handleError(e)622 return self._handleError(e) -
MILK/trunk/milk_server/milk_server/controllers/atom_editor/editorconstants.py
r4678 r4724 12 12 DEPLOYMENTS_ASSOCIATION_TITLE = ' - to create associations with deployment data' 13 13 DEPLOYMENTS_DATA_ASSOCIATION_TITLE = ' - to create associations with activity/data production tool/observation station data' 14 HELP_PAGE_TITLE = 'Atom Editor Help Page' 15 14 16 NO_SEARCH_RESULTS = 'No data found for search selections' 15 17 EDIT_TITLE = 'Editing [%s]' -
MILK/trunk/milk_server/milk_server/controllers/atom_editor/listatom.py
r4668 r4724 6 6 ''' 7 7 import logging, xmlrpclib 8 from paste.request import parse_querystring9 from ndgUtils import ndgObject10 8 from ndgUtils.models.Atom import Atom 11 9 from ndgUtils import DocumentRetrieve 12 10 from ndgUtils.eXistInterface import ndg_eXist 13 import ndgUtils.lib.existdbclient as edc14 from ndgUtils.models.MolesEntity import MolesEntity as ME15 11 from ndgUtils.models.vocabtermdata import VocabTermData as VTD, VocabTermItem as VTI 16 12 from milk_server.lib.base import * 17 13 from editorconstants import * 18 14 import milk_server.lib.htmlUtilities as utils 19 from milk_server.lib.atomutilities import savePageAndRender 20 from editatom import EditatomController as ec 21 15 from atomeditorcontroller import AtomEditorController 22 16 23 class ListatomController( BaseController):17 class ListatomController(AtomEditorController): 24 18 ''' 25 19 Provides the pylons controller for listing/searching NDG Atom documents. 26 20 ''' 27 def __setup(self,uri=None):28 ''' Common setup stuff for all the actions on this controller '''29 logging.info("Setting up EditatomController")30 self.cf=request.environ['ndgConfig']31 32 if uri:33 try:34 self.ndgObject = ndgObject(uri, config=self.cf)35 except ValueError,e:36 return e37 21 38 self.inputs=dict(parse_querystring(request.environ)) 39 40 logging.info("EditatomController set up") 41 return 0 42 43 22 44 23 def atomHome(self): 45 24 ''' … … 48 27 logging.info("Rendering atom home page") 49 28 c.title = ATOM_HOME_TITLE 50 return s avePageAndRender(self.pathInfo,"atom_editor/atom_home")29 return self.savePageAndRender("atom_editor/atom_home") 51 30 52 31 … … 57 36 logging.info("Rendering example granulite file page") 58 37 c.title = EXAMPLE_GRANULITE_TITLE 59 return savePageAndRender(self.pathInfo, "atom_editor/granulite_example") 38 return self.savePageAndRender("atom_editor/granulite_example") 39 40 41 def showAtomHelp(self): 42 ''' 43 Show the help page 44 ''' 45 logging.info("Rendering help page") 46 c.title = HELP_PAGE_TITLE 47 return self.savePageAndRender("atom_editor/atom_help") 60 48 61 49 … … 75 63 ''' 76 64 try: 77 inputs = request.params78 65 c.searchData = None 66 self._setup() 79 67 if searchData and int(searchData) > 0: 80 68 logging.info("Preparing atom search") 81 69 c.searchData = searchData 82 self.__setup() 83 atomTypeID = inputs.get('atomTypeID') 84 providerID = inputs.get('providerID') 70 atomTypeID = self.inputs.get('atomTypeID') 71 providerID = self.inputs.get('providerID') 85 72 # NB, avoid page being reloaded in incorrect state - e.g. after 86 73 # browser reload … … 96 83 atomTypeID = VTD.DEPLOYMENT_TERM 97 84 98 c.results = self.searchAtoms(providerID, atomTypeID, inputs.get('title'))85 c.results = self.searchAtoms(providerID, atomTypeID, self.inputs.get('title')) 99 86 100 87 logging.info("Rendering atom listings page") … … 104 91 c.associateLink = "" 105 92 if associatedAtomID: 106 c.associateLink = h.url_for( controller='atom_editor/editatom', action='saveAtom', \107 uri = associatedAtomID, saveLevel = ec.ADD_ASSOCIATIONS)108 c.searchLink = h.url_for( controller = 'atom_editor/listatom', action='list', \109 searchData='1', associatedAtomID = associatedAtomID)110 111 c.searchTerm = inputs.get('title')93 c.associateLink = h.url_for('save', uri = associatedAtomID, \ 94 saveLevel = self.ADD_ASSOCIATIONS) 95 c.searchLink = h.url_for('list', searchData='1', 96 associatedAtomID = associatedAtomID, \ 97 associatedAtomType = associatedAtomType, \ 98 associationType = associationType) 112 99 113 100 # set up the drop down content … … 136 123 c.atomTypes = utils.getVocabTermDataDropdown(listVals, \ 137 124 defaultVal = defaultVal, \ 138 selected = inputs.get('atomTypeID'))125 selected = self.inputs.get('atomTypeID')) 139 126 c.providerIDs = utils.getVocabTermDataDropdown(g.vtd.getValidTypes(g.vtd.PROVIDER_CATEGORY), 140 127 defaultVal = allVal, \ 141 selected = inputs.get('providerID'))128 selected = self.inputs.get('providerID')) 142 129 143 return s avePageAndRender(self.pathInfo, 'atom_editor/atom_list')130 return self.savePageAndRender('atom_editor/atom_list', **self.inputs) 144 131 145 132 except Exception, e:
Note: See TracChangeset
for help on using the changeset viewer.