I've been busy trying to widgetize.  I have some questions.

a- so far, the easiest way to push into a widget is this:

class Form__Register(TableForm):
    fields = [
        Image('captcha_image',label='',validator=None) ,
                TextField('captcha_text',label="Enter The Text Above" ,
validator=String(not_empty=True) ) ,
                HiddenField('captcha_key' , validator=String(not_empty=True) ) ,
]

however:
    a - i had to make this widget, which is quite bad

class Image(FormField):
    template = """<img src="${value}" border="0"/>"""

    b - i have no idea how to consolidate this into a compound widget

in displaying the form , i figured this out:

    def index(self,tg_errors=None,**data):
        if 'captcha_key' in data:
            captcha_key = data['captcha_key']
        else:
            captchaInstance = CaptchaNew(captcha_seed="sessionID")
            captchaInstance.generate_key()
            captcha_key = captchaInstance.captcha_key_combined
        value['captcha_image'] =
'/register/captcha_view__registration?key=%s' % captcha_key
        value['captcha_key'] = captcha_key

however, i can't figure out how to validate my captcha correctly
i figure i can either
   a) do it in the schema , but i have no idea how to hook a custom
validator into the schema
   b) do it in the form process, but then i don't know how to push back
to the main page as an error ie:
       def process( self, **data ):
           if not validate_captcha():
                return dict( self.index() )

any suggestions?  i know i'll have 2 dozen more questions relating to
this in the near future.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to