#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    10
    Rep Power
    0

    from ZPT(forms) to python scripts?


    Hi,
    Im now working with forms from zope page templates. Im accepting inputs of the Username and Password. The names of the input on the forms are '__ac_name' and '__ac_password'
    They are named this way because of the use of cookies in Plone.
    I would then create a python script but i couldnt pass in the parameter because "_" is not a valid character for parameters. I figure a variable passed is only a string. Is there any way around this?
    Last edited by JuiceMan; January 16th, 2004 at 04:21 PM.
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    To be honest you lost me on that last part, how do you mean '_' is not a valid parameter?

    Do you have a any code you could show us, might make what you're wanting to do a little clearer... or at least to me

    Or maybe you could explain exactly what you want this Python script to do? On what platform/server etc.

    Mark
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    10
    Rep Power
    0
    I'm sorry for not being clearer.

    The python script is from Plone's dropdown menu.

    The variable that I am trying to get from the form is named '__ac_name' and the double underscore at the front isnt valid in python.


    ## Script (Python) "logged_in"
    ##bind container=container
    ##bind context=context
    ##bind namespace=
    ##bind script=script
    ##bind subpath=traverse_subpath
    ##parameters=__ac_name, __ac_password
    ##title=login
    ##

    from DateTime import DateTime
    REQUEST=context.REQUEST

    name = REQUEST.get('__ac_name')
    password = REQUEST.get('__ac_password')

    success = context.checkPassword(name, password)


    login_failed = 'login_failed'
    login_success = 'login_success'

    if success == 'true':
    return context.restrictedTraverse(login_success)()

    return context.restrictedTraverse(login_failed)()

    I'm working from the ZMI and the zmi gives me this error message:

    Line 1: "__ac_name" is an invalid variable name because it starts with "_"
    Line 1: "__ac_password" is an invalid variable name because it starts with "_"



    Thanks
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Mmmm, ok, that makes no sence. Variables in Python can begin with letters or underscores

    for instance...

    >>> _name = 'value'
    >>> _name
    'value'
    >>>

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo