Skip to content

Conversation

@williballenthin
Copy link
Contributor

first pass at adding a cortex-level routine for registering data models.

pnfo['form'] = name
fullprop = '%s:%s' % (name,prop)
self.formTufoByProp('syn:prop',fullprop,**pnfo)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that we didn't reuse this method to implement _saveCoreModels() because that routine first loads types, and then forms. seems this would minimize dependency issues, so its a better approach. but we can't replicate that here, since we only have access to one datamodel at a time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we would also want an addDataModels([ (name,modl), ... ]) API for use when you do have more than one with interconnected type deps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@coveralls
Copy link

coveralls commented Dec 20, 2016

Coverage Status

Coverage increased (+0.04%) to 87.025% when pulling 2e69374 on williballenthin:cortex-adddatamodel into 3a4136d on vivisect:master.

@coveralls
Copy link

coveralls commented Dec 20, 2016

Coverage Status

Coverage increased (+0.02%) to 87.01% when pulling 283be23 on williballenthin:cortex-adddatamodel into 3a4136d on vivisect:master.

def addDataModel(self, modname, modl):
'''
Store all types/forms/props from the given data model in the cortex.
This should be done on initialization of an empty cortex only.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% true... this could be done after the fact to add a new data model to an old cortex.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

Example:
modname = 'synapse.models.foo'
core.addDataModel(modname, s_dyndep.tryDynFunc(modname+'.getDataModel'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think i'd introduce the dyndep / module complexity here. it'd probably be better to just have a small model dict declared in the example and pass it in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, no problem.

on a semi-related note, where would you like the documentation on a model's schema? should it go here, since this is where the model is actually installed?

pnfo['form'] = name
fullprop = '%s:%s' % (name,prop)
self.formTufoByProp('syn:prop',fullprop,**pnfo)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we would also want an addDataModels([ (name,modl), ... ]) API for use when you do have more than one with interconnected type deps?

Example:
for item in self.getTufosByProp('syn:prop'):
self._initPropTufo(item)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well git's diff algorithm is totally failing here. this function is not touched. focus on addDataModel and addDataModels.

@williballenthin
Copy link
Contributor Author

all recommendations addresses, awaiting further suggestions or reject/merge

@coveralls
Copy link

coveralls commented Dec 22, 2016

Coverage Status

Coverage increased (+0.004%) to 86.993% when pulling f8b375d on williballenthin:cortex-adddatamodel into 3a4136d on vivisect:master.

@invisig0th invisig0th merged commit ef4452a into vertexproject:master Dec 23, 2016
@vertexmc vertexmc modified the milestone: v0.0.10 Feb 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants