carolinux / gdata-python-client

Automatically exported from code.google.com/p/gdata-python-client
0 stars 1 forks source link

Bug in samples/analytics/data_feed_demo.py (using segments) #462

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1) If you add a segment into your data query, you get an error

What steps will reproduce the problem?
1. Add for example "'segment': 'gaid::-7'" to data_query
2. You get the error message: 'Segment' object is not iterable

The error ist reasonable because you just can have one segment, so thers's 
nothing to iterate on.

Solution: delete "for segment in self.feed.segment:" and replace it with 
"segment = self.feed.segment"

2) segment.defintion.value makes an error

What steps will reproduce the problem?
1. After fixing problem 1 you get the error message: 'Definition' object has no 
attribute 'value'

The error ist reasonable because the segment definition is not an attribute but 
inner text of the definition tag

Solution: Replace "segment.defintion.value" with "segment.defintion.text"

3) Code doesn't work with dynamic segment definitions

What steps will reproduce the problem?
1. After fixing problem 1 and 2, replace "'segment': 'gaid::-7'" with for 
example "'segment': 'dynamic::ga:country=~Germany' " (within data_query)
2. You get the error message: cannot concatenate 'str' and 'NoneType' objects

The problem here is that with dynamic segment definitions there are no 
attributes 'id' and 'name'.

Solution: Replace

print 'Segment Name       = ' + segment.name
print 'Segment Id         = ' + segment.id
print 'Segment Definition = ' + segment.definition.text

with

if segment.name: 
  print 'Segment Name       = ' + segment.name
if segment.id:
  print 'Segment Id         = ' + segment.id
print 'Segment Definition = ' + segment.definition.text 

What version of the product are you using?
http://code.google.com/p/gdata-python-client/source/browse/samples/analytics/dat
a_feed_demo.py

I hope my solutions are nice python code, because I'm quite a newbie to python.

Dear
sven

Original issue reported on code.google.com by sven.deg...@googlemail.com on 6 Nov 2010 at 10:44

GoogleCodeExporter commented 9 years ago
Fixed in daa8898c9254.

Original comment by joe.gregorio@gmail.com on 21 Jan 2011 at 8:35