質問

I'm just getting myself into eve. Great framework but I'm stuck with the _links to items.

I have a collection with contracts allowing only item_methods.

domain.com/contracts/19687176add597c50b13b4188fcafd6d

Each contract may have n credit notes, accessible via:

domain.com/contracts/a78b1627f7858cc187bcad5d8abe19d3/creditnotes

-> list of all credit notes.

Each credit note in the list has a link like this:

_links": {
    "self": {
      "href": "domain.com/contracts/<regex(\"[a-f0-9]{32}\"):token>/creditnotes/DD001366"

I want this to be a pretty link without the regex inside (doesn't make any sense) and I think it'd be better to have link to the credit note items like this:

domain.com/creditnotes/DD001366

I tried to change the item configuration but no luck so far:

creditnotes = {
'url': 'contracts/<regex("[a-f0-9]{32}"):token>/creditnotes',
'resource_title': 'creditnotes for contract token',
'item_title': 'creditnote',
'item_url': 'regex("[D0-9]{8}")',
'item_lookup': True,
'item_lookup_field': '_id',

# We choose to override global cache-control directives for this resource.
'cache_control': 'max-age=10,must-revalidate',
'cache_expires': 10,

# most global settings can be overridden at resource level
'resource_methods': ['GET'],
'item_methods': ['GET'],
'pagination': False,
# 'item_lookup_field': 'token',

'schema': creditnotes_schema

}

役に立ちましたか?

解決

Yes this is a known issue with sub-resources. For the time being you probably can get around it by just turning off HATEOAS (HATEOAS = False in your settings file).

Will add a comment to this thread when it's fixed on the dev-branch.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top