#TEDxBerkeley Client Tier
This is the TEDxBerkeley client tier for tedxberkeley.org.
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 Client 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 client 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
client
submodule, which is located in theclient
directory from this repository. If you wish to make edits, clone theclient
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.
Detailed Explanation
This tier is quite simply a Flask application, except with a custom API instead of a datastore. For a primer, see Flask documentation.
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_client/__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_client/views.py
file, "views" define output for a specific or
a set of URLs. Those URLs may inject Python values into an HTML template, using
a powerful templating language, called Jinja.
All objects have five default operations, matching default objects in the
logic tier: post
(create), get
, put
(update), delete
, and get_or_create
.
Note that get_or_create
takes only one API call.
##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 a view in
view.py
with the right decorator. - Create a new object in
libs/sample.py
that extendsEntity
. - Import, instantiate and save your object inside your new view in
view.py
. - Return a stringified version of your object.
- Finally, access the URL specified for your view.