World of Warcraft API: Return value from PutItemInBag() - world-of-warcraft

Is there any return value from PutItemInBag(), possibly telling you if it succeeded or the bag was full?

There is a return value, but that only returns whether the cursor had an item. See FrameXML/MainMenuBarBagButtons.lua#L20
hadItem = PutItemInBag(inventoryID)
The UI_ERROR_MESSAGE event will fire with errorType 13 if a bag is full

Related

Node BehaviorSubject Problem only get empty object

I am using Angular version 7 and trying to use a BehaviorSubject
but when I get the value, all times I receive an empty object
value empty
line: 315 | let value: any = await this._service.machine$.pipe(take(1)).toPromise()
Emmit
this._service.emitterMachineSelected('new')
code of service
_machine's default value
_machine is a BehaviorSubject that (to start with) contains an empty object. ({} is an empty object). That's how you read the following line:
_machine = new BehaviorSubject({});
So when you grab that value, an empty object (The default value of the BehaviorSubject) is what you get.
Using .next to emit a value
Some time later, it contains the string "new"
this_machine.next("new");
You're not grabbing this value anywhere, so you shouldn't expect to see it anywhere.

Trying to check if value is in sqlite3 with Python

I am trying to check if a value is in SQLite with python to then either update the table if the value exists or create a new value if it is not. I have tried to create a cursor to check rows, append the rows to a list with loop, check if value exists, check the count of the rows... I seems to get hung up on the if statement when trying to access the value initialized from the query. Here is the code:
checkT = db.execute("SELECT COUNT(*) FROM trans WHERE stock=:stock AND id=:user_id", stock=request.form.get("symbol"), user_id=session["user_id"])
if checkT > 0:
print("there")
else:
print("not there")
How can I fix this? Thank you!
From the CS50 Library for Python doc for execute
Returns
for SELECTs, a list of dict objects, each of which represents a row in the result set; for INSERTs, the primary key of a newly inserted row (or None if none); for UPDATEs, the number of rows updated; for DELETEs, the number of rows deleted; for CREATEs, True on success; on error, a RuntimeError is raised
checkT is a list with one element, which is a dict with one key/value pair.
This checkT[0]['COUNT(*)'] will give the number returned from the sql. Counting the rows would not be appropriate in this case because this query will always return one row.
One hint: column names in a SELECT can be aliased, given a different name, like so:
SELECT COUNT(*) as count from....... It would just be typing convenience, because then the key in the returned dict will be count instead of COUNT(*).
Remember: in the flask run terminal there is a traceback with gives more details information on the error received (assuming "hung up" means a 500 Internal Server Error).

How could I return link to object property and not a value in Python3?

Thank you for taking your time.
Here is my code:
right_field_return(player, player.what_to_edit) = message
This call raise SyntaxError: can't assign to function call and I do understand it, but...
What does right_field_return does?
It is return objects field like this:
return player.current_mission.name
What I want to do?
I want to assign message value to player.current_mission.name
What do I get now?
Well, all I can do now is to return a VALUE from right_field_return, and I want to return a link to property player.current_mission.name - is there any way I can do it this way? Or maybe you can help me out and point in the other direction?
thank you
You should define a setter method in your class that takes message as an argument and sets new value to player.current_mission

learning mapreduce in Fauxton

I am brand new to noSQL, couchDB, and mapreduce and need some help.
I have the same question discussed here {How to use reduce in Fauxton} but do not understand the answer:(.
I have a working map function:
function (foo) {
if(foo.type == "blog post");
emit(foo)
}
which returns 11 individual documents. I want to modify this to return foo.type along with a count of 1.
I have tried:
function (doc) {
if(doc.type == "blog post");
return count(doc)
}
and "_count" from the Reduce panel, but clearly am doing something wrong as the View does not return anything.
Thanks in advance for any assistance or guidance!
In Fauxton, the Reduce step is kind of awkward and unintuitive to find.
Select _count in the "Reduce (optional)" popup below where you type
in your Map.
Select "Save Document and then Build Index". That will display your
map results.
Find the "Options" button at the top next to a gears icon. If you see a
green band instead, close the green band with the X.
Select Options, then the "Reduce" check-circle. Select Run Query.
Map
So when you build a map function, you are literally creating a dictionnary or map which are key:value data structures.
Your map function should emit keys that you will query. You can also emit a value but if you intend to simply get the associated document, you don't have to emit any values. Why? Because there is a query parameter that can be used to return the document associated (?include_docs=true).
Reduce
Then, you can have reduce function which will be called for every result with the same keys. Every result with the same key will be processed through your reduce function to reduce the value.
Corrected example
So in your case, you want to map document the document per type I suppose.
You could create a function that emit documents that have the type property.
function(doc){
if(doc.type)
emit(doc.type);
}
If you query this view, you will see that the keys of each rows will be the type of the document. If you choose the _count reduce function, you should have the number of document per types.
When querying the view, you have to specify : group=true&reduce=true
Also, you can get all the document of type blog postby querying with those parameters : ?key="blog post"

How to check any response value matches its property value

I have a piece of code below that checks that every value of regionId (found under region.hotels.regionId) matches its property value regionid_request.
def response = messageExchange.response.responseContent
def json = new JsonSlurper().parseText(response)
def regionid_request = messageExchange.modelItem.testStep.testCase.testSuite.getPropertyValue("regionid") as Integer
region.hotels.each { hotel ->
assert hotel.regionId == regionid_request
}
I want the code above to perform slightly differently. Instead of saying each regionid needs to match its property value, I just want any of regionid to match its property value. In other words I want to ensure when I have my response, that at least one of the regionIds matches the property value.
What needs to be changed above to match this condition?
Thank you,
Just
assert region.hotels.regionId.contains(regionid_request)

Resources