Adding Cookie to ZSI Posts

I've added cookie support to SOAPpy by overriding HTTPTransport. I need functionality beyond that of SOAPpy, so I was planning on moving to ZSI, but I can't figure out how to put the Cookies on the ZSI posts made to the service. Without these cookies, the server will think it is an unauthorized request and it will fail.

How can I add cookies from a Python CookieJar to ZSI requests?

Asked by: Cadie306 | Posted: 01-10-2021

Answer 1

If you read the _Binding class in of ZSI you can see that it has a variable cookies, which is an instance of Cookie.SimpleCookie. Following the ZSI example and the Cookie example that is how it should work:

b = Binding(url='/cgi-bin/simple-test', tracefile=fp)
b.cookies['foo'] = 'bar'

Answered by: Max376 | Posted: 02-11-2021

Answer 2

Additionally, the Binding class also allows any header to be added. So I figured out that I can just add a "Cookie" header for each cookie I need to add. This worked well for the code generated by wsdl2py, just adding the cookies right after the binding is formed in the SOAP client class. Adding a parameter to the generated class to take in the cookies as a dictionary is easy and then they can easily be iterated through and added.

Answered by: Oliver428 | Posted: 02-11-2021

Similar questions

python - Adding REST to Django

python - NumPy, PIL adding an image

I'm trying to add two images together using NumPy and PIL. The way I would do this in MATLAB would be something like: >> M1 = imread('_1.jpg'); >> M2 = imread('_2.jpg'); >> resM = M1 + M2; >> imwrite(resM, 'res.jpg'); I get something like this:

linux - python or bash - adding " at beginning of line and ", at end of line

I have text file with something like first line line nr 2 line three etc And i want to generate "first line", "line nr 2", "line three", I wonder how to do this in python or maybe in bash if it's easier/quicker. I know there is different code for opening file and different for reading only one line in python(?) but i'm not sure which option to use ...

python - Why do I need to save this model before adding it to another one?

In django, I'm trying to do something like this: # if form is valid ... article = = req.user product_name = form.cleaned_data['product_name'] try: article.product = Component.objects.get(name=product_name) except: article.product = Component(name=product_name) # do some more form processing ... But then it tells me:

Python GTK adding signal to a combo box

I create a combo box using PyGTK: fileAttrCombo = gtk.ComboBox(); I want to attach a signal handler for this combo box. This signal handler handles when user change selection in the combo box. What is be the best approach to do this ?

python - Adding string to end of URL

To practise some more bits of python I've been having a go at the challenges on In brief, this challenge as a first step requires one to load an html page from a url with a number at the end. The page contains a single line of text which has in it a number. That number is used to replace the existing one in the url, and so take you to the next page in the sequence. Apparently this continues for ...

python - adding a header to pyqt list

i want to add a headers and index to a list in pyqt , it's really not important what list of QT (qlistwidget , qlistview , qtablewidget, qtreeview) in short .. i want something like the spin box delegate example in the pyqt demo ... but instead of the index in the column headers i want a strings ... hope the idea is clear enough thanx in advance

python - Adding custom fields to users in Django

I am using the create_user() function that Django provides to create my users. I want to store additional information about the users. I tried following the instructions given at

python - Error when adding value to array

with open('file00.txt') as f00: for line in f00: farr=array.append(float(line)) print "farr= ",farr i get: farr=array.append(float(line)) AttributeError: 'module' object has no attribute 'append' does anyone know why I get this? do I have to import something? am I doing it completely wrong? thanks

python - Adding opion to form label

I have form declared like this: field = forms.MultipleChoiceField(choices = STATES, widget=forms.CheckboxSelectMultiple, label_suffix= "(%d)" % id) let say STATES is decladed as STATES = [(0, 'foo'), (1, 'bar')] And I want to acheve labels that looks like this: foo (0) bar (1) id should be option value (I'll call func there, so it has to b...

python - What's the best Django search app?

How can I use a DLL file from Python?

What is the easiest way to use a DLL file from within Python? Specifically, how can this be done without writing any additional wrapper C++ code to expose the functionality to Python? Native Python functionality is strongly preferred over using a third-party library.

python - PubSub lib for c#

Is there a c# library which provides similar functionality to the Python PubSub library? I think it's kind of an Observer Pattern which allows me to subscribe for messages of a given topic instead of using events.

python - What is the best way to copy a list?

This question already has answers here:

python - Possible Google Riddle?

My friend was given this free google website optimizer tshirt and came to me to try and figure out what the front logo meant. t-shirt So, I have a couple of guesses as to what it means, but I was just wondering if there is something more. My first guess is that eac...

How do you check whether a python method is bound or not?

Given a reference to a method, is there a way to check whether the method is bound to an object or not? Can you also access the instance that it's bound to?

ssh - How to scp in Python?

What's the most pythonic way to scp a file in Python? The only route I'm aware of is os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) which is a hack, and which doesn't work outside Linux-like systems, and which needs help from the Pexpect module to avoid password prompts unless you already have passwordless SSH set up to the remote host. I'm aware of Twisted'...

python - How do I create a new signal in pygtk

I've created a python object, but I want to send signals on it. I made it inherit from gobject.GObject, but there doesn't seem to be any way to create a new signal on my object.

python - What do I need to import to gain access to my models?

I'd like to run a script to populate my database. I'd like to access it through the Django database API. The only problem is that I don't know what I would need to import to gain access to this. How can this be achieved?

python - How do I edit and delete data in Django?

I am using django 1.0 and I have created my models using the example in the Django book. I am able to perform the basic function of adding data; now I need a way of retrieving that data, loading it into a form (change_form?! or something), EDIT it and save it back to the DB. Secondly how do I DELETE the data that's in the DB? i.e. search, select and then delete! Please show me an example of the code ...

Still can't find your answer? Check out these communities...

PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python