How do I view text on view.html

46 views
Skip to first unread message

Maurice Waka

unread,
Jun 16, 2014, 6:08:55 AM6/16/14
to web...@googlegroups.com
 My code:



class Person(): name = 'Victor' def say(self, what): print(self.name, what)

getattr(person, attr_name)

How do I display 'Victor' on web2py html.view?

I tried using:

{{=getattr(person, attr_name)}}
 

 I know this could be wrong and I cant get a result either


Carlos Costa

unread,
Jun 16, 2014, 7:36:44 AM6/16/14
to web...@googlegroups.com
You should create and action for that view and pass it in dictionary to the view


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Att.

Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom
<º))><

Maurice Waka

unread,
Jun 16, 2014, 9:17:37 AM6/16/14
to web...@googlegroups.com
@ Carlo, that's where am stuck


You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/ERdNYzSpnEk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Dr Maurice Waka, MBCHB.
Nairobi

Anthony

unread,
Jun 16, 2014, 9:24:54 AM6/16/14
to web...@googlegroups.com
This doesn't look anything like typical web2py code. I would recommend that you read some of the book and follow the typical patterns and then come back with questions if you're having trouble. In general, though, note that you won't be using the print statement to display anything in HTML pages -- print is for printing to the console.

Anthony

LoveWeb2py

unread,
Jun 16, 2014, 11:31:32 AM6/16/14
to web...@googlegroups.com


On Monday, June 16, 2014 6:08:55 AM UTC-4, Maurice Waka wrote:

If you want to get 'Victor' in a view you could do something simple like:

Controller:
def name_return():
     name = 'Victor'
     return dict(name=name)

view name_return.html:

{{extend 'layout.html'}}
{{=name)

LoveWeb2py

unread,
Jun 16, 2014, 11:32:15 AM6/16/14
to web...@googlegroups.com

Carlos Costa

unread,
Jun 16, 2014, 11:42:39 AM6/16/14
to web...@googlegroups.com
I guess you need to familiarize yourself more with not just with web2py but also with web development, right?

Anthony is right, you should read web2py book at www.web2py.com/book, at least the first chapters to get a start.
At first you need to understand MVC.

For example you may have:
in db.py (Model)
class Person():
     name = 'Victor'

in default.py (Controler)

def index():
    person = Person()
    return dict(person=person)

in default/index.html (View)

{{=person.name}}



--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Maurice Waka

unread,
Jun 17, 2014, 2:28:24 AM6/17/14
to web...@googlegroups.com
Thanks! it works!


--
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/ERdNYzSpnEk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages