Way of reusing loopback model - loopbackjs

I have to implement reporting application that requires fetching data from existing ITS such as Jira.
I was able to login by extending StrongLoop's User model and calling REST API from JIRA.
Now, I want to share this codes by creating loopback component or something so that I could use this login method later on.
Please share your knowledge or best practice for creating loopback component.
Thanks

You probably want to look at writing a model "mixin", but without seeing your code it's hard to say exactly what that would look like. You might also just define an internal-only model that extends the built in User and then additional models that extend your new model and are actually implemented in the REST API.

Related

Rest API instead of table in Django Proxy unmanaged models

In my Django arch. task I must connect multiple projects. Some can only communicate through REST API and don't have common database access. However, the task is to provide seamless communication on model level. I.e. my model should serve as a wrapper for read-only requests in such a way, that business layer does not see the difference between local models and models that wrap remote data. Assuming that inherited create-delete-update methods will do nothing and network communication and authentication is handled by some method:
read_remote_records(**kwargs)
This method returns any data that I would need for my model. All I need is to wrap it in query set api for seamless use in views.
I have read these:
Proxy models documentation
Unmanaged models documentation
Also documentation on creation of custom managers and querysets.
However, not a single good example for what I am set to achieve.
Perhaps you can provide a solid Django example how to modify manager and query set in this way?

How to write reusable apps with customizable models in Django?

I want to make reusable apps, that allow for customization by the integrator.
An example is if I make a newsletter signup app with the bare minimum of storing email address, but the integrator later wants to add additional fields, like say a name. What is the things I need to do to allow for this easily?
I went down the path of swapping out the models, like Django's auth system does, but that didn't work well. Then I found swappable attribute in the Meta class and a package that does this, but both are not intended for external use.
The only way I can think of for the integrator to do is, allow them to provide custom forms by passing it into the view in the urls for instance.
url('^someurl/$', MyView.as_view(form_class=SomeForm), name="myurl")
Then have a secondary model, with foreign keys to the internal newsletter model, but this means a secondary table that needs to be joined.
Another alternative is to try Abstract models, but I'm not sure what the impact will be there.
So what is the Django/Pythonic way of solving this?

CakePHP model to web service

I'm developing a web application that doesn't need database. All data comes via REST.
My question is: Is possible to use a model class (extended from AppModel) to manage data from a RESTfull service?, How to do that?, Does CakePHP any way to mapping directly a RESTfull web service?.
I have researched and I have found the $useTable attribute (http://book.cakephp.org/2.0/en/models/model-attributes.html#usetable) but I'm not sure if exists another way to do this in a better way.
My first idea is implement my own functions in a Model and put $useTable to false.
Thank you.
There is no such functionality that ships with CakePHP, but it's relatively easy to implement it on your own.
Check out datasources, they sit between the model and the data, but can also be used standalone, ie you can use datasource instances directly, or indirectly through the model layer (find/save/delete calls are using the datasource CRUD methods).
Checkout https://github.com/nodesagency/CakePHP-Rest-Datasource for some inspiration.

Django Tastypie, run an action

I was wondering if someone could point me in the right direction. I am currently trying to build an API with Django and Tastypie.
I would like to have a http request lookup a model via a primary key then run a model method/action.
I can't seem to identify and matching docs or methods to achieve what seems like a simple action..
Thanks for any pointers,
I don't believe TastyPie is used to run model methods. It wraps the model up as a Resource and exposes a set of methods, mainly get,post,put. Take a look at Django TastyPie QuickStart
The methods you can expose are those of a REST api and not custom methods.

How to implement non-database backed models in Django?

I have an existing Django application with a pretty typical model implementation that's backed by a database. My task is to change this model so that instead of fetching the information from a database, it now fetches it from a service (e.g., via HTTP). Because there is existing code which already makes use of this model, it would be nice to maintain the same model interface so that it continues to behave like a typical Django model.
This raises a few of questions:
Is it possible to do this without having to re-write the interface from scratch to make it look like Django's model interface? (This stackoverflow question would seem to suggest otherwise: Django MVC pattern for non database driven models?)
Would writing a custom manager for this model be an appropriate approach (or have I misunderstood the role of the manager)?
Due to the service-backed nature of the new model, caching will be much more important than before. Is this something that should be implemented at the model level?
Have a look at django-roa. From the sound of it, it might be exactly what you are looking for.