Commit 2ff5ffb1 authored by Jacek Furmankiewicz's avatar Jacek Furmankiewicz

Issue 1: wrong class passed as self to router methods

parent 84b8be92
Twisted REST micro-framework Twisted REST micro-framework
================================ ================================
Based on *Flask* API, with integrated multiprocessing support for full usage of all CPUs. Based on *Flask* API, with plans integrated multiprocessing support for full usage of all CPUs.
Provides a more Flask/Sinatra-style API on top of the core *twisted.web* APIs. Provides a more Flask/Sinatra-style API on top of the core *twisted.web* APIs.
Geared towards creating REST-oriented server platforms. Geared towards creating REST-oriented server platforms.
...@@ -222,7 +222,6 @@ Calling it with "Accept: text/yaml" will return: ...@@ -222,7 +222,6 @@ Calling it with "Accept: text/yaml" will return:
- {test1: Test1} - {test1: Test1}
- {test2: Test2} - {test2: Test2}
*Note*: marshalling to XML will be supported in a future release. There is no default Python library that does this automatically.
HTTP codes HTTP codes
------------------ ------------------
...@@ -255,5 +254,4 @@ Can be run using: ...@@ -255,5 +254,4 @@ Can be run using:
Plans Plans
----- -----
* match all the relevant features of the Flask API * integrate multi core support
* integrate twisted.internet.processes in order to scale to multiple CPU cores : http://pypi.python.org/pypi/twisted.internet.processes \ No newline at end of file
...@@ -132,6 +132,7 @@ class RequestRouter: ...@@ -132,6 +132,7 @@ class RequestRouter:
self.__routers = {} self.__routers = {}
self.__schema = schema self.__schema = schema
self.__registerRouters(urlContainer) self.__registerRouters(urlContainer)
self.__urlContainer = urlContainer
@property @property
def path(self): def path(self):
...@@ -205,7 +206,7 @@ class RequestRouter: ...@@ -205,7 +206,7 @@ class RequestRouter:
try: try:
# if POST/PUT, check if we need to automatically parse JSON # if POST/PUT, check if we need to automatically parse JSON
self.__parseRequestData(request) self.__parseRequestData(request)
val = urlrouter.call(self,request,**allargs) val = urlrouter.call(self.__urlContainer,request,**allargs)
#handle Deferreds natively #handle Deferreds natively
if isinstance(val,defer.Deferred): if isinstance(val,defer.Deferred):
......
Using step definitions from: '../steps'
@issues
Feature: Issues
Fixes for issues reported on github
@issue1
Scenario: Issue 1 (unable to access self.var in a router method)
Given 'home_resource' is running
When as user 'None:None' I GET 'http://127.0.0.1:8080/issues/1'
Then I expect HTTP code 200
And I expect content contains 'issue 1'
...@@ -12,6 +12,10 @@ import json, yaml ...@@ -12,6 +12,10 @@ import json, yaml
class HomeApp(CorePost): class HomeApp(CorePost):
def __init__(self,*args,**kwargs):
CorePost.__init__(self, *args, **kwargs)
self.issue1 = "issue 1"
@route("/",Http.GET) @route("/",Http.GET)
@defer.inlineCallbacks @defer.inlineCallbacks
def root(self,request,**kwargs): def root(self,request,**kwargs):
...@@ -105,7 +109,12 @@ class HomeApp(CorePost): ...@@ -105,7 +109,12 @@ class HomeApp(CorePost):
t2.test2="Test2" t2.test2="Test2"
return (t1,t2) return (t1,t2)
####################################
# Issues
####################################
@route("/issues/1")
def test_issue_1(self,request,**kwargs):
return self.issue1
def run_app_home(): def run_app_home():
app = HomeApp() app = HomeApp()
......
...@@ -54,19 +54,11 @@ Changelog ...@@ -54,19 +54,11 @@ Changelog
""" """
import os
from setuptools import setup from setuptools import setup
# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup( setup(
name="CorePost", name="CorePost",
version="0.0.8", version="0.0.9",
author="Jacek Furmankiewicz", author="Jacek Furmankiewicz",
author_email="jacekeadE99@gmail.com", author_email="jacekeadE99@gmail.com",
description=("A Twisted Web REST micro-framework"), description=("A Twisted Web REST micro-framework"),
...@@ -89,13 +81,12 @@ setup( ...@@ -89,13 +81,12 @@ setup(
'twisted>=11.0.0', 'twisted>=11.0.0',
'formencode>=1.2.4', 'formencode>=1.2.4',
'pyyaml>=3.1.0', 'pyyaml>=3.1.0',
'jinja2>=2.6' 'jinja2>=2.6',
'txZMQ>=0.3.1,'
], ],
tests_require=[ tests_require=[
'httplib2>=0.7.1', 'httplib2>=0.7.1',
'freshen>=0.2', 'freshen>=0.2',
], ],
zip_safe = True zip_safe = True
) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment