Exemplo n.º 1
0
 def __init__(self, context, request):
     WebResponseObject.__init__(self, context, request)
     self.data = {}
     try:
         self.data['group'] = self._get_category()
     except Exception as e:
         self.data['group'] = self.ERROR
Exemplo n.º 2
0
 def __init__(self,context,request):
     WebResponseObject.__init__(self,context,request)
     self.data = {}
     try:
         self.data['group'] = self._get_category()
     except Exception as e:
         self.data['group'] = self.ERROR
Exemplo n.º 3
0
 def __init__(self,context,request):
     WebResponseObject.__init__(self,context,request)
     self.resources = []
     self.computers = []
     self.computers_accessible = 'True' # dead code
     self.resources_accessible = 'True' # dead code
     self.description = "Resources Available at Polk Library"
Exemplo n.º 4
0
class WebServiceBase(BrowserView):
    """
    Any Web Service should extend this class, this will setup the basic
    functionality and return types for any service.
    """

    DEFAULT_RESPONSE_TYPE = 'xml'
    DEFAULT_CALLBACK = '?'
    APPLICATION_JSON = 'application/json'
    APPLICATION_XML = 'application/xml'
    RESPONSE_TYPE_JSON = 'json'
    RESPONSE_TYPE_JSONP = 'jsonp'
    RESPONSE_TYPE_XML = 'xml'

    response = None

    def __call__(self, proceed=False):
        self.response = WebResponseObject(self.context,
                                          self.request)  # Default
        self.setup()
        if proceed:
            self.execute()

    def setup(self):
        """ Setup before execution """
        self.use_cache = self.request.form.get('use_cache', '')
        self.response_type = self.request.form.get('alt',
                                                   self.DEFAULT_RESPONSE_TYPE)
        self.callback = self.request.form.get('callback',
                                              self.DEFAULT_CALLBACK)
        content_type = self.request.form.get('content_type', 'text/html')

        if self.response_type == self.RESPONSE_TYPE_JSON or \
           self.response_type == self.RESPONSE_TYPE_JSONP:
            self.request.response.setHeader('Content-Type',
                                            self.APPLICATION_JSON)
        elif self.response_type == self.RESPONSE_TYPE_XML:
            self.request.response.setHeader('Content-Type',
                                            self.APPLICATION_XML)
        else:
            self.request.response.setHeader('Content-Type', content_type)

    def execute(self):
        """ Execution """
        raise Exception("Must implement execute()")

    def sendResponse(self):
        if self.response_type == self.RESPONSE_TYPE_JSON:
            return self.response.toJSON()
        elif self.response_type == self.RESPONSE_TYPE_JSONP:
            return str(self.callback) + "(" + self.response.toJSON() + ")"
        elif self.response_type == self.RESPONSE_TYPE_XML:
            return self.response.toXML()
        else:
            return self.response.toCustom()

    def setResponse(self, value):
        self.response = value
Exemplo n.º 5
0
class WebServiceBase(BrowserView):
    """
    Any Web Service should extend this class, this will setup the basic
    functionality and return types for any service.
    """
    
    DEFAULT_RESPONSE_TYPE = 'xml'
    DEFAULT_CALLBACK = '?'
    APPLICATION_JSON = 'application/json'
    APPLICATION_XML = 'application/xml'
    RESPONSE_TYPE_JSON = 'json'
    RESPONSE_TYPE_JSONP = 'jsonp'
    RESPONSE_TYPE_XML = 'xml'
    
    response = None
    
    def __call__(self,proceed=False):
        self.response = WebResponseObject(self.context,self.request) # Default
        self.setup()
        if proceed: 
            self.execute()
    
    def setup(self):
        """ Setup before execution """
        self.use_cache = self.request.form.get('use_cache','')
        self.response_type = self.request.form.get('alt',self.DEFAULT_RESPONSE_TYPE)
        self.callback = self.request.form.get('callback',self.DEFAULT_CALLBACK)
        content_type = self.request.form.get('content_type','text/html')
        
        if self.response_type == self.RESPONSE_TYPE_JSON or \
           self.response_type == self.RESPONSE_TYPE_JSONP:
            self.request.response.setHeader('Content-Type', self.APPLICATION_JSON)
        elif self.response_type == self.RESPONSE_TYPE_XML:
            self.request.response.setHeader('Content-Type', self.APPLICATION_XML)
        else:
            self.request.response.setHeader('Content-Type', content_type)

    def execute(self):
        """ Execution """
        raise Exception("Must implement execute()")

    def sendResponse(self):
        if self.response_type == self.RESPONSE_TYPE_JSON:
            return self.response.toJSON()
        elif self.response_type == self.RESPONSE_TYPE_JSONP:
            return str(self.callback) + "(" + self.response.toJSON() + ")"
        elif self.response_type == self.RESPONSE_TYPE_XML:
            return self.response.toXML()
        else:
            return self.response.toCustom()

    def setResponse(self,value):
        self.response = value
