我正在读取这些代码块(在Django视图文件中的函数中找到),其中将Job类分配给可变作业,如下所示(参见最后6行)。找不到代码在线。
我之前没有遇到过这种调用外部类的方法。这是将类分配给Django中变量的常用方法吗?
谢谢!
def ajax_save_job(request,session):
c = {}
user_model = session.get_property('user_model')
userid = user_model.get_property('UserID')
JobID = request.POST.get('JobID',False)
collectAddress = request.POST.get('collectAddress',False)
collectContactNumber = request.POST.get('collectContactNumber',False)
collectContactName = request.POST.get('collectContactName',False)
deliverAddress = request.POST.get('deliverAddress',False)
deliverContactNumber = request.POST.get('deliverContactNumber',False)
deliverContactName = request.POST.get('deliverContactName',False)
collectCompanyName = request.POST.get('collectCompanyName',False)
deliverCompanyName = request.POST.get('deliverCompanyName',False)
price = request.POST.get('price',False)
parcelWeight = request.POST.get('parcelWeight',False)
parcelSize = request.POST.get('parcelSize',False)
collectDate = request.POST.get('collectDate',False)
collectTimeFrom = request.POST.get('collectTimeFrom',False)
collectTimeEnd = request.POST.get('collectTimeEnd',False)
deliverDate = request.POST.get('deliverDate',False)
deliverTimeFrom = request.POST.get('deliverTimeFrom',False)
deliverTimeEnd = request.POST.get('deliverTimeEnd',False)
rearrangementStatus = request.POST.get('rearrangementStatus',False)
rearrangementMaxLimit = request.POST.get('rearrangementMaxLimit',False)
RearrangementExpiry = request.POST.get('RearrangementExpiry',False)
parcelDescription = request.POST.get('parcelDescription',False)
collectedon = request.POST.get('collectedon',False)
deliveredon = request.POST.get('deliveredon',False)
collectPostal = request.POST.get('collectPostal',False)
deliverPostal = request.POST.get('deliverPostal',False)
assignedTo = request.POST.get('assignedTo',False)
status = request.POST.get('status',False)
job = False
output = {}
try:
job = Job.init(JobID,index="JobID",multiple=False)
if (job.properties['status'].lower() == 'processing' or job.properties['status'].lower() == 'bidding') and assignedTo != job.properties['assignedTo'] :
status ='Assigned'
except:
job = False
班级工作(基地):
table = 'tbl_jobs' index = 'JobID' def __init__(self,**kwargs): Base.__init__(self) self.keys = ['JobID'] self.required_property_list = ['postByUserID','price'] self.unique_properties = [] self.db_fields = ['paypalToken','JobID','postByUserID','jobName','parcelDescription','parcelSize','parcelWeight','declaredValue','collectDate','collectTimeFrom','collectTimeEnd','collectContactName','collectContactNumber','collectPostal','collectAddress','collectRegion','collectLatitude','collectLongitude','deliverDate','deliverTimeFrom','deliverTimeEnd','deliverContactName','deliverContactNumber','deliverPostal','deliverAddress','deliverRegion','deliverLatitude','deliverLongitude','biddingTime','biddingTimeEnd','price','postedOn','assignedTo','posted_by','PAID','jobType','status','paymentMethod','collectCompanyName','deliverCompanyName','collectSelfRefName','deliverSelfRefName','collectContactEmail','deliverContactEmail'] if len(kwargs) == 0: return for key in kwargs: self.properties[key] = kwargs[key] missing_properties = self.required_properies() if len(missing_properties) > 0: raise UserModelPropertyMissingException('Required Property Missing',missing_properties)
答案 0 :(得分:0)
它在我看来 - 这只是一个猜测 - 就像这里发生的是你正在创建一个具有给定id的Job实例,并告诉它“multiple = False”,你的意思是,如果已经存在,你想要现有的,而不是新的 - 一种获取或创建标志。然后,您可以使用该作业的状态来更新您正在做的任何事情的状态。
显然,没有更多的事情可以继续,这只是在黑暗中刺伤。