Does PutAndUnlock on DataCache without supplying tags remove existing tags for that item? - appfabric

My scenario is that I have an item in the cache with several existing tags. I want to update the item using the PutAndUnlock method. Do I need to first retrieve any existing tags and pass them to the PutAndUnlock method to preserve them?
Related to that, adding new tags, would I have to get the existing tags and append any new ones before passing them to the PutAndUnlock method?

The switch (operationInfo.OperationType) case MDHOperationType.PUT_AND_UNLOCK in Microsoft.ApplicationServer.Caching.MultiDirectoryHashtable.PreProcess(AMDHObjectNode oldObjectNode, ref AMDHObjectNode newObjectNode, ref MDHOperationInfo operationInfo) is where the MDHOperationInfo determines whether the existing item is null (or throws), or if it should do the put.
PreProcess was called by
MultiDirectoryHashtable.PutNodeInSlot(ref MDHOperationInfo operationInfo, MDHDirectoryNode dir, int slotIndex).
The return from PreProcess is true, so it should end up calling dir.PutNodeInSlot(slotIndex, newObjectNode), which would have what I believe is the final answer.
As far as I can tell, it just does a simple assignment into the MDHNode slot, without doing any comparison of the Tags. It assigns a new Version using operationInfo.AssignNewInternalCacheItemVersion(), but I can't see where it ever does anything with the Tags.
If you look at usages for the NewCacheItem property on Microsoft.ApplicationServer.Caching.MDHOperationInfo, they don't seem to be touching the Tags.

Related

Use Key-Value Edit when passing object in Postman post request

I have a collection of requests I'm trying to improve and want to be able to use the Key-Value Editing UI in Postman, but I need to pass an object.
rest_data = {
"session_id":"{{sessionId}}",
"dealer_number":{{integralinkCode}},
"customer_id":"12345",
"vehicle_id":null,
"phone":"5555555555",
"amount":"0.01",
"reference_no":"test1234",
"asm_user_id":"{{userId}}",
"message":"test"
}
Currently, I have the key set as "rest_data", and the value holds the object. This works, but I feel like it makes it a bit hard to read. Ideally, I'd like to have the properties of the object as key-value pairs in Postman.
I tried setting the keys in Postman like this rest_data["session_id"] and the value equal to the relevant value, but that didn't work.
My reasoning is so that when making changes to the body, it's easier and I can fill in the description for values and what they should be. Also, you're not able to hover over environmental variables to see their values or use environmental variable autofill within the object.
Can this be done, and if so, how? I'm also open to alternative solutions.

Safely serializing complex values to HTML element attributes

When I have to transfer complex values (e.g. a list of dicts) through a Django template to the front end, I typically use json_script to try and prevent XSS vectors.
Recently, I started using lit-element, which has a neat way of pulling attribute values from your custom elements and providing them as properties to your component. You can say:
<my-element items="{{ serialized array of items }}"></my-element>
Then lit-element will take whatever string value is passed to the items attribute and call JSON.parse() on it, so I need a way of serializing my value to JSON.
Since that is relatively trivial in itself, my initial idea was to write a custom template filter and try to match how json_script escapes values. But then I read the source for that function and it explicitly states:
Escape all the HTML/XML special characters with their unicode escapes,
so value is safe to be output anywhere except for inside a tag attribute.
This sounds like attribute values are potentially a more serious XSS vector. So I guess my question is - how to serialize data (in Django/Python) to JSON so it's safe for use in tag attribute values?
I think the reason it says can be used anywhere apart from attributes is that this function doesn't escape speechmarks, this means you would be able to close an attribute and start a new one easily. Django provides the escapejs template tag that escapes speech marks as well.
This function is in the same source that you linked in your question. Following the approach used there should be safe.

Django-voting: what is the right way of appending tags

i'm starting with django-tagging and I don't understand why update_tags(object, new_tag) method replaces all existing tags on object by new_tag.
What is the proper way to append a tag to the existing tags on an object inside a views?
EDIT: add_tag function is not satifying becaus it doesn't enables you to add multiple words tags: see this former post
Use add_tag(object, tag_name).
For more information see http://api.rst2a.com/1.0/rst2/html?uri=http://django-tagging.googlecode.com/svn/trunk/docs/overview.txt#api-reference

SPDataSource for update and delete

Has anyone tried out working with the Delete and update command of SPDataSource used in conjunction with SPGridView? If yes, can you share a working example?
There is no way to do this without code. It specifies the query used to first retrieve the item(s) to be deleted, you in turn should add a handler for deleting the items the DeleteCommand retrieves in code.... I know, not very clean, but the SPDataSource is basically only useable for selecting items... CAML is a retrieval only language, it itself does not have any Command either (i.e. SELECT is implicit, DELETE, INSERT UPDATE do not exist in CAML)

How do you rename a Verity collection in ColdFusion?

Can't seem to rename an existing Verity collection in ColdFusion without deleting, recreating, and rebuilding the collection. Problem is, I have some very large collections I'd rather not have to delete and rebuild from scratch. Any one have a handy trick for this conundrum?
I don't believe that there is an easy way to rename a Verity collection. You can always use
<cfcollection action="map" ...>
to assign an alias to an existing collection, provided you do not need to re-use the original name.
For the Verity part (without considering ColdFusion), it's easy enough to detach a collection, rename it, and reattach it again:
rcadmin> indexdetach
Server Alias:YourDocserver
Index Alias:CollectionName
Index Type [(c)ollection,(t)ree,(p)arametric,(r)ecommendation]:c
Save changes? [y|n]:y
<<Return>> SUCCESS
rcadmin> collpurge
Collection alias:CollectionName
Admin Alias:AdminServer
Save changes? [y|n]:y
<<Return>> SUCCESS
rcadmin> adminsignal
Admin Alias:AdminServer
Type of signal (Shutdown=2,WSRefresh=3,RestartAllServers=4):4
Save changes? [y|n]:y
<<Return>> SUCCESS
Now you can rename the collection directory, and re-attach. (If you are unsure of any of these values, check them with collget before you take it offline).
rcadmin> collset
Admin Alias:AdminServer
Collection Alias:NewCollectionName
Modify Type (Update=0, Insert=1):1
Path:
Gateway[(o)dbc|(n)otes|(e)xchange|(d)ocumentum|(f)ilesys|(w)eb|o(t)her]:
Style Alias:
Document Access (Public=0,Secure=1,Anonymous=2):
Query Parser [(s)imple|(b)oolPlus|(f)reeText|(o)ldFreeText|O(l)dSimple|O(t)her]:
Description:
Max. Search Time(msecs):
Save changes? [y|n]:y
rcadmin> indexattach
Index Alias:NewCollectionName
Index Type [(c)ollection,(t)ree,(p)arametric,(r)ecommendation]:c
Server Alias:YourDocserver
Modify Type (Update=0, Insert=1):1
Index State (offline=0,hidden=1,online=2):2
Threads (default=3):
Save changes? [y|n]:y
<<Return>> SUCCESS
It should now show up again in the 'hierarchyview'.
You can also use the "merge" utility to copy content from one collection to another, with a new name.
Looks like this is not possible. Deleting and re-creating the collection with the desired name appears to be the only approach available.