Ignore:
Timestamp:
10/08/12 15:32:06 (8 years ago)
Author:
mnagni
Message:

Incomplete - # 22534: Add versiojn number to the gui page
 http://team.ceda.ac.uk/trac/ceda/ticket/22534

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/molesSessionMiddleware.py

    r8486 r8507  
    4242from django.core.context_processors import csrf 
    4343from django.shortcuts import render_to_response 
     44from cedaMoles import __version__ 
    4445 
    4546 
     
    8990    def process_response(self, request, response): 
    9091        if hasattr(request, "moles3EPB"):             
    91             request.moles3EPB.close() 
    92              
     92            request.moles3EPB.close()             
    9393        return response 
    9494 
     
    102102    if runMigration and not MolesSessionMiddleware._migrationThread.isAlive(): 
    103103        #t.setDaemon(False) 
    104         MolesSessionMiddleware._migrationThread.start()         
     104        MolesSessionMiddleware._migrationThread.start()     
     105         
     106 
     107def mm_render_to_response(request, context, page_to_render): 
     108    """ 
     109    Exploit a 'render_to_response' action. The advantage of this method 
     110    is to contains a number of operations that are expected to be  called 
     111    for each page rendering, for example passing the application version number 
     112      
     113    **Parameters**             
     114        * HttpRequest_ **request** 
     115            a django HttpRequest instance        
     116        * `dict` **context** 
     117            a dictionary where to pass parameter to the rendering function    
     118        * `string` **page_to_render** 
     119            the html page to render                          
     120    """ 
     121    if context is None or not isinstance(context, dict): 
     122        raise Exception("Cannot render an empty context") 
     123     
     124    context['version'] = __version__ 
     125    context.update(csrf(request)) 
     126    return render_to_response(page_to_render, context)             
Note: See TracChangeset for help on using the changeset viewer.