def get(self, key=None, view=None):
        """Register a new model (models)"""
        self.set_header("Access-Control-Allow-Origin", "*")
        self.set_header("Content-Type", "application/json")
        if key is not None:
            value = {}
            value.update(self.database[key])
            if view is not None:
                # generate a context with the relevant variables
                context = {}
                context["value"] = value
                context["ctx"] = self.ctx
                result = json.dumps(getattr(views, view)(context))
            else:
                result = json.dumps(value)
        else:
            result = json.dumps(self.database.values())

        self.write(result)
def get ( self , key = None , view = None ) : self . set_header ( "Access-Control-Allow-Origin" , "*" ) self . set_header ( "Content-Type" , "application/json" ) if key is not None : value = { } value . update ( self . database [ key ] ) if view is not None : context = { } context [ "value" ] = value context [ "ctx" ] = self . ctx result = json . dumps ( getattr ( views , view ) ( context ) ) else : result = json . dumps ( value ) else : result = json . dumps ( self . database . values ( ) ) self . write ( result )
Register a new model (models)