1 |
swtstore (Sweet Store) |
2 |
====================== |
3 |
|
4 |
---- |
5 |
|
6 |
|
7 |
Introduction |
8 |
------------ |
9 |
|
10 |
This is the sweet store application. |
11 |
The store for the decentralized, semantic, social web tweets a.k.a SWeeTs! |
12 |
|
13 |
This README is about installing, configuring and running/deploying this |
14 |
application. If you want to know more about SWeeTs, please go to |
15 |
[wiki.janastu.org/Sweet_Web](http://janastu.org/technoscience/index.php/Sweet_Web) and |
16 |
[trac.pantoto.org/sweet-web](http://trac.pantoto.org/sweet-web). |
17 |
|
18 |
This application acts as the repository store for all the SWeeTs that are |
19 |
generated from the clients registered with the sweet store. It provides |
20 |
query APIs to query the SWeeTs. |
21 |
|
22 |
It also provides user management to manage the users of the swtstore. |
23 |
|
24 |
All the APIs of the swtstore are accessed by using an access token which is |
25 |
generated by the swtstore when an user authorizes a third-party application |
26 |
through OAuth. |
27 |
|
28 |
Sweet store provides the following APIs: |
29 |
|
30 |
- [GET] /api/sweets/<id>: Get a specific SWeeT by its id. |
31 |
|
32 |
- [GET] /api/sweets/q?who=<username>&what=<contextname>&where=<URL> : |
33 |
This API is for querying sweet based on the who, what and where |
34 |
parameters. |
35 |
This API do not support querying based on parameters mentioned in how, |
36 |
but will be supported in future. Right now, the client can get sweets |
37 |
based on the above mentioned three parameters, and as the 'how' part is |
38 |
a JSON, it is trivial to do further filtering based on parameters of |
39 |
'how' by the client. |
40 |
|
41 |
- [POST] /api/sweets : Post a SWeeT to this swtstore with the data in the |
42 |
body of the request. The data or payload is a list of sweets. Even if you |
43 |
are sending one sweet, make sure that the sweet is in a list. |
44 |
|
45 |
- [GET] /api/users/me : Get a JSON details of the current user logged in. |
46 |
|
47 |
|
48 |
Any third-party client side application can communicate with the swtstore |
49 |
using these APIs, provided they have a valid access token. |
50 |
|
51 |
|
52 |
Installing |
53 |
---------- |
54 |
|
55 |
The swtstore application is written in Python and uses a relational database. |
56 |
|
57 |
Hence, the dependencies of this application is Python and any relational database |
58 |
supported by SQLAlchemy. |
59 |
|
60 |
Most common RDBMS supported by SQLAlchemy are MySQL, Postgresql. |
61 |
|
62 |
For more information on supported databases see |
63 |
[here](http://docs.sqlalchemy.org/en/rel_0_9/dialects/index.html). |
64 |
|
65 |
___ Once you are sure you have Python and a relational database (like |
66 |
MySQL/Postgresql etc.) installed. You can go ahead and follow these steps:___ |
67 |
|
68 |
* Clone the repository from [https://git.pantoto.org/sweet-web/sweet-web-engine](https://git.pantoto.org/sweet-web/sweet-web-engine) |
69 |
OR you can download the |
70 |
code from the same link. |
71 |
|
72 |
* It is strongly recommended to do the installation inside a virtual environment. |
73 |
If you think, you know what you are doing and don't need the virtual |
74 |
environment, you can skip to the next step. |
75 |
Initialize a python virtual environment using `virtualenv` in the same directory |
76 |
where you cloned the repository in the above step. Now, activate the |
77 |
environment |
78 |
|
79 |
> ``$ source <path/to/your/current-virtual-env>/bin/activate `` |
80 |
|
81 |
See [http://www.virtualenv.org/en/latest/virtualenv.html](http://www.virtualenv.org/en/latest/virtualenv.html) for more details about `virtualenv`. |
82 |
|
83 |
* Run the setup.py script to install `` python setup.py install `` |
84 |
|
85 |
You're done installing swtstore. Now you need to configure it to run. |
86 |
|
87 |
|
88 |
Configure swtstore |
89 |
------------------ |
90 |
|
91 |
* Copy the contents of ``sample_config.py`` inside the ``swtstore`` directory |
92 |
into ``config.py`` inside ``swtstore`` directory itself. |
93 |
|
94 |
Assuming you are using a *-nix based system, and you are in the root directory |
95 |
of the codebase, |
96 |
|
97 |
`` $ cp swtstore/sample_config.py swtstore/config.py`` |
98 |
|
99 |
* Edit the config.py file, and change the values accordingly. |
100 |
|
101 |
* Now, you have to setup the database for the swtstore application. But |
102 |
fortunately, the creation of database and tables have also been scripted, so |
103 |
all you need to do is run the ``dbsetup.py`` script. |
104 |
`` $ python dbsetup.py `` |
105 |
|
106 |
**NOTE:** Please remember that all these configuration step is necessary and is |
107 |
required wether you are running the application locally or deploying it on a |
108 |
server. |
109 |
|
110 |
|
111 |
|
112 |
Running the server locally |
113 |
-------------------------- |
114 |
|
115 |
Run the runserver.py script to run the server locally, |
116 |
|
117 |
> `` $ python runserver.py `` |
118 |
|
119 |
This runs the application locally, on port 5001. So you can direct your browser |
120 |
to http://localhost:5001 |
121 |
|
122 |
|
123 |
|
124 |
Deploying the application |
125 |
------------------------- |
126 |
|
127 |
SwtStore is deployed as a WSGI application server. |
128 |
|
129 |
The wsgi script to deploy the application is provided (its called |
130 |
`swtstore.wsgi`). |
131 |
Point your webserver like Apache, or Nginx to point to the `swtstore.wsgi` |
132 |
script. |
133 |
|
134 |
See Apache WSGI configuration here: |
135 |
[http://modwsgi.readthedocs.org/en/latest/configuration-directives/WSGIScriptAlias.html](http://modwsgi.readthedocs.org/en/latest/configuration-directives/WSGIScriptAlias.html) |
136 |
|
137 |
TODO: [insert Nginx WSGI config link] |
138 |
|
139 |
|
140 |
Help / Feedback |
141 |
--------------- |
142 |
|
143 |
If you need any help, or have any questions, comments or feedback, you can contact at |
144 |
rayanon or arvind or bhanu at servelots.com |
145 |
|
146 |
You can also join channel #servelots on freenode network, using your favourite |
147 |
IRC client. We usually hang out at #servelots. |
148 |
|
149 |
|
150 |
License |
151 |
------- |
152 |
|
153 |
BSD Licensed. |
154 |
|
155 |
See LICENSE for more details. |