To get an idea of T2 and T3 I am going through the Web Design Patterns
and T2 Components PDF of October 21 2008.
My problem is that the display_puppy function doesn't create an image
preview, it creates a link labeled download.
My model reads like:
db=SQLDB('sqlite://storage.db')
db.define_table('puppy',
SQLField('name'),
SQLField('image','upload'),
migrate='puppy.table')
db.puppy.name.requires=IS_NOT_EMPTY()
db.puppy.represent=lambda puppy: A(puppy.name,_href=t2.action
('display_puppy',puppy.id))
from applications.plugin_t2.modules.t2 import T2
t2=T2(request,response,session,cache,T,db)
My controller reads like:
def create_puppy():
form=t2.create(db.puppy)
itemize=t2.itemize(db.puppy)
return dict(form=form,itemize=itemize)
def display_puppy():
puppy=t2.display(db.puppy)
search=t2.search(db.puppy)
return dict(puppy=puppy,search=search)
def download():
return t2.download()
I modified the layout view:
{{extend '../../plugin_t2/views/layout.html'}}
{{include}}
And the specific views read like:
{{extend 'layout.html'}}
<div class="frame">
<h2>Post the image of a puppy</h2>
{{=form}}
</div>
<div class="frame">
<h2>Puppies</h2>
{{=itemize}}
</div>
{{extend 'layout.html'}}
<div class="frame">
<h2>A puppy</h2>
{{=puppy}}
</div>
<div class="frame">
<h2>Search puppies</h2>
{{=search}}
</div>
Best regards,
Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---