Thanks for your answer, Alessandro. Another question about the @validate 
decorator. What I like with the WSME webservice layer is that it allows to 
define structures to be used for validation. For example, I create a class 
WikiPage with required properties, and when the client sends a request in json 
format eg { "title": "blabla", "content": "<html>this is the wiki page body 
</html>"}, WSME will try to match my model class with the json sctructure.

hm... actually, I looked at http://turbogears.org/2.1/docs/main/Validation.html
and I believe I can build classes like this:

WikiPageValidator(object):
  todict(self):
    return {
      "title": validators.UnicodeString,
      "content": validators.UnicodeString,
    }

from formencode import validators

@expose('json')
@validate(validators=WikiPageValidator.todict())
def two_validators(self, a=None, b=None, *args):
    errors = [{key, value} in pylons.c.form_errors.iteritems()]
    values =  pylons.c.form_values
    return dict(a=a, b=b, errors=str(errors), values=str(values))


What do you think ? Is it a good way to use it ?

Damien

----- Mail original -----
De: "Alessandro Molina" <[email protected]>
À: "TurboGears ." <[email protected]>
Envoyé: Vendredi 28 Mars 2014 18:45:15
Objet: Re: [TurboGears] Web services with turbogears2


Actually TG works pretty well for REST API due to built-in support for JSON, 
RestController and @validate 


There is also a tutorial on rapid-prototyping REST API using the 
EasyCrudRestController which shows how to setup an autogenerated rest api with 
minimum effort: 
http://turbogears.readthedocs.org/en/latest/cookbook/Crud/restapi.html 



On Fri, Mar 28, 2014 at 5:22 PM, < [email protected] > wrote: 


Hi all, 

I'm about to start a new project which is a web application mostly based on a 
server-side application implementing a REST/Json API and a database connection 
(through SQLAlchemy). I was thinking of using WSME for the webservice layer 
(formatting output + data validation) but it seems that it does not support 
TG2. 

My question is: is there a simple way to implement a REST/Json api with TG2 
(with data validation) ? If not, what framework would you recommend to do so ? 
I'm looking for a full-stack framework with features like user rights 
management (like TG2 do). 

Thanks in advance. 

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group. 
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected] . 
To post to this group, send email to [email protected] . 
Visit this group at http://groups.google.com/group/turbogears . 
For more options, visit https://groups.google.com/d/optout . 



-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group. 
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected] . 
To post to this group, send email to [email protected] . 
Visit this group at http://groups.google.com/group/turbogears . 
For more options, visit https://groups.google.com/d/optout . 

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to