Пример #1
0
 def as_dict(self):
     representation = HALRepresentation({})
     representation.add_embed('events', [
         HALEventRepresentation(e, 'events.event').as_dict()
         for e in self.events
     ])
     if self.day and self.month and self.year:
         representation.add_links(
             get_nav_links(self.endpoint,
                           self.start,
                           self.count,
                           self.size,
                           day=self.day,
                           month=self.month,
                           year=self.year))
         representation.add_link(
             'self',
             url_for(self.endpoint,
                     day=self.day,
                     month=self.month,
                     year=self.year))
     else:
         representation.add_links(
             get_nav_links(self.endpoint, self.start, self.count,
                           self.size))
         representation.add_link('self', url_for(self.endpoint))
     return representation.as_dict()
Пример #2
0
 def as_dict(self):
     values = {}
     values[<XXX>] = <XXX>
     values['_attribution'] = self.attribution
     values['_last_updated'] = self.last_updated
     representation = HALRepresentation(values)
     representation.add_link('self', url_for(self.endpoint))
     return representation.as_dict()
Пример #3
0
 def as_dict(self):
     representation = HALRepresentation({})
     representation.add_embed('webcams', [
         HALWebcamRepresentation(w, 'webcams.webcam').as_dict()
         for w in self.webcams
     ])
     representation.add_link('self', url_for('webcams.webcams'))
     return representation.as_dict()
Пример #4
0
 def as_dict(self):
     base = super(HALWebcamRepresentation, self).as_dict()
     representation = HALRepresentation(base)
     representation.add_link('self',
                             url_for(self.endpoint, slug=self.webcam.slug))
     if self.webcam.poi:
         # TODO remove hardcoded endpoint for places
         representation.add_link(
             'poi', url_for('places.poidetail', ident=self.webcam.poi))
     return representation.as_dict()
Пример #5
0
def get_routes():
    path = request.path
    representation = HALRepresentation({})
    representation.add_curie(
        'hl',
        'http://moxie.readthedocs.org/en/latest/http_api/events.html#{rel}')
    representation.add_link('self', '{bp}'.format(bp=path))
    representation.add_link('hl:search',
                            '{bp}search'.format(bp=path),
                            title="Search events")
    representation.add_link('hl:event',
                            '{bp}event/{{id}}'.format(bp=path),
                            templated=True,
                            title="Event")
    response = make_response(representation.as_json(), 200)
    response.headers['Content-Type'] = "application/json"
    return response
Пример #6
0
 def as_dict(self):
     base = super(HALEventRepresentation, self).as_dict()
     representation = HALRepresentation(base)
     representation.add_link(
         'self', url_for(self.endpoint, ident=self.event.signature))
     return representation.as_dict()
Пример #7
0
 def as_dict(self):
     rivers = RiversStatusRepresentation(self.rivers,
                                         self.last_updated).as_dict()
     representation = HALRepresentation(rivers)
     representation.add_link('self', url_for(self.endpoint))
     return representation.as_dict()