Hi Ken,

see if this is what you want:

1) Make an empty app, edit the model and add at the bottom

db.define_table('contact',db.Field('email',requires=IS_EMAIL()))
db.define_table('news',db.Field('title'),db.Field
('body','text'),db.Field('pub_datetime','datetime'))
import datetime; now=datetime.datetime.today()
for i in range(10): db.news.insert(title='news %i'%i,body='bla
'*100,pub_datetime=now)

2) Make a controller with a single action:

def index():
     news=db(db.news.pub_datetime>now-datetime.timedelta(7)).select
(orderby=~db.news.pub_datetime)
     form=SQLFORM(db.contact)
     if form.accepts(request.vars): response.flash='address stored'
     return dict(form=form, news=news)

3) Edit the view index.html and write

{{extend 'layout.html'}}
<h1>Add to Contacts</h1>{{=form}}
<h1>Last week news</h1>
{{for item in news:}}<h2>{{=item.title}}</h2><p>{{=item.body}}</p>
{{pass}}


Let us know if you need something different

On Dec 11, 6:26 am, "Ken Needham" <[EMAIL PROTECTED]> wrote:
> Well I guess I can because massimo already said so on StackOverflow
> I'm reposting here to find out how.
>
> As a way of evaluating Web2Py I tried reimplementing a web page in Web2Py.
> It seemed quite simple to start with but I'm not sure if it works the way I
> think.
>
> I've attached a trivial example of the sample web page I'm trying to
> recreate
> I have a simple page with an input field and button to add an email address.
> It has a menu bar which links to other pages
> And it has a couple of scrollable DIVs with content derived from a database.
>
> To implement this in Web2Py can I link actions to the various buttons and
> input fields?
> From my quick look at sample code it looks like all request for input is
> driven from database tables where I have little control over the formatting
>
> I'm sure I'm just looking at it all wrong because I come from a J2EE
> background and I just need to switch my mind into a different mode.
>
> Any help nudging me in the right direction much appreciated.
>
> Ken Needham
>
>  webpage.png
> 99KViewDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to