you can create your on validators:
class IS_DIR:
def __init__(self,error_message='Dir does not exist'):
self.error_message=error_mesage
def __call__(self,value):
import os
if not or.path.isdir(value): return
(value,self.error_message)
return (value,None)
db.table.field.requires=[IS_NOT_EMPTY(),IS_DIR()]
I smell directry traversal attack here. Depends on the contexts.
Massimo
On Jan 5, 1:26 am, Iceberg <[email protected]> wrote:
> Hey pals,
>
> I am new to T2. It is really convenient such as t2.create(db.config)
> or t2.update(db.config,query). But I do not find a way to customize
> form validation. In t2.pdf I only found the "onaccept" callback, but
> it is called AFTER the form is accepted - NOT what I want.
>
> Finally I used this clumsy approach. Is there a better way?
>
> def create():
> import os,os.path
> if request.vars.logdir:# Same blah happens in update()
> if not os.path.isdir(request.vars.logdir): # I need to make sure
> this
> response.flash='Dir not exist: %s'%request.vars.logdir
> return {'Oops':A('Try again',_href=URL(r=request,f='create'))}
> return {'Create':t2.create(db.config)}
>
> Thanks in advance.
> Iceberg
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---