Re: [web2py] authenticate against Active Directory - need some direction.

2011-02-11 Thread Panupat Chongstitwattana
using direct ldap class I am able to log in using the following settings

login = 'n...@domain.com'
PWD = 'password'
server = 'ldap://localhost'

l = ldap.initialize(server)
l.set_option(ldap.OPT_REFERRALS, 0)
l.protocol_version = 3
l.simple_bind_s(login, PWD):

I really can't get it working with web2py DAL. How can I check if it
is communicating with the active directory or not?

from gluon.tools import Auth
auth = Auth(globals(), db)
auth.define_tables(username=True)
from gluon.contrib.login_methods.ldap_auth import ldap_auth
auth.settings.login_methods = [ldap_auth(mode='ad',
   server='localhost',
   base_dn='dc=domain,dc=com')]


Re: [web2py] custom form without using database?

2011-02-10 Thread Panupat Chongstitwattana
What I meant was breaking the form down to pieces and put them at the
appropriate places. Like,

tr
td 'Name :' comes here /td
td INPUT _name comes here/td
/tr
tr
td 'Password :'/td
td INPUT _password /td

etc.

On Thu, Feb 10, 2011 at 7:37 PM, Bruno Rocha rochacbr...@gmail.com wrote:
 form = FORM()
 form.element().append(LABEL(_for='name',_value='Name'))
 form.element().append(INPUT(_type='text',_name='name'))
 print form
 form action= enctype=multipart/form-data method=postlabel
 for=name value=Name/labelinput name=name type=text //form
 ---
 Bruno Rocha
 http://about.me/rochacbruno/bio




Re: [web2py] Re: custom form without using database?

2011-02-10 Thread Panupat Chongstitwattana
Thanks Bruno the DIV(FORM()) trick is really nice.

Too bad there's no dd, dt, dl which is what I usually use for form
layouts. I guess I can always manually append them in.



On Thu, Feb 10, 2011 at 8:32 PM, Bruno Rocha rochacbr...@gmail.com wrote:
 Anyone know what properties I can call to get the hidden fields?

 Using SQLFORM you have form.hidden_fields()
 but using FORM you need to use Server side DOM and Parsing
 #
 # Create a form with hidden elements
 form =
 FORM(INPUT(_type='hidden',_value='secret'),INPUT(_type='hidden',_value='secret2'))
 print form
 form action= enctype=multipart/form-data method=postinput
 type=hidden value=secret /input type=hidden value=secret2
 //form
 #Get the hidden elements
 form.elements(_type='hidden')
 [gluon.html.INPUT object at 0xa35920c, gluon.html.INPUT object at
 0xa3592ec]
 #Get by its index
 form.elements(_type='hidden')[0]
 gluon.html.INPUT object at 0xa35920c
 # each one
 print form.elements(_type='hidden')[0]
 input type=hidden value=secret /
 print form.elements(_type='hidden')[1]
 input type=hidden value=secret2 /
 #iterate
 for element in form.elements(_type='hidden'): print element
 ...
 input type=hidden value=secret /
 input type=hidden value=secret2 /

 



Re: [web2py] Re: custom form without using database?

2011-02-10 Thread Panupat Chongstitwattana
Hi Villas

I'm sorry, I see what you meant now. I wasn't aware of the factory
feature before

:)

On Thu, Feb 10, 2011 at 11:52 PM, villas villa...@gmail.com wrote:
 On Feb 10, 1:16 pm, Panupat panup...@gmail.com wrote:
 Villas - I have read the book. The form.custom only works with SQLFORM
 and crud. I cannot use that same method with FORM.

 Hi Panupat,

 I reread your original post again and I notice that your initial
 comment was: In the book only mentioned how to use custom form with
 pre-defined database.

 Your assumption in that comment does not seem correct because I make
 forms without any database tables by using SQLFORM.factory.

 Best wishes
 David


Re: [web2py] Test if client has javascript

