What I meant was to re-use the photo entry that GData returns to you
upon a 409 error.
In other words: When an update (or delete) request fails because the
version used
in a request URL doesn't match the server side version, a 409 error is
returned along with
the current service side copy of the photo entry (just the metadata,
not the media).
This will essentially save you another roundtrip doing an extra GET
request.
This photo entry contains the currently valid "edit" and "edit-media"
links that should be
used to send the next request to. From your code it looks like the
Python library does that for you
and you don't have to extract the edit URL yourself. Just take what
the error returned,
re-apply your metadata changes (in case the metadata edit request
failed) and
call UpdatePhotoMetadata again (or UpdatePhotoBlob).

I'm not sure why you were seeing a Bad Request error.
I checked your image and it currently seems to have version 5. So a
simple GET or a failed update
should give you an edit link that looks like
http://picasaweb.google.com/data/entry/api/user/vallsdotname/albumid/5365689932489135537/photoid/5365689989036907650/5?authkey=Gv1sRgCLDEx9OSxMyCzgE
and an edit-media link like
http://picasaweb.google.com/data/media/api/user/vallsdotname/albumid/5365689932489135537/photoid/5365689989036907650/5?authkey=Gv1sRgCLDEx9OSxMyCzgE

The authkey part is always appended for unlisted albums. You basically
don't need that since you are authenticated when doing edits anyway.


