Data Engine/QML/Python Guidance Needed
Eric Mesa
ericsbinaryworld at gmail.com
Wed Aug 17 04:16:51 UTC 2011
On Monday, August 15, 2011 10:15:35 Aaron J. Seigo wrote:
> > On Mon, Aug 15, 2011 at 5:34 AM, Aaron J. Seigo <aseigo at kde.org> wrote:
> > > complex types from Python will not be able to be used from users of
> > > the>
>
> DataEngine. the data is being exported from the Python runtime, after
>
> > > all. you'll need to simplify the returns, e.g. turn the XML into a
> > > string and the> provide the list as a separate key/value pair.
> >
OK, trying to get a bit of help formatting things for the data engine. Here's
the relevant code in "views":
(begin code)
def analyzeviews(group_key):
#Get my photos from the views pool
pages = 1
group_photos = flickr.groups_pools_getPhotos(group_id=group_key,
user_id=user, per_page=perpage, page=pages)
print "Status: " + group_photos['stat'] + "\tViews: %d Pictures in group:
%s" % (numerical_views[group_key], group_photos.photos[0]['total'])
photoinfo =[]
if group_photos.photos[0]['total'] != "" and int(group_photos.photos[0]
['total']) > 0:
ids25 = [i['id'] for i in group_photos.photos[0].photo]
for id in ids25:
#print id
photoinfo.append(flickr.photos_getinfo(photo_id=id))
for number in range (1, int(group_photos.photos[0]['pages'])):
pages = pages + 1
group_photos = flickr.groups_pools_getPhotos(group_id=group_key,
user_id=user, per_page=perpage, page=pages)
ids25 = [i['id'] for i in group_photos.photos[0].photo]
for id in ids25:
#print id
photoinfo.append(flickr.photos_getinfo(photo_id=id))
print "done grabbing photos" #debugging
return photoinfo
(end code)
So, I realized that I didn't need to return a tuple, that was left over from
a previous idea I'd had with the script. So now I'm returning a list of XML
objects. So I'm partway there.
So, I'm just curious about the best way of doing this. I was thinking of
changing photoinfo.append(flickr.photos_getinfo(photo_id=id)) to
photoinfo.append(str(flickr.photos_getinfo(photo_id=id)))
and then I was going to change return photoinfo to return str(photoinfo) is
that the best way to do it?
Thanks!
-------------
Eric Mesa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20110817/89eb1d2c/attachment.sig>
More information about the Plasma-devel
mailing list