I have the following class:
class SoftwarePackage:
def __init__(self, name, description, order_of_installation, url):
self.name = name
self.description = description
self.order_of_installation = order_of_installation
self.url = "http://localhost:9090/api/software_package"
def create():
post_data = {"name": self.name, "description": self.description,
"order_of_installation": self.order_of_installation}
post_data = json.dumps(post_data)
req = urllib2.Request(url, post_data)
req.add_header('Content-Type', 'application/json')
return urllib2.urlopen(req, post_data)
When I try to call the "create" method like this:
sp = SoftwarePackage(name="my-package-1", description="my-package-1-desc", order_of_installation=0, url="")
sp.create()
I get this error:
sp.create()
AttributeError: SoftwarePackage instance has no attribute 'create'
What is the proper way to call this class method?