api-design

How to update the Nested List/Tree Store in Sencha Touch?

女生的网名这么多〃 提交于 2019-12-12 17:18:47
问题 I have a nested list which must be filled with new data based on what does user select in an Ext.Carousel. TreeStore.load(newData) // this does not work :( TreeStore.removeAll() // this works! It seems that the docs and the forum don't have the answer, cause I have been searching for 2-3 days. Thank you in advance. 回答1: I've ended up with following solution: NestedList = Ext.extend(Ext.NestedList, { loadData: function(data) { this.store.setProxy({ type:'memory', data: data, reader: { type:

Why TypeError when too many / too few args in Python function call

本小妞迷上赌 提交于 2019-12-12 11:27:44
问题 I'm having trouble understanding why Python raises a TypeError when you provide arguments that aren't part of a method signature. Example: >>> def funky(): ... pass ... >>> funky(500) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: funky() takes no arguments (1 given) I thought, if this is because *args is expected to be None or [] within the scope of a no-arg function, that's a leaky abstraction, so I looked it up. What I found A page search for TypeError on

Is it RESTful to create a foreign key record from another resources POST request?

旧时模样 提交于 2019-12-12 09:53:12
问题 So I have some resources in my API with foreign key relationships and these fk records (by design) cannot be created unless a POST is made to that specific resource first. I cannot create a Country by POSTing to Wine even though Country is a foreign key. the POST is going to /api/wine not /api/country In other words, if I send this payload to Wine resource: { id: 79, name: "Bordeaux", country: { id: 76, code: "FR", name: "France" }, year: "2005" } It will fail unless that country already

What's a RESTful way to query with logic operation?

我们两清 提交于 2019-12-12 09:44:47
问题 This is a spin-off question to query with filters Say my application is managing objects called workload, with the following fields. I want to expose a REST interface for user to query workloads by labels. "Workload": {"id":"test1", "labels":["A", "B", "C"]} "Workload": {"id":"test2", "labels":["A", "C", "D"]} "Workload": {"id":"test3", "labels":["A", "B", "D"]} Question : How do I design the REST endpoint so that it would support query workload with basic logic operations? Sample Query 2 : I

“Program to an interface” using extension methods: When does it go too far?

天大地大妈咪最大 提交于 2019-12-12 07:58:32
问题 Background: In the spirit of "program to an interface, not an implementation" and Haskell type classes, and as a coding experiment, I am thinking about what it would mean to create an API that is principally founded on the combination of interfaces and extension methods. I have two guidelines in mind: Avoid class inheritance whenever possible. Interfaces should be implemented as sealed class es. (This is for two reasons: First, because subclassing raises some nasty questions about how to

Open api 3.0 mock Generator [closed]

房东的猫 提交于 2019-12-12 06:21:57
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I am learning Open API Specification. Is there any tools to perform mocking on API based on the open API specification in YAML file. Thanks in Advance ps: I am using the currently released draft version of open API (OpenAPI 3.0) 回答1: SwaggerHub includes a mock server for OpenAPI 2.0 and 3.0 specs. Mocking is

Can I derive from a class that can only be created by a “factory”?

回眸只為那壹抹淺笑 提交于 2019-12-12 03:42:57
问题 Suppose that a library I'm using implements a class class Base(object): def __init__(self, private_API_args): ... It's meant to be instantiated only via def factory(public_API_args): """ Returns a Base object """ ... I'd like to extend the Base class by adding a couple of methods to it: class Derived(Base): def foo(self): ... def bar(self): ... Is it possible to initialize Derived without calling the private API though? In other words, what should be my replacement for the factory function?

Design a Python API for existing Java API

為{幸葍}努か 提交于 2019-12-12 03:17:35
问题 I am new to python and I have to design a Python API(version - 2.7) similar to an existing Java API Python version - 2.7 The Java API is as follows public interface Process<T> { Future<T> create(Client<T> client) //Other methods } public interface Client<T> extends Serializable { T execute(ClientContext c) //Other methods } public interface ClientContext { File createFile(String path) //Other methods } The equivalent Python API design that I have come up with is Approach1 class Process: _

API webservice testing with Postman

这一生的挚爱 提交于 2019-12-12 02:49:09
问题 I installed Postman inside Chrome to test Kairos API webservice. I have set following fields: I get error message, but regarding to API documentation it should be working in this format. Authentication parameters missing 回答1: On Kairos' website it says: Requests must be authenticated with your API key. This must be sent as an HTTP header. So click the "Add token to the header" radio button under "Previously Used" instead of the "Add token to the url" button, and it should work! 回答2: The API

Why is the Java date API (java.util.Date, .Calendar) such a mess?

冷暖自知 提交于 2019-12-12 01:55:46
问题 As most people are painfully aware of by now, the Java API for handling calendar dates (specifically the classes java.util.Date and java.util.Calendar ) are a terrible mess. Off the top of my head: Date is mutable Date represents a timestamp, not a date no easy way to convert between date components (day, month, year...) and Date Calendar is clunky to use, and tries to combine different calendar systems into one class This post sums it up quite well, and JSR-310 also expains these problems.