#TEDxBerkeley Logic Tier
Here is how to setup a local instance.
- Check that needed commands are accessible
source check.sh
. - Install
source install.sh
. - Run server
source activate.sh
. - Browse Logic Core Documentation. (coming soon)
- Read the Guidelines below.
- If you are uncertain of where to start, see How to get Working below.
To update your installation of the logic core, use:
git submodule foreach git reset head --hard
to remove any inadvertent changes.git submodule foreach git pull origin master
to update the submodules.
- It is safer not to modify the core
logic
submodule, which is located in thelogic
directory from this repository. If you wish to make edits, clone thelogic
repository and make edits there. - Make all edits in a new branch. After creating a branch, immediately create
a Pull Request (PR), but include
[do not merge]
in the title, so that your teammates can comment and collaborate on the branch. - Once the branch is ready, remove
[do not merge]
and alert your code partner that it is ready for code review. - Do not merge your own PRs, unless it is a critical bug fix and all tests pass.
- Conform to PEP style guidelines.
- Rename the "template" folder in this repository's root to your application's name.
High-Level Overview
The logic core is responsible for accepting, authenticating, and translating API calls into methods. Logic tier simply treats the core as a distinct, independent library and registers (1) API endpoints for the application client to call and (2) models, to define how data is stored.
Detailed Explanation
Implementations of the core logic tier only require registered APIs. Assuming that models are included in the relevant API python files, they will be automatically detected and registered.
To begin, the run.py
file, in the repository root directory, creates an instance
of the app, and then runs it. This app is defined in template/__init__.py
. In
that file, a number of items are necessary for this to function:
- Updating
sys.path
with the logic directory. This allows your application to access the logic core as a module namedlogic
. - In
create_template_app
, it is necessary to import views after the app is instantiated. - In
created_template_app
, it is necessary to invokeapp.register_blueprints
after importing the file that registers your APIs.
In the template/views.py
file, we import register_api
and then register
each API with an endpoint name. Note that this file is arbitrarily named. All that
matters, is that this file is imported in __init__.py
after the app is
instantiated.
In the template/api.py
file, you must create API classes that extend from
BaseAPI. Again, this file is arbitrarily named. All that matters, is that an
imported views file registers this API using the register_api
method.
##How to get Working
If all of the above is confusing, then simply respect the application's abstractions and know the following. These should compartmentalize the application enough, so that you don't need to know how the rest of it works.
- Create an API in
api.py
that extends fromBaseAPI
. - Register the API by calling
register_api
with it, inviews.py
. - Read through the sample
SampleAPI
and remove it. - Learn how to use models. These are all mongoengine documents but you can also use a set of simpler abstractions. All models extend that Document object, so refer to the specified examples for usage.
- Write tests.