2011-02-09 Thread Panupat Chongstitwattana
Fist thing that comes to mind is the http-user-agent. I'm not sure if
javascript is stored in there but try print this via your browser

os.environ.get(HTTP_USER_AGENT)

see if that gives you anything.


On Thu, Feb 10, 2011 at 3:31 AM, ma...@rockiger.com
rocki...@googlemail.com wrote:
 The noScript-Tag works, but this way the database-query is executed. I would
 like
 to find about javascript in the request of the client.


[web2py] options_std.py missing from web2py_win download

2011-02-08 Thread Panupat Chongstitwattana
Was trying to figure this out for a while.

web2py_win comes with web2py.exe that starts the server immediately.
There was no installation and the options_std.py wasn't availabl
either.

I tried download the source, run web2py.py and options_std.py just showed up.


[web2py] web2py as service - error

2011-02-08 Thread Panupat Chongstitwattana
Following the book, trying to get web2py to work as service but
haven't gotten any luck so far.

Windows Server 2008 R2

C:\web2py python web2py.py -W install
No handlers could be found for logger web2py
web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.91.6 (2011-01-03 17:55:14)
Database drivers available: SQLite3, pymysql
Starting hardcron...
WARNING:web2py.cron:WEB2PY CRON: Disabled because no file locking
Traceback (most recent call last):
  File web2py.py, line 19, in module
gluon.widget.start(cron=True)
  File C:\web2py\gluon\widget.py, line 803, in start
web2py_windows_service_handler(['', options.winservice],
NameError: global name 'web2py_windows_service_handler' is not defined

start and stop are giving me the exact same message. What message
should I see if the service starts correctly?

A little confused about options.py too.
- options_std says numthreads is depreciated but in the book still
tells me to set it to 10.
- options not shown in the book such as interfaces, should I leave them there?
- ssl_xxx are also commented out in the options_std, should I set it
to blank value like the book suggests?


[web2py] web2py as windows service

2011-02-08 Thread Panupat Chongstitwattana
A couple questions.

I can't seem to get web2py to load the options. Either
python web2py.py -L options.py
or
python web2py.py -L options

give me the same error messages - Cannot import config file [options].
I'm running the command from web2py.py directory.
My options.py is exactly like the one listed on web2py online book.
Are there any changes need to be made?

Another question is, once the service has started, how do I access my
web2py site? IIS is already running on 127.0.01:80 how can I make it
not conflict with each other?


[web2py] Re: web2py as windows service

2011-02-08 Thread Panupat Chongstitwattana
Checking out web2py service from windows service manager. Turns out
web2py service stops itself right after it starts.

Any assistance please?


On Wed, Feb 9, 2011 at 11:13 AM, Panupat Chongstitwattana
panup...@gmail.com wrote:
 A couple questions.

 I can't seem to get web2py to load the options. Either
 python web2py.py -L options.py
 or
 python web2py.py -L options

 give me the same error messages - Cannot import config file [options].
 I'm running the command from web2py.py directory.
 My options.py is exactly like the one listed on web2py online book.
 Are there any changes need to be made?

 Another question is, once the service has started, how do I access my
 web2py site? IIS is already running on 127.0.01:80 how can I make it
 not conflict with each other?



[web2py] Web2py on Windows Server with IIS and URL Rewrite?

2011-02-06 Thread Panupat Chongstitwattana
Following the early chapters of the online book. I got web2py working
under 127.0.0.1:8000 but still confused with a couple things.

I'm learning web2py on a virtual server which mimics my company's set
up. The spec is as follow.
Windows Server 2008 R2
IIS7.5.
Python 2.7
MySQL 5.5

- Can I run web2py with the already running IIS7 service instead of
its own server? IIS already set up to recognize python scripts and
Django.

- The IIS needs to point the base of the website to a directory. For a
web2py site, which directory should this point to?

- I found a blog explaining how to set up ISAP_Rewrite 3, but IIS 7.5
now comes with its own URL Rewrite thing. Are there any tutorials
online about how to set this up?

best regards.