On Aug 12, 8:36 am, Josep Valls <[email protected]> wrote:
> Sorry to bother again. Your previous solution for the gdata library
> worked like a charm, but I'm trying to get rid of some overhead and
> doing plain requests.
> I fixed the URL to point to a picture, I authenticate and then I try
> the URL for a picture. I.E.
> url = 'http://picasaweb.google.com/data/media/api/user/vallsdotname/
> albumid/5365689932489135537/photoid/5365689989036907650/1'
> this gives me a Error! Got "409 Conflict"
> Right, I updated the picture using GData, so my guess is that the
> version will be 2, so I try again with the url:
> url = 'http://picasaweb.google.com/data/media/api/user/vallsdotname/
> albumid/5365689932489135537/photoid/5365689989036907650/2'
> but i get  the same. ok, I'll keep increasing the version number, but
> when I try 3 i get Error! Got "400 Bad Request".
> I think I didn't understand your proposed solution of the retry option
> on 409. What way should I retrieve the version number?
> Anyway, the thing is that then I use the gdata library and when I
> record the session, there are some headers that don't match what the
> protocol documentation shows. What is the data after the version
> number (?authkey=Gv1sRgCLDEx9OSxMyCzgE)? It's the 3rd log:
>
> Here are the Http logs.
>
> Send: Return Code: 0x00000000
> PUT /data/media/api/user/vallsdotname/albumid/5365689932489135537/
> photoid/5365689989036907650/2 HTTP/1.1
> Host: picasaweb.google.com
> Accept-Encoding: identity
> Content-Type: image/jpeg
> Content-Length: 66993
> Authorization: GoogleLogin auth=DQAAAIwAAAAs8MVs5Z6Ede9Sdp5iM-
> Pm91ElbMbvODKEv0DMqk8RkzDwkCh9Nf1NNnfdUjHcjLSzHkAuWc9Kf3mmj6enkb4vW1BLTmTmT39THURKyOyCa8kiOsAgovofgVOBeQmNCRx4Og0966Obm81I0F0nCr4BzxJqwFAE-94JGHfkYRn_g6h0j2Qx4tE4cgZ2uejdPRQ
> Send: Return Code: 0x00000000
> 00000000  FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00
> 60    ......JFIF.....`
>
> Send: Return Code: 0x00000000
> PUT /data/media/api/user/vallsdotname/albumid/5365689932489135537/
> photoid/5365689989036907650/3 HTTP/1.1
> Host: picasaweb.google.com
> Accept-Encoding: identity
> Content-Type: image/jpeg
> Content-Length: 66993
> Authorization: GoogleLogin
> auth=DQAAAIoAAAA1V68EloXFPZHFZQHJMuFgdJ2dNBqKJtAEsyzD79GmcM_vSZroxVBvikANuQZRlk4hn9fd8Z5NqsYVGwlB50Kjh0WDeXtMh_afdtnAlA9tZG0AzX9lOFZ-
> cafeit2j_6Lgl0rBIUSUgo84T9bVr1dXQj9TRcaY8OfozbBmUn7chr9cmFDW26fZZiztaCgCtVM
> Send: Return Code: 0x00000000
> 00000000  FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00
> 60    ......JFIF.....`
>
> Send: Return Code: 0x00000000
> PUThttp://picasaweb.google.com/data/media/api/user/vallsdotname/albumid/...
> HTTP/1.1
> Accept-Encoding: identity
> Host: picasaweb.google.com
> Content-Length: 9474
> Content-Type: image/jpeg
> Authorization: GoogleLogin auth=DQAAAIsAAAAnRTjWtj0r40gP5eiH-
> C0Y785TOIrWNXtJISJSFlmSbPlOXO1pT6ELOZPIK6IAhS1aQtYYYGzUTiMNcvqQ5EF4_2cxAJyVxJe_7iNWLvNsAppUXEPuxCRqX8h-
> k6vpf71Z_hNyVV5P0hJ86v-E-QLRwwAaHqEuFVz8FMjDgUXt6PxW5WTh7xAO8MA-
> bPhtz58
> User-Agent: None GData-Python/1.3.3
> Send: Return Code: 0x00000000
> 00000000  FF D8 FF E0 00 10 4A 46 49 46 00 01 01 00 00
> 01    ......JFIF......
>
> On Aug 10, 4:28 pm, Detlev <[email protected]> wrote:
>
> > It seems that you ran into an issue that we haven't found a good
> > solution for yet:
> > Our photo storage servers maintain a version number for every photo.
> > This version gets updated every time the meta data or the binary data
> > is updated either externally or internally. It is the case that for a
> > metadata update, that version number gets incremented twice: the first
> > time when you make your first edit call, the second time when some
> > asynchronous process that gets triggered has finished and touches the
> > photo again. For GData calls that unfortunately currently has the
> > effect, that the updated entry being returned from your first edit
> > call has the version number incremented by 1. This new version number
> > is then used by your second request to edit the binary data.
> > Unfortunately, in the meantime, the photo version has been increased a
> > second time and so the version you are sending up in you second edit
> > call does not match the current version anymore and you get a 409
> > error.There are two possible workarounds in your case:
> > A. Update meta data and binary data in a single request after you are
> > done processing the image:
> > 1. query current photo entry
> > 2. apply your meta data edits to the entry (e.g. caption, title aka
> > filename)
> > 3. make your UpdatePhoto call
>
> > B. the other option is to build in a retry mechanism based on
> > receiving a 409:
> > 1. when an update fails with a version conflict, just retry it using
> > the most recent photo entry that is being returned with the failure.
> > You'll have to apply your metadata changes again though.
>
> > On Aug 8, 8:28 am, Josep Valls <[email protected]> wrote:
>
> > > My code is as follows:
> > > import gdata.photos.service
> > > import gdata.media
> > > import gdata.geo
> > > import atom
>
> > > username = 'vallsdotname'
> > > email = 'XXX'
> > > password = 'XXX
> > > source = 'vallsdotname-albumlist-1'
> > > filename = 'C:/Users/Valls/Downloads/Desktops/
> > > 00660_splash_2560x1600.jpg'
>
> > > pws = gdata.photos.service.PhotosService()
> > > pws.ClientLogin(username, password)
> > > albums = pws.GetUserFeed().entry
> > > photos = pws.GetFeed(albums[0].GetPhotosUri()).entry
> > > album = albums[0]
> > > photo = pws.InsertPhotoSimple(album_url, 'New Photo', 'Uploaded using
> > > the API', filename, content_type='image/jpeg')
> > > photo = photos[8]
> > > photo.rotation = gdata.photos.Rotation(text='90')
> > > photo = pws.UpdatePhotoMetadata(photo)
> > > # so far so good
> > > ph = pws.UpdatePhotoBlob(photo, filename)
> > > # errors
> > > fh = open(filename, 'rb')
> > > ph = pws.UpdatePhotoBlob(photo, fh)
> > > # errors
>
> > > And this is what I captured. Hopefully will be enough. Any advice on
> > > http monitors?
>
> > > Send: Return Code: 0x00000000
> > > PUThttp://picasaweb.google.com/data/media/api/user/vallsdotname/albumid/...
> > > HTTP/1.1
> > > Accept-Encoding: identity
> > > Host: picasaweb.google.com
> > > Content-Length: 176489
> > > Content-Type: image/jpeg
> > > Authorization: GoogleLogin
> > > auth=DQAAAIwAAAAMe34fRcNb3L_9GuxNfNbdk2cfgk886rkmn1PZ9tGBcy1gPTuROvNgbgQi8eqfP_XY5K5WPmSbtw5SmOPm8huMK-
> > > WQ4oAaRboug_bmtjzHz7JgqkyerDQSdpteFrsWK0CXJZpfpdBghMRT0gLkGMEMVaiSx9lsSMT7DADG8H3HyT7ehSJeW4oIdGiRxA-
> > > Fcx4
> > > User-Agent: None GData-Python/1.3.3
>
> > > Send: Return Code: 0x00000000
> > > 00000000  FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00
> > > 48    ......JFIF.....H
> > > [...]
>
> > > Receive: Return Code: 0x00000000
> > > <?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/
> > > 2005/Atom' xmlns:exif='http://schemas.google.com/photos/exif/2007'
> > > xmlns:gphoto='http://schemas.google.com/photos/2007'
> > > xmlns:media='http://search.yahoo.com/mrss/'><id>http://
> > > picasaweb.google.com/data/entry/api/user/vallsdotname/albumid/
> > > 5365689932489135537/photoid/5367284203201802034</
> > > id><published>2009-08-07T18:03:55.000Z</
> > > published><updated>2009-08-08T15:17:16.503Z</updated><category
> > > scheme='http://schemas.google.com/g/2005#kind'term='http://
> > > schemas.google.com/photos/2007#photo'/><title type='text'>New Photo</
> > > title><summary type='text'>Uploaded using the API</summary><content
> > > type='image/jpeg' src='http://lh4.ggpht.com/_vgXOso7OdEA/Snxsi7RorzI/
> > > AAAAAAAAB6k/j-KVLIK75LQ/New%20Photo.jpg'/><link rel='http://
> > > schemas.google.com/g/2005#feed' type='application/atom+xml'
> > > href='http://picasaweb.google.com/data/feed/api/user/vallsdotname/
> > > albumid/5365689932489135537/photoid/5367284203201802034?
> > > authkey=Gv1sRgCLDEx9OSxMyCzgE'/><link rel='alternate' type='text/html'
> > > href='http://picasaweb.google.com/vallsdotname/2009_07_29?
> > > authkey=Gv1sRgCLDEx9OSxMyCzgE#5367284203201802034'/><link rel='http://
> > > schemas.google.com/photos/2007#canonical' type='text/html'
> > > href='http://picasaweb.google.com/lh/photo/BdP8LrkztXzpxc4vYnpPmg?
> > > authkey=Gv1sRgCLDEx9OSxMyCzgE'/><link rel='self' type='application/atom
> > > +xml' href='http://picasaweb.google.com/data/entry/api/u
> > > Receive: Return Code: 0x00000000
> > > ser/vallsdotname/albumid/5365689932489135537/photoid/
> > > 5367284203201802034?authkey=Gv1sRgCLDEx9OSxMyCzgE'/><link rel='edit'
> > > type='application/atom+xml' href='http://picasaweb.google.com/data/
> > > entry/api/user/vallsdotname/albumid/5365689932489135537/photoid/
> > > 5367284203201802034/32?authkey=Gv1sRgCLDEx9OSxMyCzgE'/><link rel='edit-
> > > media' type='image/jpeg' href='http://picasaweb.google.com/data/media/
> > > api/user/vallsdotname/albumid/5365689932489135537/photoid/
> > > 5367284203201802034/32?authkey=Gv1sRgCLDEx9OSxMyCzgE'/><link
> > > rel='media-edit' type='image/jpeg' href='http://picasaweb.google.com/
> > > data/media/api/user/vallsdotname/albumid/5365689932489135537/photoid/
> > > 5367284203201802034/32?authkey=Gv1sRgCLDEx9OSxMyCzgE'/><link
> > > rel='http://schemas.google.com/photos/2007#report'type='text/html'
> > > href='http://picasaweb.google.com/lh/reportAbuse?
> > > uname=vallsdotname&amp;aid=5365689932489135537&amp;iid=5367284203201802034'/><gphoto:id>5367284203201802034</gphoto:id><gphoto:version>32</
>
> > > gphoto:version><gphoto:albumid>5365689932489135537</
> > > gphoto:albumid><gphoto:access>private</
> > > gphoto:access><gphoto:width>1200</gphoto:width><gphoto:height>1600</
> > > gphoto:height><gphoto:size>117066</gphoto:size><gphoto:client/><gphoto:checksum/><gphoto:timestamp>1249668235000</
>
> > > gphoto:timestamp><gphoto:imageVersion>1961</
> > > gphoto:imageVersion><gphoto:commentingEnabled>true</
> > > gphoto:commentingEnabled><gphoto:commentCount>1</
> > > gphoto:commentCount><exif:tags><exif:imageUniqueID>5e2680042d568e46fdcf7b2ee89f2a7b</
> > > exif:imageUniqueID></exif:tags><media:group><media:content url='http://
> > > lh4.ggpht.com/_vgXOso7OdEA/Snxsi7RorzI/AAAAAAAAB6k/j-KVLIK75LQ/New
> > > %20Photo.jpg'
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Picasa Web Albums API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Picasa-Data-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to