[web2py] Re: DAL read and variables

2014-01-17 Thread DAL read and variables


push, please, i still have no idea

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: DAL read and variables

2014-01-17 Thread Matheus Cardoso
I did not follow you right, but I'll try to help you where I did understand.

In 1. where you say "i want to get a link with the text "Hier kann man 
Daten eingeben." and a link to "eingeben"". You could use the A() helper . 
As the following:

A("Hier kann man Daten eingeben.",_href=URL('eingeben'))

It will generates to you this: 
Hier kann man Daten eingeben.

Ok?

For 2. and 3. I did not understand your doubt. If you want to put 'marc' 
result in a variable, just do this:

newvariable = records[0].name

Got it? And above I did assume that there is only one record on results.

On Tuesday, January 14, 2014 7:33:58 PM UTC-3, DAL read and variables wrote:
>
> Hi guys,
>
> this question is about tree things at once.
> The first on is as follow:
> I have this code:
>
> [code]
>
> in the models (not so importantthis part works fine):
>
> dba = DAL('mysql://web2py:test@localhost/testdb')
> dba.define_table('person', Field('name', requires=IS_NOT_EMPTY()), 
> Field('email', requires=IS_NOT_EMPTY()))
>
>
> in the controller:
>
>
> def index():
> a = 'Hallo Besucher. Wie geht es ihnen?'
> b = 'Hier kann man Daten eingeben. ', URL('eingeben')
> c = 'Hier kann man daten ausgeben'
> 
> return dict( Welcome=a, eingabe=b, showdata=c)
> 
> def eingeben():
> form = SQLFORM(dba.person)
> form.add_button('records', URL('ausgabe'))
> if form.process().accepted:
> session.flash = 'form accepted'
> redirect(URL('ausgabe'))
> elif form.errors:
> response.flash = 'form has errors'
> else:
> response.flash = 'please fill out the form'
>
> return dict(form=form)
> 
> def ausgabe():
> a = 4
> records = SQLTABLE(dba(dba.person._id== 1).select(dba.person.name
> ),headers='fieldname:capitalize')
> return dict(records=records)
>
> [/code]
>
> 1. in def index(), you see this:
> b = 'Hier kann man Daten eingeben. ', URL('eingeben') 
> but this does not work fine, i want to get a link with the text "Hier kann 
> man Daten eingeben." and a link to "eingeben"
>
> 2. in def ausgabe(), you see this:
>
> variable = 4
> records = SQLTABLE(dba(dba.person._id== variable).select(
> dba.person.name),headers='fieldname:capitalize')
> it should work like this, the variable in the first line should be used in 
> the dba.person._id==variable
>
>
> 3. 
> def ausgabe():
> a = 4
> records = SQLTABLE(dba(dba.person._id== 1).select(dba.person.name
> ),headers='fieldname:capitalize')
> return dict(records=records)
>
> ok, lets assume, the first line in the data bank is 1 marc 
> te...@gmail.com
>
> the code on the top leeds to the following output:
> Name
> marc
>
> is there some way to get a variable like 
> newvariable = 'marc'
>
>
> I hope you can help me, i spent hours in trying, but i didn't found 
> anything that  helped me. the handbook doesnt cover such basic stuff , or i 
> didn't found it :(
>
> Thank you very much,
> Darren
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.