示例#1
0
def put_package():
	try:
		# Add a new package.
		version = request.forms.get('version')
		name = request.forms.get('name')

		if version and name:
			myDb.put_package(version,name)
		else:
			response.status = "400 - Required fields missing."
		return
	except Exception as e:
		raise Exception('Exception encountered: ' + str(e))
		return None
示例#2
0
 def process_package(self, name, version):
     # retrieve existing package or try to add a new one
     package = None
     matching_package_versions = myDb.get_package_byvalues(name, version)
     if len(matching_package_versions) > 0:
         package = matching_package_versions[0]
         if package.id:
             print "MATCHING PACKAGE FOUND (", package.id, package.name, package.version, ")"
     else:
         # add new package to db
         package = myDb.put_package(version, name)
         if package.id:
             print "ADDED NEW PACKAGE (", package.id, package.name, package.version, ")"
     return package