In the case that I'm dealing with, the image is incidental to the problem. 
But let's say there is an image, and a relative URL (i.e. file download); 
you can do something like this:

    db.my_db.file.represent = lambda x,y: \
                            A(generate_image(y.file),
                            _href=URL(args=["my_db/download", x],vars = 
dict(action="update_download_number", id=y.id)))

Can't do this for absolute links. Maybe I'm misunderstanding your 
suggestion, but the same image generator function will be invoked for all 
of the rows in the table, so if I use that, all the rows end up being 
updated, as opposed to the one which should be updated. So basically, I 
think it comes down to how to go about creating a function that's invoked 
when an absolute link is clicked, and passing an identifier related 
specifically to that link to the function.

On Wednesday, March 27, 2013 2:41:16 PM UTC-5, Niphlod wrote:
>
> so, you have an url (i.e. a string) that needs to return an image.
> you should have a controller that, when that URI is matched, returns the 
> image after increasing its number_visited value.... seems pretty standard 
> to me....
>
> On Wednesday, March 27, 2013 7:15:12 PM UTC+1, Lamps902 wrote:
>>
>> Let's say you have an SQL grid generated from a db with field *my_url*, 
>> which stores the value of an absolute URL, and has a representation defined 
>> in this way: 
>>
>> db.my_db.my_url.represent = lambda the_url, row: A(generate_link_image(), 
>> _href=the_url, _target='_blank')
>>
>> What would be a good way to modify the above code so that when the link 
>> is clicked, some field in *my_db* (for example, *number_visited*, 
>> corresponding to the number of times the url has been clicked) is updated? 
>> I'm not sure you can use _href=URL(...) with absolute links, and other 
>> variants I've tried end up updating every record referenced in the table 
>> rather than just the one that the user clicks. Thanks.
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to