-
Notifications
You must be signed in to change notification settings - Fork 4
bone specific renderings moved and split to their Bones. #122
base: develop
Are you sure you want to change the base?
Conversation
…we don't need to override the renderer for new Bones.
Hello @XeoN-GHMB, I did a review on you changes, tested it with a real project and and... I like it! Especially it is downward compatible, so no changes are necessary to existing projects, it doesn't contain any breaking changes, great! I just did a commit 9600cd2 on your pull request. It changes a lot, but most of it are changes to fit into our general coding standards. I'd also added some general changes to the pull request:
Yep, thats all. In my opinion this pull request brings much more flexibility into ViUR. I've already updated the recordBone from a company-internal project and it integrates perfectly. I would like to flag it for ViUR v2.5 if all are comfortable with it. |
…e, which can be used in a Bone to avoid overriding the whole function. The rendererName can be dot separated. In this case the rendererName is resolved from back to front to find a matching function. The default uses the not prefixed version.
…work/server into feature/moving_bone_rendering # Conflicts: # bones/bone.py # bones/captchaBone.py # bones/dateBone.py # bones/numericBone.py # bones/relationalBone.py # bones/selectBone.py # bones/textBone.py # render/admin/__init__.py # render/json/default.py # render/vi/default.py # render/xml/default.py
Hello @phorward, With this mechanic it is possible to append a new renderer without overriting the whole function and multiple definitions for vi and admin renderer are not needed if they are named json.vi or json.admin |
render/xml/default.py
Outdated
return bone.value.strftime("%H:%M:%S") | ||
|
||
elif isinstance(bone, relationalBone): | ||
for renderer in reversed( self.rendererName.split( "." ) ): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should spend a few more thoughts on speed. This would be the most flexible solution, but we'll have have this loop running for each bone in each entry returned. Maybe we should drop sub-classing support here and have only the base-name (ie "html") in that variable so simply know the function to call?
@@ -465,3 +465,18 @@ def setBoneValue(self, valuesCache, boneName, value, append, *args, **kwargs): | |||
return True | |||
else: | |||
return False | |||
|
|||
def renderBoneStructure( self, renderer = None, *args, **kwargs ): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the structure guaranteed to be identically for each render? Otherwise we should also pre/post-fix this function.
…derBoneStructure and renderBoneValue to a new baseRender Class to avoid multiple definitions for each renderer. Each Bone could define a renderType prefixed version of renderBoneStructure and renderBoneValue if this function not exists the baseBone fallback will be used.
bone specific renderings moved and split to their Bones.
As a result we don't need to override the renderer for new Bones.