Skip to content

Commit

Permalink
add backward compat support for report_type
Browse files Browse the repository at this point in the history
  • Loading branch information
viseshrp committed Nov 12, 2024
1 parent 860f336 commit 1d0ae29
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ansys/dynamicreporting/core/serverless/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@ def save(self, **kwargs):
def from_db(cls, orm_instance, **kwargs):
# Create a new instance of the correct subclass
if cls is Template:
# the typename should be: Class:Classname where Class can be 'Layout' or 'Generator'
# originally, there were no Class values, so for backward compatibility, we prefix
# with 'Layout'...
type_name = orm_instance.report_type
if ':' not in type_name:
type_name = 'Layout:' + type_name
# Get the class based on the type attribute
templ_cls = cls._type_registry[orm_instance.report_type]
templ_cls = cls._type_registry[type_name]
obj = templ_cls.from_db(orm_instance, **kwargs)
else:
obj = super().from_db(orm_instance, **kwargs)
Expand Down

0 comments on commit 1d0ae29

Please sign in to comment.