Adding first tree from web interface fails; second tree succeeds!

43 views
Skip to first unread message

Bob Troester

unread,
Apr 6, 2013, 4:12:48 PM4/6/13
to opentree...@googlegroups.com
I have described part of this problem in a reply to Keith Bornhorst's thread below "NameError at /trees/add/ - global name 'content_type' is not defined" (https://groups.google.com/forum/?fromgroups=#!topic/opentreemap-user/JX52c3uO2ws) but now I see further oddities:

Using the web interface, if I try to add a tree in a neighborhood NOT containing any other trees, the add fails with an exception "IntegrityError at /trees/add/ - null value in column "annual_stormwater_management" violates not-null constraint" - but if I first add a tree using uimport.py, the SECOND tree I add in that neighborhood is accepted without a quibble!

The problem traceback through the OTM code goes from treemap/views.py (method tree_add, line 1394) to shortcuts.py (validate_form, 14) to forms.py (save, 157) to models.py (save, 615) and finally to models.py (update_aggregate, 644 in class Plot). Further down the traceback, when execution gets to psycopg2, the SQL is shown as
query    
'INSERT INTO "treemap_resourcesummarymodel" ("annual_stormwater_management",
"annual_electricity_conserved", "annual_energy_conserved", "annual_natural_gas_conserved",
"annual_air_quality_improvement", "annual_co2_sequestered", "annual_co2_avoided",
"annual_co2_reduced", "total_co2_stored", "annual_ozone", "annual_nox", "annual_pm10",
"annual_sox", "annual_voc", "annual_bvoc")
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'

where the args for the resources are given as
(None,None,None,None,None,None,None,None,None,None,None,None,None,None,None)

In other words it is trying to initialize everything as null, an invalid value. I notice, for what it's worth, that there are two update_aggregate methods in models.py. In the companion update_aggregate method, in class Tree, there are provisions to initialize to zero, but not in the method in class Plot.

Since I am the only one with this problem, it clearly seems to be an initialization problem on my part. What did I miss in setting up the application to this point? I have updated to the latest 1.3 version with Josh Livni's SanFrancisco templates, lightly modified. I have certainly run syncdb and migrate several times, and when I run python manage.py test treemap I only see a reference to CitizenAtlas in treemap/views.py and some oddities about the csv, kvm, kml, and shp output files, but the test code seems to be able to add a tree (as does the batch load program, uimport.py). What do I have to do to initialize the resources properly for the web interface?

So close and yet so far. I would be *very* grateful for any help (and for any for the "content_type" problem in Keith's thread too!)
Bob

Adam Hinz

unread,
Apr 6, 2013, 4:18:48 PM4/6/13
to opentree...@googlegroups.com
Hey Bob,

Did you load up iTree Eco benefit data?

-Adam

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "opentreemap-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opentreemap-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Message has been deleted

Bob Troester

unread,
Apr 7, 2013, 3:29:00 PM4/7/13
to opentree...@googlegroups.com
Thanks Adam for that suggestion!

1)It impelled me to look back at all the forum posts on iTree and I noticed a reference to running 'python manage.py update_aggregates'. Looking further I saw it was step 6 in the wiki page "First Installation" - and of course I had missed it, duh. After I ran update_aggregates, I was then able to add trees freely, even the first tree in a neighborhood. A big thanks!

2)However, now we're back to *editing* a tree, or rather, *not* being able to edit certain characteristics, like the Environmental features, or dragging its position. See my post in Keith's thread about "global name 'content_type' is not defined" (https://groups.google.com/forum/?fromgroups=#!topic/opentreemap-user/JX52c3uO2ws). Any thoughts on that?

3)And for extra bonus points! - in the External Data wiki page there is the comment, 'OpenTreeMap requires cost values for 10 benefits trees bring to the urban landscape. Defaults for each region can be found in iTree's data files, however you may be able to locate more accurate data for your specific city or area. Enter the following values in the "treemap_benefitvalues" table. (etc.)'

The fields in the treemap_benefitvalues tables as I see them are uniformly 0.01 - like electricity 0.01 dollar per kWh. Does doing the itree_import somehow automatically override those numbers with the treemap_resource data, or are the appropriate numbers to be found elsewhere in other iTree data files? If it is necessary to update treemap_benefitvalues, does one do it directly with pgadmin3 or psql or is there a form that I've missed?

4) And for good measure - in my case, when itree_import loaded the treemap_resource table, it set the region field to "NorthernCalifornia". As far as I can see from the code, that is just a default region field value set for each new entry loaded in the table, but not set when the table is later updated(?) It looks like I can just ignore it, but is there any problem in leaving the region field like that for those of us on the east coast, for instance?

I hope this isn't an undigestible lump of questions. OTM is an amazingly big system, I'm only just beginning to appreciate how impressive it is!
Bob

jr...@courtdatatech.com

unread,
Apr 12, 2013, 6:28:32 PM4/12/13
to opentree...@googlegroups.com
Hey Bob
 re: 2) content_type  problem moving a tree

the error is really misleading but this solved my problem 

check your django_reputationreputationaction table
adding row 5 and 6 did it for me...

make sure it has the following lines

1;"add tree";"Reputation to add a tree"
2;"edit tree";"Reputation to edit a tree"
3;"edit verified";"Can edit a verified tree"
4;"Administrative Action";"Can administer site"
5;"add plot";"Reputation to add a plot"
6;"edit plot";"Reputation to edit a plot"

Reply all
Reply to author
Forward
0 new messages