Hi there

Trying to use @request.restful() I have an issue : 

*My model : *
db.define_table('company',Field('name'),Field('info'))
db.define_table('employee',Field('employer',db.company),Field('name'),Field(
'info'))

*My controller :*

@request.restful()
def api():
    def GET(*args,**vars):
        patterns = [
            "/companies[company]",
            "/company/{company.id}",
            "/company/{company.name.contains}"
            ]
        parser = db.parse_as_rest(patterns,args,vars)
        if parser.status == 200:
            return dict(content=parser.response)
        else:
            raise HTTP(parser.status,parser.error)
    def POST(table_name,**vars):
        return db[table_name].validate_and_insert(**vars)
    def PUT(table_name,record_id,**vars):
        return db(db[table_name]._id==record_id).update(**vars)
    def DELETE(table_name,record_id):
        return db(db[table_name]._id==record_id).delete()
    return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)


When I call */default/api/company/1.json* (pattern  
"/company/{company.id}",) I get the correct result
But when I call */default/api/company/pyt.json* (pattern 
"/company/{company.name.contains}") I get an error : 


*<type 'exceptions.ValueError'> invalid literal for long() with base 10: 
'ython'
Version
web2py™     Version 2.6.3-stable+timestamp.2013.09.15.17.01.20
Traceback

Traceback (most recent call last):
  File "C:\Users\loic\Google Drive\web2py\gluon\restricted.py", line 217, 
in restricted
    exec ccode in environment
  File "C:/Users/loic/Google 
Drive/web2py/applications/RESTful_api/controllers/default.py", line 46, in 
<module>
  File "C:\Users\loic\Google Drive\web2py\gluon\globals.py", line 378, in 
<lambda>
    self._caller = lambda f: f()
  File "C:\Users\loic\Google Drive\web2py\gluon\globals.py", line 342, in f
    return rest_action(*_self.args, **_self.vars)
  File "C:/Users/loic/Google 
Drive/web2py/applications/RESTful_api/controllers/default.py", line 16, in 
GET
    parser = db.parse_as_rest(patterns,args,vars)
  File "C:\Users\loic\Google Drive\web2py\gluon\dal.py", line 7831, in 
parse_as_rest
    count = dbset.count()
  File "C:\Users\loic\Google Drive\web2py\gluon\dal.py", line 10045, in 
count
    return db._adapter.count(self.query,distinct)
  File "C:\Users\loic\Google Drive\web2py\gluon\dal.py", line 1763, in count
    self.execute(self._count(query, distinct))
  File "C:\Users\loic\Google Drive\web2py\gluon\dal.py", line 1750, in 
_count
    sql_w = ' WHERE ' + self.expand(query)
  File "C:\Users\loic\Google Drive\web2py\gluon\dal.py", line 1414, in 
expand
    out = op(first, second, **optional_args)
  File "C:\Users\loic\Google Drive\web2py\gluon\dal.py", line 1320, in EQ
    self.expand(second, first.type))
  File "C:\Users\loic\Google Drive\web2py\gluon\dal.py", line 1425, in 
expand
    return str(self.represent(expression,field_type))
  File "C:\Users\loic\Google Drive\web2py\gluon\dal.py", line 1866, in 
represent
    return str(long(obj))
ValueError: invalid literal for long() with base 10: 'ython'*

Any idea?
Thank you

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to