-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API v2 #17
API v2 #17
Conversation
) | ||
|
||
# Register the viewset with the API router. | ||
api.router.register(r'registry/%s' % model._meta.object_name.lower(), viewset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have all top-level registry endpoints under registry/
or should they be at root directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep it at top level.
Currently, the API does not yet support filtering. For an example output, see this query. |
@@ -12,4 +14,6 @@ | |||
# Frontend components auto-discovery | |||
components.pool.discover_components() | |||
|
|||
urlpatterns = components.pool.get_urls() | |||
urlpatterns = components.pool.get_urls() + [ | |||
urls.url(r'^api/v2/', urls.include(api.router.urls)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this to nodewatcher/urls.py
, so that it is not part of frontend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, but the whole api
is part of the frontend? Why should it be separate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because to me it is not part of frontend. :-) API can be used by mobile apps, for example. While our frontend
app is our "web frontend" in fact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So to me frontend is this particular Django component system we have and display stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why is then api
under nodewatcher.core.frontend.api
and not nodewatcher.core.api
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Move it. :-)
So some features we had in Tastypie and I think we should keep them, so we should check:
|
But it looks awesome! |
Maybe we can for now just prevent access to sensitive data and later on open it. Because we do not provide OAuth access to API anyway. Or do we? |
Benchmarking serialization of a GIS field ( Old Tastypie v1 API with UJSON and our optimization:
v2 API default JSON:
v2 API UJSON 1.35:
With our optimization of using
|
I had to refactor some code because otherwise I was getting an `AppRegistryNotReady` exception. It seems Django is much more sensitive now about when things can load.
What I am saying is that "global filter" is to me some extension point different modules can register themselves in. And can say, "if user is interested (fields) into this registry item, this is how you can global search on it." |
So you are saying that as soon as a specific registry item is projected, some fields (declared by the registry item developer) would become part of the "global filter"? So for example, projecting anything under
Well, the client is already allowed to filter by arbitrary fields, including using text expressions. For example, the client may do |
Maybe projecting |
Yes, but the question is how it knows which of those queries can it do? I am not talking here about a person, but client program. So user can reason about this. But how can a "global filter" field know which queries to construct in the API request when user (human) types something in? |
The developer of the client-side application will decide which filters to use? The same as it will decide which columns to show or which filters to apply. |
And what about when user can select which columns to display through UI interface? And datatables display rows. But there is still one field to search over globally. |
But yes, we can do then something like this:
And it will be developers or UIs responsibility to generate this second-layer of filters somehow. |
In general, is there a way to create and and or between filters? Because I was thinking of using that in my UI, but now I do not even believe this is possible through the query language exposed? |
The registry supports such queries, but they are currently not exposed via the API. If you think of a nice way to pass such query expressions, we can support it. |
We now have support for complex filter expressions using |
Super! I updated the list above. I think only GIS query is now pending. Everything else has been done! |
if instance._meta.pk.name in data: | ||
del data[instance._meta.pk.name] | ||
id_field = instance._meta.pk.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, if we expose primary key as @id
, how can you then know over which field you can filter and sort? Because you probably still have to write uuid
to filter, and not @id
?
Conflicts: nodewatcher/modules/administration/location/models.py nodewatcher/settings_production.py
See #1268