raise ValueError('%s is not a valid group' % group_name) if group not in owner.groups: raise BX( _(u'User %s is not a member of group %s' % (owner.user_name, group.group_name))) job_retention = xmljob.get_xml_attr('retention_tag', unicode, None) job_product = xmljob.get_xml_attr('product', unicode, None) tag, product = self._process_job_tag_product( retention_tag=job_retention, product=job_product) job = Job(whiteboard=unicode(xmljob.whiteboard), ttasks=0, owner=owner, group=group, submitter=submitter) job.product = product job.retention_tag = tag email_validator = validators.Email(not_empty=True) for addr in set(xmljob.iter_cc()): try: job.cc.append(email_validator.to_python(addr)) except Invalid, e: raise BX( _('Invalid e-mail address %r in <cc/>: %s') % (addr, str(e))) for xmlrecipeSet in xmljob.iter_recipeSets(): recipe_set = self._handle_recipe_set( xmlrecipeSet, owner, ignore_missing_tasks=ignore_missing_tasks) job.recipesets.append(recipe_set) job.ttasks += recipe_set.ttasks if not job.recipesets:
group_name = xmljob.get_xml_attr('group', unicode, None) group = None if group_name: try: group = Group.by_name(group_name) except NoResultFound, e: raise ValueError('%s is not a valid group' % group_name) if group not in owner.groups: raise BX(_(u'User %s is not a member of group %s' % (owner.user_name, group.group_name))) job_retention = xmljob.get_xml_attr('retention_tag',unicode,None) job_product = xmljob.get_xml_attr('product',unicode,None) tag, product = self._process_job_tag_product(retention_tag=job_retention, product=job_product) job = Job(whiteboard=unicode(xmljob.whiteboard), ttasks=0, owner=owner, group=group, submitter=submitter) job.product = product job.retention_tag = tag email_validator = validators.Email(not_empty=True) for addr in set(xmljob.iter_cc()): try: job.cc.append(email_validator.to_python(addr)) except Invalid, e: raise BX(_('Invalid e-mail address %r in <cc/>: %s') % (addr, str(e))) for xmlrecipeSet in xmljob.iter_recipeSets(): recipe_set = self._handle_recipe_set(xmlrecipeSet, owner, ignore_missing_tasks=ignore_missing_tasks) job.recipesets.append(recipe_set) job.ttasks += recipe_set.ttasks if not job.recipesets: raise BX(_('No RecipeSets! You can not have a Job with no recipeSets!')) session.add(job)