[web2py] Re: How to extend IMG to preprocess url

2012-08-21 Thread Anthony
Maybe something like:

class MYIMG(IMG):
def __init__(self, *components, **attributes):
if '_src' in attributes:
attributes['_src'] = mangle(attributes['_src'])
return super(MYIMG, self).__init__(*components, **attributes)

Then you can do:

MYIMG(_src=URL('static', 'someimage.jpg'))

and the _src URL will be altered automatically.

Anthony

On Tuesday, August 21, 2012 11:36:18 AM UTC-4, AngeloC wrote:

 Hi guys,

 Any advice on howto extend IMG to preprocess url? I simply want to mangle 
 url before it passed to IMG and this should be done every time an IMG tag 
 is used.

 Thanks!

 -- 
 Profile: http://it.linkedin.com/in/compagnucciangelo
  

-- 





Re: [web2py] Re: How to extend IMG to preprocess url

2012-08-21 Thread Angelo Compagnucci
Wow!

I'll try ASAP, thank you!

2012/8/21 Anthony abasta...@gmail.com

 Maybe something like:

 class MYIMG(IMG):
 def __init__(self, *components, **attributes):
 if '_src' in attributes:
 attributes['_src'] = mangle(attributes['_src'])
 return super(MYIMG, self).__init__(*components, **attributes)

 Then you can do:

 MYIMG(_src=URL('static', 'someimage.jpg'))

 and the _src URL will be altered automatically.

 Anthony

 On Tuesday, August 21, 2012 11:36:18 AM UTC-4, AngeloC wrote:

 Hi guys,

 Any advice on howto extend IMG to preprocess url? I simply want to mangle
 url before it passed to IMG and this should be done every time an IMG tag
 is used.

 Thanks!

 --
 Profile: 
 http://it.linkedin.com/in/**compagnucciangelohttp://it.linkedin.com/in/compagnucciangelo

  --







-- 
Profile: http://it.linkedin.com/in/compagnucciangelo

--