Example #1
0
def update(request):
    p = Person(pk=request.REQUEST['id'],name=request.REQUEST['name'])
    data = '{"success":true}'
    try:
        p.save()
    except IntegrityError:
        data = '{"success":false, "msg": "%s"}' % (_("Person '%s' already exists.") % (p.name))
    except _mysql_exceptions.Warning:
        pass        
    except Exception, e1:
        data = '{"success":false, "msg": "%s"}' % (e1.args)    
Example #2
0
def save(request):
    req = request.REQUEST
    name=req['name']
    if not name or name.strip() == '':
        return '{"success":false, "msg": "%s"}' % _("Name is required.")  
    p = Person(name=name)
    #data = '{"success":true, "msg": "%s"}' % (_("Saved '%s'.") % (name))
    data = '{"success":true}'
    try:
        p.save()
    except IntegrityError:
        data = '{"success":false, "msg": "%s"}' % (_("Person '%s' already exists.") % (name))
    except _mysql_exceptions.Warning:
        pass        
    except Exception, e1:
        data = '{"success":false, "msg": "%s"}' % (e1.args)