Exemplo n.º 6
0
 def __init__(self, context, request, date):
     WebResponseObject.__init__(self,context,request)
     self.times = []
     self.description = "Hours of operation today for polk library"
     self.status = "Load Error"
     self.is_open = 0
     self.offset = timeutil.offsets()
     self.status_link = self.getProp('library_hours_url')
     
     if date:
         dt = datetime.datetime.strptime(date, '%Y-%m-%d')
         cache = HoursCache(context)
         cache.setup()
         hours = cache.query_date(dt)
         self.addTime(open=datetime.datetime.strptime(hours['start'],self.DT_FMT),
                      close=datetime.datetime.strptime(hours['end'],self.DT_FMT),
                      is_open=hours['is_open'],
                      title=hours['title'],
                      content=hours['content'])
     else:
         self.determineHours()
Exemplo n.º 7
0
 def __init__(self,context,request):
     WebResponseObject.__init__(self,context,request)
     self.computer_status = 0
     self.computer_id = ""
     self.description = "Computer Availability"
 def __init__(self,context,request):
     WebResponseObject.__init__(self,context,request)
     self.locations = []
     self.studyareas = []
Exemplo n.º 9
0
 def __init__(self, context, request):
     WebResponseObject.__init__(self, context, request)
     dao = VoyagerDAO()
 def __init__(self, context, request):
     WebResponseObject.__init__(self, context, request)
     self.data = ''
Exemplo n.º 11
0
 def __init__(self, context, request):
     WebResponseObject.__init__(self, context, request)
     self.today = []
     self.tomorrow = []
     self.upcoming = []
     self.description = "Study groups at Polk Library"
 def __init__(self,context,request):
     WebResponseObject.__init__(self,context,request)
     self.data = ''
Exemplo n.º 13
0
 def __init__(self,context,request):
     WebResponseObject.__init__(self,context,request)
     self.nodes = []
Exemplo n.º 14
0
 def __init__(self,context,request):
     WebResponseObject.__init__(self,context,request)
     self.today = []
     self.tomorrow = []
     self.upcoming = []
     self.description = "Study groups at Polk Library"
Exemplo n.º 15
0
 def __init__(self, context, request):
     WebResponseObject.__init__(self, context, request)
     self.locations = []
     self.studyareas = []
Exemplo n.º 16
0
 def __call__(self,proceed=False):
     self.response = WebResponseObject(self.context,self.request) # Default
     self.setup()
     if proceed: 
         self.execute()
 def __init__(self,context,request,ids):
     WebResponseObject.__init__(self,context,request)
     self.databases = filter(lambda x: x['id'] in ids, self.saved_cache())
Exemplo n.º 18
0
 def __init__(self,context,request):
     WebResponseObject.__init__(self,context,request)
     self.times = []
     self.description = "Hours of operation today for polk library"
Exemplo n.º 19
0
 def __call__(self, proceed=False):
     self.response = WebResponseObject(self.context,
                                       self.request)  # Default
     self.setup()
     if proceed:
         self.execute()
Exemplo n.º 20
0
 def __init__(self, context, request):
     WebResponseObject.__init__(self, context, request)
     self.output = {}