Project

Profile

Help

Issue #3767

Updated by bizhang almost 6 years ago

In python we have a relational table that maps classifiers to Python content    units [0]  
 There is no current way to create and save this Classifier model when using changesets, since changesets is the thing calling save() on the Content model. ContentUnit. 

 <pre><code class="python"> 
 def _build_additions(delta, remote_metadata): 
     def generate(): 
         for entry in remote_metadata: 
             classifiers = entry.pop('classifiers', []) 
             artifact = models.Artifact(sha256=entry.pop('sha256_digest')) 
             package = python_models.PythonPackageContent(**entry) 
             content = PendingContent( 
                 package, 
                 artifacts={ 
                     PendingArtifact(model=artifact, url=url, relative_path=entry['filename']) 
                 }) 
             for classifier in classifiers: 
                 temp = python_models.Classifier(name=classifier, python_package_content=package) 
                 temp.save() #<----------- This doesn't work because package isn't saved yet 
             yield content 
 </code></pre> 

 [0] https://github.com/pulp/pulp_python/blob/f3e01816b7e4e63d75bfb5566a06198809cf2566/pulp_python/app/models.py#L16

Back