This widget is ripped off from plugin_wiki but doesn't require it:
model
------
db.define_table('youtube',Field('code'))
def youtube_repr(code,width=400,height=250):
return XML("""<object width="%(width)s" height="%
(height)s"><param name="movie" value="http://www.youtube.com/v/%
(code)s&hl=en_US&fs=1&"></param><param name="allowFullScreen"
value="true"></param><param name="allowscriptaccess" value="always"></
param><embed src="http://www.youtube.com/v/%(code)s&hl=en_US&fs=1&"
type="application/x-shockwave-flash" allowscriptaccess="always"
allowfullscreen="true" width="%(width)s" height="%(height)s"></embed></
object>""" % dict(code=code, width=width, height=height))
db.youtube.code.represent = youtube_repr
controller
----------
def index():
form = SQLFORM(db.youtube)
if form.accepts(request.vars,session):
response.flash = 'Video added'
vids = db(db.youtube.id>0).select()
return dict(form=form,vids=vids)
On Nov 26, 12:00 pm, Andrew Evans <[email protected]> wrote:
> How can I add a youtube video in web2py... Say a user in my blog submits a
> form containing youtube video code how can I embed that code in the post?
>
> *cheers