Visitor IP & pre-populated toscawidget field from database

32 views
Skip to first unread message

Bas

unread,
Aug 2, 2009, 5:08:29 PM8/2/09
to TurboGears
Hello,

Thank you guys for the help and support so far.

I have two things that must be just easy and basic, but I just cant
find the syntax using Google.

1 Whats the correct syntax to get the visitors IP from a controller
methode for further use in the controller?
2 I want to make edit-forms in toscawidgets, whats the syntax to pre-
populate fields from database in toscawidget forms?

Thanks in advantage!

cd34

unread,
Aug 2, 2009, 9:57:24 PM8/2/09
to TurboGears
On Aug 2, 5:08 pm, Bas <elenbaa...@gmail.com> wrote:
>
> 1 Whats the correct syntax to get the visitors IP from a controller
> methode for further use in the controller?

in paster, the IP isn't passed in the environment:

import os
print os.environ['REMOTEHOST']

in wsgi, the IP is passed in the environment:

import os
print os.environ['REMOTE_ADDR']

With webob, I believe you can access the request object directly and
get the remote IP address:

http://turbogears.org/2.0/docs/modules/thirdparty/webob.html

> 2 I want to make edit-forms in toscawidgets, whats the syntax to pre-
> populate fields from database in toscawidget forms?

http://turbogears.org/2.0/docs/main/Wiki20/wiki20.html

Bas

unread,
Aug 3, 2009, 3:29:27 PM8/3/09
to TurboGears
I think I just pushed the wrong link and replied to author, and not to
the mailing list. Sorry for that.

On Aug 3, 3:57 am, cd34 <mcd...@gmail.com> wrote:

> > 1 Whats the correct syntax to get the visitors IP from a controller
> > methode for further use in the controller?
>
> in paster, the IP isn't passed in the environment:
>
>         import os
>         print os.environ['REMOTEHOST']
>
> in wsgi, the IP is passed in the environment:
>
>         import os
>         print os.environ['REMOTE_ADDR']
>
> With webob, I believe you can access the request object directly and
> get the remote IP address:
>
> http://turbogears.org/2.0/docs/modules/thirdparty/webob.html
>

Thank you for pointing me in the right direction.

> > 2 I want to make edit-forms in toscawidgets, whats the syntax to pre-
> > populate fields from database in toscawidget forms?
>
> http://turbogears.org/2.0/docs/main/Wiki20/wiki20.html

Sorry, but I can't find anything referring to ToscaWidgets on the page
where your link points to. I may overlooked it.

Plane html forms are not a problem, but ToscaWidgets has such nice
field validation including the error messaging. I know this is not a
ToscaWidgets-mailing list, but I figured that people here must know
how to handle ToscaWidgets.

Thanks in advance!

Diez B. Roggisch

unread,
Aug 3, 2009, 4:06:52 PM8/3/09
to turbo...@googlegroups.com
Bas schrieb:

> I think I just pushed the wrong link and replied to author, and not to
> the mailing list. Sorry for that.
>
> On Aug 3, 3:57 am, cd34 <mcd...@gmail.com> wrote:
>
>>> 1 Whats the correct syntax to get the visitors IP from a controller
>>> methode for further use in the controller?
>> in paster, the IP isn't passed in the environment:
>>
>> import os
>> print os.environ['REMOTEHOST']
>>
>> in wsgi, the IP is passed in the environment:
>>
>> import os
>> print os.environ['REMOTE_ADDR']
>>
>> With webob, I believe you can access the request object directly and
>> get the remote IP address:
>>
>> http://turbogears.org/2.0/docs/modules/thirdparty/webob.html
>>
>
> Thank you for pointing me in the right direction.
>
>>> 2 I want to make edit-forms in toscawidgets, whats the syntax to pre-
>>> populate fields from database in toscawidget forms?
>> http://turbogears.org/2.0/docs/main/Wiki20/wiki20.html
>
> Sorry, but I can't find anything referring to ToscaWidgets on the page
> where your link points to. I may overlooked it.

There are none.


> Plane html forms are not a problem, but ToscaWidgets has such nice
> field validation including the error messaging. I know this is not a
> ToscaWidgets-mailing list, but I figured that people here must know
> how to handle ToscaWidgets.

There is quite a bit of docu about that on the toscawidgets-site, and on
the TG2-docs:

http://toscawidgets.org/documentation/tw.forms/tutorials/index.html#making-the-form-post-and-validate
http://turbogears.org/2.0/docs/main/ToscaWidgets/forms.html


Diez

Bas

unread,
Aug 4, 2009, 3:36:24 PM8/4/09
to TurboGears


On Aug 3, 10:06 pm, "Diez B. Roggisch" <de...@web.de> wrote:

> >>> 2 I want to make edit-forms in toscawidgets, whats the syntax to pre-
> >>> populate fields from database in toscawidget forms?
> >>http://turbogears.org/2.0/docs/main/Wiki20/wiki20.html
>
> > Sorry, but I can't find anything referring to ToscaWidgets on the page
> > where your link points to. I may overlooked it.
>
> There are none.
>
> > Plane html forms are not a problem, but ToscaWidgets has such nice
> > field validation including the error messaging. I know this is not a
> > ToscaWidgets-mailing list, but I figured that people here must know
> > how to handle ToscaWidgets.
>
> There is quite a bit of docu about that on the toscawidgets-site, and on
> the TG2-docs:
>
> http://toscawidgets.org/documentation/tw.forms/tutorials/index.html#m...http://turbogears.org/2.0/docs/main/ToscaWidgets/forms.html
>
> Diez

Thanks for pointing me out, found it here →
http://toscawidgets.org/documentation/tw.forms/tutorials/db_tg2.html .
I must have overlooked it earlier.
Reply all
Reply to author
Forward
0 new messages