beginner questions about REST

98 views
Skip to first unread message

Dimid Korovev

unread,
Sep 16, 2013, 9:44:10 AM9/16/13
to web...@googlegroups.com
Hi All,

I heard about web2py following this question:

My goal is to create a RESTful web service from a DB, such that when the DB is modified, no code changes would be needed.

Questions:
1. When creating the DB schema to be extracted, should I add an 'id' field? If I do, the resulted 'legacy_db_web2py_code' string contains an 'ID' field in 'define_table'. However, the documentation says such field is already created implicitly. If I don't, I need another PK to create relations with foreign keys.


but PUT and DELETE won't work (GET and POST do work). any suggestions?

3.I've written a small scitpt (attached) which wraps 'extract_mysql_models'. Feedback would be welcomed.

Thanks in advance
auto_extract_mysql_to_db_model.py

Dimid Korovev

unread,
Sep 17, 2013, 9:53:10 AM9/17/13
to web...@googlegroups.com
Update to question 2: PUT works now, but DELETE doesn't. I get the following error:
 <type 'exceptions.TypeError'> not indexable

web2py Version 
 2.6.3-stable+timestamp.2013.09.15.17.01.20
Python  Python 2.7.4: /usr/bin/python (prefix: /usr)  
Traceback (most recent call last):  
  File "../gluon/restricted.py", line 217, in restricted  
    exec ccode in environment  
  File "../applications/app/controllers/default.py", line 103, in <module>  
  File "../gluon/globals.py", line 378, in <lambda>  
    self._caller = lambda f: f()  
  File "../gluon/globals.py", line 348, in f  
    raise e  
TypeError: not indexable

Massimo Di Pierro

unread,
Sep 17, 2013, 3:25:43 PM9/17/13
to web...@googlegroups.com
Please open a ticket about this.

Dimid Duchovny

unread,
Sep 18, 2013, 8:56:50 AM9/18/13
to web...@googlegroups.com
Ticket opened: 
https://code.google.com/p/web2py/issues/detail?id=1682

I'd appreciate help with the first question and feedback on the script.

2013/9/17 Massimo Di Pierro <massimo....@gmail.com>

--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/FDmOccKa39E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Derek

unread,
Sep 18, 2013, 6:49:07 PM9/18/13
to web...@googlegroups.com
For question 1 I'd follow PEP20...

Explicit is better than implicit.

Joel Samuelsson

unread,
Nov 22, 2013, 9:13:24 AM11/22/13
to web...@googlegroups.com
Is this in the stable version yet? I am having the same issue and updating to the latest stable doesn't help.

If not, is there a small fix I can use in the meantime?

Best regards,
Joel Samuelsson
Reply all
Reply to author
Forward
0 new messages