Giter Site home page Giter Site logo

Comments (7)

nicolaiarocci avatar nicolaiarocci commented on August 26, 2024

Hello,

can you please provide me with an example of the request that causes you trouble?

from eve.

jkatz50 avatar jkatz50 commented on August 26, 2024

Here's my 2 schemas and some sample code

projects = {
    'item_title': 'project',
    'additional_lookup': {
        'url': '[\w]+',
        'field': 'perma_name'
    },
    'schema': {
        'name': {
            'type': 'string',
            'required': True,
        },
        'perma_name': {
            'type': 'string',
            'empty': False,
            'required': True,
            'unique': True,
        },
        'camp_id': {
            'type': 'objectid',
            'required': True,
            'data_relation': {
                'collection': 'campaigns'
            }
        },
        'raised': {
            'type': 'integer',
            'required': True,
            'min': 0,
        },
        'goal': {
            'type': 'integer',
            'required': True,
            'min': 0,
        },
        'description': {
            'type': 'string',
        }
    }
}

campaigns = {
    'item_title': 'campaign',
    'additional_lookup': {
        'url': '[\w]+',
        'field': 'perma_name'
    },
    'schema': {
        'name': {
            'type': 'string',
            'required': True,
        },
        'perma_name': {
            'type': 'string',
            'empty': False,
            'required': True,
            'unique': True,
        },
        'active_list': {
            'type': 'list',
            'items': {
                'p_id': {
                    'type': 'objectid',
                    'required': True,
                    'data_relation': {
                        'collection': 'projects'
                    }
                },
                'proj_name': {
                    'type': 'string',
                    'empty': False,
                    'required': True,
                },
                'perma_name': {
                    'type': 'string',
                    'required': True
                },
                'raised': {
                    'type': 'integer',
                    'required': True,
                    'min': 0,
                },
                'goal': {
                    'type': 'integer',
                    'required': True,
                    'min': 0,
                },
                'description': {
                    'type': 'string',
                    'required': True,
                    'maxlength': 255,
                }
            }
        }
    }
}


import requests
import json

camp = {'name': 'test',
             'perma_name': 'test',
             'active_list': []
}

data = {'item1': camp}

post_camp = requests.post('http://127.0.0.1:5001/campaigns/',data=json.dumps(data), headers={'content-type': 'application/json'})

camp_res = post_camp.json()
proj = { 'name': 'test_proj', 'perma_name': 'test_proj', 'camp_id': camp_res['item1']['_id'], 'raised': 0, 'goal': 50000, 'description': 'whooo'}

post_proj = requests.post('http://127.0.0.1:5001/projects/',data=json.dumps({'item1':proj}), headers={'content-type': 'application/json'})
proj_res = post_proj.json()
camp_proj = {'p_id': proj_res['item1']['_id'], 'proj_name': proj['name'], 'perma_name': proj['perma_name'], 'raised': 0, 'goal': 50000, 'description': 'whooo'}

camp_patch = {'active_list': [camp_proj]}
patch_link = 'http://' + camp_res['item1']['_links']['self']['href']
etag = camp_res['item1']['etag']
changes = {'item1': camp_patch}

patch_req = requests.post(patch_link, data=json.dumps(changes),headers={'content-type':'application/json','x-http-method-override':'patch','if-match':etag})
patch_req.content
#this will return a 400 error

new_camp = {'name': 'test2', 'perma_name': 'test2', 'active_list' = [camp_proj]}
new_camp_post = requests.post('http://127.0.0.1:5001/campaigns/', data=json.dumps({'item1':new_camp}), headers={'content-type': 'application/json'})
new_camp_post.json()
#will return with {'item1': {'status': 'ERR', 'issues': ["'field'"]}}

from eve.

jkatz50 avatar jkatz50 commented on August 26, 2024

Upon further inspection, I think it might be the fact that in my campaigns active list array, I am trying to define a data relation on projects? I believe if I take the data_relation out, it posts ok...

^-- just confirmed that it works without the data_relation for both...

from eve.

nicolaiarocci avatar nicolaiarocci commented on August 26, 2024

Try setting the data_relation field value explicitly. There might be a bug in the code that sets the default value (I'm just looking at the code, can't test it atm).

from eve.

jkatz50 avatar jkatz50 commented on August 26, 2024

Awesome! I believe that worked

from eve.

nicolaiarocci avatar nicolaiarocci commented on August 26, 2024

Excellent. Will fix in 0.0.7.

from eve.

jkatz50 avatar jkatz50 commented on August 26, 2024

Great framework btw - I'm loving the rapid development I can do with this and the speed with which it is evolving.

from eve.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.