Re: Leaf Resources with child Leaf Resources

[email protected]
Newsgroups gmane.comp.python.twisted.web
Message-ID <20120229211243.4576.125225416.divmod.xquotient.82@localhost6.localdomain6>
On 09:00 pm, [email protected] wrote:
>OK, so the issue I have is that I cannot create two separate REST 
>Resources
>with nested URLs  e.g.
>
>class CustomerRestService(Resource):
>     """Handles REST operations for Customer /customer"""
>
>class CustomerAddressRestService(Resource):
>     """Handles REST operations for Customer Address
>/customer/<customerId>/address"""
>     pass
>
>Instead I would need to have one common Resource that handles 
>everything
>under '/customer',
>including the customer entity and customer address entity in one (and 
>any
>other entity whose root is '/customer').

I don't understand what this means.  It sounds like you're saying you 
have to have CustomerRestService be a leaf resource.  You don't have to. 
If you don't want it to be a leaf resource, don't make it a leaf 
resource.  The way you not making it a leaf resource is by not setting 
`isLeaf = True` on it.
>That isn't a very good design...especially if you maybe have 50 
>different
>entities hooked up  under '/customer' (like in our app).
>It seems in order to enable having nice cohesive classes that provide a
>REST service for just one entity I would need to manually
>route the request from the root Resource into each of them myself.
>
>That is what i was trying to avoid, but it looks like there is no other
>choice.

I still don't understand the problem you're having.  As I said, 
regarding the "solution" I gave in my previous email, it's just how you 
would achieve the behavior I thought maybe you were trying to describe 
wanting, but I don't really understand what you're trying to accomplish 
or why.

Jean-Paul
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.