| 1 |
=================== |
|---|
| 2 |
PrimaGIS - Buildout |
|---|
| 3 |
=================== |
|---|
| 4 |
|
|---|
| 5 |
This is a buildout system for PrimaGIS -- a web mapping solution for |
|---|
| 6 |
Plone. Its main purpose is to provide a dependable and repeatable way |
|---|
| 7 |
for developers to easily setup a development environment that contains |
|---|
| 8 |
all the dependencies and allows for easy development. |
|---|
| 9 |
|
|---|
| 10 |
Although the focus of the buildout is developers the end result of the |
|---|
| 11 |
buildout is a working software setup that may also be used in |
|---|
| 12 |
production. |
|---|
| 13 |
|
|---|
| 14 |
The buildout provides an isolated sandbox environment for using and |
|---|
| 15 |
developing PrimaGIS without interfering with the rest of your system. |
|---|
| 16 |
|
|---|
| 17 |
The buildout is implemented using zc.buildout_ |
|---|
| 18 |
|
|---|
| 19 |
_zc.buildout: http://pypi.python.org/pypi/zc.buildout |
|---|
| 20 |
|
|---|
| 21 |
================= |
|---|
| 22 |
Table of Contents |
|---|
| 23 |
================= |
|---|
| 24 |
1.Quickstart |
|---|
| 25 |
2.Bootstrapping the buildout |
|---|
| 26 |
3.Buildout structure |
|---|
| 27 |
4.Setting up PostgreSQL |
|---|
| 28 |
5.Developing PrimaGIS |
|---|
| 29 |
6.OSX Notes |
|---|
| 30 |
7.Building on Debian based systems(see README-deb.txt) |
|---|
| 31 |
================= |
|---|
| 32 |
|
|---|
| 33 |
Quickstart |
|---|
| 34 |
---------- |
|---|
| 35 |
|
|---|
| 36 |
The following commands will install the whole of PrimaGIS and setup a |
|---|
| 37 |
PostgreSQL db for testing For detailed instructions read below. |
|---|
| 38 |
|
|---|
| 39 |
Do not run any of the following commands as root. Run as a normal user or |
|---|
| 40 |
problems will result when attempting to start PostGreSQL and Zope. |
|---|
| 41 |
|
|---|
| 42 |
1. Get the buildout from the SVN repository and bootstrap it. Note |
|---|
| 43 |
that you will need a python version >= 2.4 (but < 2.5) to run the |
|---|
| 44 |
buildout. |
|---|
| 45 |
|
|---|
| 46 |
$ svn co http://svn.gispython.org/svn/zope/primagis.buildout/branches/zc.buildout primagis.buildout |
|---|
| 47 |
$ cd primagis.buildout |
|---|
| 48 |
$ python bootstrap.py |
|---|
| 49 |
|
|---|
| 50 |
2. Execute the buildout. The buildout will download, compile and |
|---|
| 51 |
install a fairly large number of software components and may take a |
|---|
| 52 |
while (~2 hours). Be patient. |
|---|
| 53 |
|
|---|
| 54 |
$ ./bin/buildout |
|---|
| 55 |
|
|---|
| 56 |
If the network connection is lost during the buildout and the buildout |
|---|
| 57 |
stops, run the buildout again. The buildout will start again from the last |
|---|
| 58 |
incomplete step, saving significant time. |
|---|
| 59 |
|
|---|
| 60 |
3. Set up the PostgreSQL database (optional). |
|---|
| 61 |
|
|---|
| 62 |
If a port for the PostgreSQL server is not specified, the default is 5432. |
|---|
| 63 |
Insure the port does not collide with any other instances. |
|---|
| 64 |
|
|---|
| 65 |
$ ./bin/python init_postgresql.py [--port=xxxx] |
|---|
| 66 |
|
|---|
| 67 |
This step may be run over again many times to re-initialize the sample data |
|---|
| 68 |
in PostGreSQL. But running the re-initialization will delete all data |
|---|
| 69 |
previously saved in the database. |
|---|
| 70 |
|
|---|
| 71 |
4. Insure PostGreSQL is running. |
|---|
| 72 |
|
|---|
| 73 |
To see if the PostGreSQL server is running: |
|---|
| 74 |
|
|---|
| 75 |
$ .bin/pg_ctl status |
|---|
| 76 |
|
|---|
| 77 |
If the PostGresQL server is not running, start it: |
|---|
| 78 |
|
|---|
| 79 |
$ ./bin/pg_ctl start |
|---|
| 80 |
|
|---|
| 81 |
If the process appears to hang after the "database system is ready" message, |
|---|
| 82 |
simply hit the enter key to return to the command prompt. |
|---|
| 83 |
|
|---|
| 84 |
5. Enable the ZCML configuration. |
|---|
| 85 |
|
|---|
| 86 |
Make copies of the ZCML templates in ./src/ZCO/src/zco/mapconfiguration: |
|---|
| 87 |
|
|---|
| 88 |
datastores.zcml.dist |
|---|
| 89 |
maprenderer.zcml.dist |
|---|
| 90 |
symbolizers.zcml.dist |
|---|
| 91 |
|
|---|
| 92 |
by removing the .dist file extension: |
|---|
| 93 |
|
|---|
| 94 |
$ cd src/ZCO/src/zco/mapconfiguration |
|---|
| 95 |
$ for f in *.dist; do cp -p "$f" "${f%?????}"; done |
|---|
| 96 |
$ cd - |
|---|
| 97 |
|
|---|
| 98 |
6. Enable the font set in ZCML. |
|---|
| 99 |
|
|---|
| 100 |
PCL needs to know about some fonts. Tell Zope about the font by editing: |
|---|
| 101 |
|
|---|
| 102 |
./src/ZCO/src/zco/mapconfiguration/maprenderer.zcml |
|---|
| 103 |
|
|---|
| 104 |
Find the <gis:mapserverRenderer> tag and edit its fontset attribute. The |
|---|
| 105 |
fontset to which to point the attribute is: |
|---|
| 106 |
|
|---|
| 107 |
./base/pcl.buildout/src/PCL/examples/fonts.txt |
|---|
| 108 |
|
|---|
| 109 |
The attribute expects an absolute path. So replace the . with the path |
|---|
| 110 |
to your buildout. |
|---|
| 111 |
|
|---|
| 112 |
7. Enable the PostGIS datastore in ZCML. |
|---|
| 113 |
|
|---|
| 114 |
PCL needs to know where to get data. Tell Zope about PostGIS by editing: |
|---|
| 115 |
|
|---|
| 116 |
./src/ZCO/src/zco/mapconfiguration/datastores.zcml |
|---|
| 117 |
|
|---|
| 118 |
Find the <gis:postgisDataStore> tag. Uncomment it. Edit its dns attribute |
|---|
| 119 |
by removing the user and password keyword/value pairs. |
|---|
| 120 |
|
|---|
| 121 |
8. Enable the map symbolizers in ZCML. |
|---|
| 122 |
|
|---|
| 123 |
ZCO needs to know about a number of symbolizers. Tell Zope about the |
|---|
| 124 |
symbolizers by editing: |
|---|
| 125 |
|
|---|
| 126 |
./src/ZCO/src/zco/mapconfiguration/symbolizers.zcml |
|---|
| 127 |
|
|---|
| 128 |
Uncomment: |
|---|
| 129 |
|
|---|
| 130 |
a. the pointSymbolizer with the name attribute of "circle." |
|---|
| 131 |
b. the lineSymbolizer |
|---|
| 132 |
c. the polygonSymbolizer |
|---|
| 133 |
d. the textSymbolizer |
|---|
| 134 |
|
|---|
| 135 |
9. Run the test cases. |
|---|
| 136 |
|
|---|
| 137 |
The really important test is: |
|---|
| 138 |
|
|---|
| 139 |
$ ./bin/zope-instance test -s primagis |
|---|
| 140 |
|
|---|
| 141 |
Other tests of individual dependencies are scripts in ./bin. It is not |
|---|
| 142 |
unusual to see some failures in edge cases for dependecies. The important |
|---|
| 143 |
test is running the PrimaGIS unit tests in the Zope instance as shown above. |
|---|
| 144 |
|
|---|
| 145 |
10. Start Zope |
|---|
| 146 |
|
|---|
| 147 |
Use: |
|---|
| 148 |
|
|---|
| 149 |
$ ./bin/zope-instance fg |
|---|
| 150 |
|
|---|
| 151 |
the first time in order to observe the start up messages for errors. For |
|---|
| 152 |
subsequent starts of Zope, use: |
|---|
| 153 |
|
|---|
| 154 |
$ ./bin/zope-instance start |
|---|
| 155 |
|
|---|
| 156 |
11. Browse the ZMI. |
|---|
| 157 |
|
|---|
| 158 |
Point a browser at the default for the buildout: |
|---|
| 159 |
|
|---|
| 160 |
http://localhost:7000/manage |
|---|
| 161 |
|
|---|
| 162 |
The userid and password for the buildout are both "admin." |
|---|
| 163 |
|
|---|
| 164 |
12. Create a Plone Site. |
|---|
| 165 |
|
|---|
| 166 |
In the root of the ZMI, add a Plone Site. It is not necessary to select any |
|---|
| 167 |
extension profiles. |
|---|
| 168 |
|
|---|
| 169 |
13. Install the PrimaGIS product in Plone. |
|---|
| 170 |
|
|---|
| 171 |
View the Plone Site just created. Go to Site Setup -> Add-on Products. |
|---|
| 172 |
Select PrimaGIS and click "Install." View the install log to see that the |
|---|
| 173 |
install was successful. |
|---|
| 174 |
|
|---|
| 175 |
14. Create a Map. |
|---|
| 176 |
|
|---|
| 177 |
In the root of the Plone Site, add a new Map item. Call it something like |
|---|
| 178 |
"World."After saving, click on the "Configure Map" tab, change the Map Units |
|---|
| 179 |
to Decimal Degrees, and click Apply. |
|---|
| 180 |
|
|---|
| 181 |
15. Create a Layer. |
|---|
| 182 |
|
|---|
| 183 |
A Map is a folderish item. It contains Map Layers of various stripes. First, |
|---|
| 184 |
add a Layer item to the Map. Call this Layer something like "World Borders." |
|---|
| 185 |
|
|---|
| 186 |
After saving, click on the "Configure Layer" tab. Select "teststore" |
|---|
| 187 |
(previously enabled in datasource.zcml) as the Spatial Data Source and |
|---|
| 188 |
postgis.world_borders as the feature set within that data source. |
|---|
| 189 |
Click Apply. |
|---|
| 190 |
|
|---|
| 191 |
After configuring the Layer, click on the "Manage Styles" tab. Add a new |
|---|
| 192 |
rule to the Layer. The only required fields are the Title and a Symbolizer. |
|---|
| 193 |
Call it something like "Borders." Select blueGreenPolygon for a Symbolizer |
|---|
| 194 |
(previously enabled in symbolizers.zcml). Click Save. |
|---|
| 195 |
|
|---|
| 196 |
16. Create a Presentation Layer. |
|---|
| 197 |
|
|---|
| 198 |
Return to the View of the Map item. Add a Presentation Layer to the Map. |
|---|
| 199 |
Call it something like "Boundaries," select the Layer you previously added |
|---|
| 200 |
to the Map and "Base layer" as the Layer type. Click Save. |
|---|
| 201 |
|
|---|
| 202 |
17. View the Map. |
|---|
| 203 |
|
|---|
| 204 |
Return to the View of the Map item. Select "OpenLayers" from the Display |
|---|
| 205 |
content action drop down menu. You should now see a map. |
|---|
| 206 |
|
|---|
| 207 |
If you see "an error occurred" on the map display, try zooming in on the |
|---|
| 208 |
map. PrimaGIS uses Zope RAM caching. A previous error in your Map item |
|---|
| 209 |
or any of the items it contains may be cached. Otherwise, the logs for the |
|---|
| 210 |
Zope instance are in ./var/log. |
|---|
| 211 |
|
|---|
| 212 |
Bootstrapping the buildout |
|---|
| 213 |
-------------------------- |
|---|
| 214 |
|
|---|
| 215 |
When the buildout is checked out from the repository it needs to be |
|---|
| 216 |
bootstrapped before it is ready to use. Simply run:: |
|---|
| 217 |
|
|---|
| 218 |
$ python bootstrap.py |
|---|
| 219 |
|
|---|
| 220 |
in the root of the buildout to get everything ready for work. You will |
|---|
| 221 |
need to use a Python version >= 2.4. This will not run the buildout, |
|---|
| 222 |
but will set the necessary scripts in the right places for doing it. |
|---|
| 223 |
|
|---|
| 224 |
After the bootstrapping you will have the buildout script in:: |
|---|
| 225 |
|
|---|
| 226 |
./bin/buildout |
|---|
| 227 |
|
|---|
| 228 |
which is used to run the actual buildout process. For a full listing |
|---|
| 229 |
of available options see:: |
|---|
| 230 |
|
|---|
| 231 |
./bin/buildout --help |
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 |
Buildout structure |
|---|
| 235 |
------------------- |
|---|
| 236 |
|
|---|
| 237 |
PrimaGIS buildout builds on top of other buildouts defined for some of |
|---|
| 238 |
the dependencies, namely other projects from the GIS-Python Laboratory |
|---|
| 239 |
(www.gispython.org). These buildouts are contained within the ``base`` |
|---|
| 240 |
directory. |
|---|
| 241 |
|
|---|
| 242 |
The main configuration file is ``buildout.cfg`` which in turn |
|---|
| 243 |
references the other buildouts from the ``base`` directory. You may |
|---|
| 244 |
wish to modify the configuration to change the Zope HTTP port or other |
|---|
| 245 |
settings. |
|---|
| 246 |
|
|---|
| 247 |
For more information on the individual buildouts refer to their |
|---|
| 248 |
corresponding ``README.txt`` files. |
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
Setting up PostgreSQL |
|---|
| 253 |
--------------------- |
|---|
| 254 |
|
|---|
| 255 |
PCL-Core contains code and tests that interacts with a PostgreSQL |
|---|
| 256 |
database. The buildout compiles the database server automatically, but |
|---|
| 257 |
test data must be populated with a manual step. |
|---|
| 258 |
|
|---|
| 259 |
In the root of the buildout directory is a python script called |
|---|
| 260 |
``init_postgresql.py`` that takes care of setting up a database for |
|---|
| 261 |
testing PCL. You can run by simply calling:: |
|---|
| 262 |
|
|---|
| 263 |
$ ./bin/python init_postgresql.py |
|---|
| 264 |
|
|---|
| 265 |
You can optionally set the port number by using the --port option. The |
|---|
| 266 |
default port is 5432. |
|---|
| 267 |
|
|---|
| 268 |
You can run the script as many times as you want, but be aware that it |
|---|
| 269 |
will reset the whole database. You shouldn't use the test database to |
|---|
| 270 |
store any important data as it will be lost on subsequent runs of the |
|---|
| 271 |
script. |
|---|
| 272 |
|
|---|
| 273 |
See the OSX Notes section below if you are using Mac OSX. |
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
Developing PrimaGIS |
|---|
| 277 |
------------------- |
|---|
| 278 |
|
|---|
| 279 |
All the PrimaGIS components will be installed as development eggs, so |
|---|
| 280 |
you can keep modifying the source on-the-fly. All editable source code |
|---|
| 281 |
is located under the ``src/`` directory within the buildout. |
|---|
| 282 |
|
|---|
| 283 |
There is also a Python interpreter script located in:: |
|---|
| 284 |
|
|---|
| 285 |
./bin/python |
|---|
| 286 |
|
|---|
| 287 |
which has all the relevant components available for instant use. |
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 |
OSX Notes |
|---|
| 291 |
--------- |
|---|
| 292 |
|
|---|
| 293 |
Running the PostgreSQL database server on Mac OS X may require |
|---|
| 294 |
modifying the amount of shared memory available on your system. See |
|---|
| 295 |
|
|---|
| 296 |
http://www.postgresql.org/docs/8.2/static/kernel-resources.html#SYSVIPC |
|---|
| 297 |
|
|---|
| 298 |
for more detailed instructions. |
|---|