Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganization of SILPA code #21

Open
wants to merge 96 commits into
base: master
Choose a base branch
from
Open

Reorganization of SILPA code #21

wants to merge 96 commits into from

Conversation

copyninja
Copy link
Member

This PR contains reorganization of SILPA code to follow some structure so that extending it will not cause any problem.

Don't Merge this yet it will be done when every thing works fine

Code was previously started as a proof of concept and was then directly
extended and deployed. Extending it more will be a problem so lets start
reorganizing the code.

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
We were using JSON-RPC 1.0 previously, new code starts using JSON-RPC
2.0 instead, code is being written from scratch.

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
Use importlib module to import modules, these modules will be accessible
to applications from sys.modules so drop local caching of modules.

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
Derive from ConfigParser.ConfigParser our config parsing class, and
create a config variable which reads config file when module is first
imported.
Now new name reflects what module is actually doing

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
Logic for invoking requested method on a module is added, if module
doesn't have a method by the requested name a METHOD_NOT_FOUND error is
returned to client as per JSON-RPC 2.0 specifications.

If there is error in execution of call, INTERNAL_ERROR is returned to
client as per JSON-RPC spec and message is set appropriately to reflect
what happened.

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
introduce create_app function as factory function, and on error in
jsonrpc call return 400 error code instead of 200.

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
app factory for SILPA creates app and registers its blueprints and sets
all settings for the app before returning it.

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
We also need same logging across multiple app, configure logging before
returning the app from factory.

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
pep8 throws an error but this is run time variable, need to find to make
flake8 ignore this error.
Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
Using blueprints redesigned the page handling logic (frontend) of SILPA
to be much more cleaner and neater, dropped old files

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
* silpa/api/jsonrpc.py: instance variable name is error_response typoed
  it as errors_response.
* silpa/factory.py: %(message)  is formatter field for message, typoe it
  as %(messagename)

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
Unit test for SILPA framework initiated, need to add more test cases
here.

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
* make the error codes public so it can be accessed from outside the
  module, like test cases
* error namedtuple needs to be translated into dict before returning the
  result, else error will be just a list!.
* Fix the logic for method calling

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
* silpa/api/jsonrpc.py: Remove unwanted print statement and fix the
  error dict wrapping in error response.
* tests/api/jsonrpc_tests.py: Tests for parse errors

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
Use testr for testing instead of nosetests as nose breaks with
testscenarios. Use setuptools integration of testr with coverage

Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling d698f92 on development into * on master*.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 0a05986 on development into * on master*.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 381e3bc on development into * on master*.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling a93d218 on development into * on master*.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 70ca19d on development into * on master*.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling b2efa41 on development into * on master*.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 63a783f on development into * on master*.

@copyninja
Copy link
Member Author

@santhoshtr Thanks for updating jquery.ime and install documentation, much appreciated 💯

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 8b91ff7 on development into * on master*.

copyninja and others added 7 commits June 9, 2014 22:45
Add check to functionality of __str__ (not really required only for coverage purpose ;))
Both depends on jquery
Without it, they throw js errors
Signed-off-by: Vasudev Kamath <kamathvasudev@gmail.com>
set are faster when we need to do item lookup.
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling fe5ba40 on development into * on master*.

copyninja and others added 7 commits May 15, 2016 14:29
Let the function use index.html which is default.
These were introduced in newer flake8 previously tests were passing.
tests are now part of silpa module.
When the request is processed the PATH_INFO becomes /JSONRPC instead of
/api/JSONRPC. After a bit of debugging I figured out since we are
already registering app at /api we do not need url_prefix.

Removing url_prefix from Blueprint fixed the 404 issue.

(Though its still unclear to me what was mistake I did by using
url_prefix in Blueprint creation).
This is useful for developers to figure out reasons for error in server
code.
Flask has a json object and it should be always be available since this
is jsonrpc API.

There is a possible problem that wrong information comes and this might
break in python3 as request.data is byte and json.loads expects string.
@copyninja
Copy link
Member Author

This branch can be merged now but it needs some more work to fix the failing tests and also merging means libindic.org will have to use this front end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants