~dkuhlman/python-training-materials/Materials

« back to all changes in this revision

Viewing changes to Code_python/DocServer/Solutions/solution_zmq_doc_http_server/zmq_doc_http_server/views.py

  • Committer: Dave Kuhlman
  • Date: 2015-10-09 19:50:18 UTC
  • mfrom: (35.1.6 Materials)
  • Revision ID: dkuhlman@davekuhlman.org-20151009195018-8rfrdur2zxdjn5ds
Merge after training at Cisco 10/05/2015

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from pyramid.view import view_config
 
2
import zmq_doc_client01
 
3
 
 
4
#from pyramid.response import Response
 
5
 
 
6
 
 
7
@view_config(route_name='help_view', renderer='templates/help_view.pt')
 
8
def help_view(request):
 
9
    return {}
 
10
    #return Response("<p>Hello</p>")
 
11
 
 
12
 
 
13
@view_config(route_name='list_view', renderer='templates/list_view.pt')
 
14
def list_view(request):
 
15
    docs = zmq_doc_client01.list_request([], show=False)
 
16
    return {'docs': docs, 'version': '1.0a'}
 
17
 
 
18
 
 
19
@view_config(route_name='get_view', renderer='templates/get_view.pt')
 
20
def get_view(request):
 
21
    #import pdb; pdb.set_trace()
 
22
    doc_id = request.matchdict['doc_id']
 
23
    doc = zmq_doc_client01.get_request([doc_id], show=False)
 
24
    return {'doc': doc}
 
25
 
 
26
 
 
27
@view_config(route_name='search_view', renderer='templates/search_view.pt')
 
28
def search_view(request):
 
29
    tag = request.matchdict['tag']
 
30
    docs = zmq_doc_client01.search_request([tag], show=False)
 
31
    return {'docs': docs}