-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Different behavior between generated model and dynamic loaded #119
Comments
Hi @AnNeub Thanks so much once again for the issue :) ! You are definitely right, the automatique handling of keyword parameters should be equivalent to the generated code. This is definitely a "half-baked" feature for dynamic metamodels that I didn't finish properly 😅. Your patch is just perfect and gives the same semantic than the generated code. You can use def new_init(self, *args, **kwargs):
for name, value in kwargs.items():
feature = self.eClass.findEStructuralFeature(name)
if feature:
if feature._many:
attr = getattr(self, name)
attr.extend(value)
else:
setattr(self, name, value)
else:
raise AttributeError(f'{self.eClass.name} has no attribute "{name}"') I will integrate your patch on Thanks so much again ! |
Hi Vince, I tested your implementation and This is the macro I am talking about.
Best regards, |
Hi @AnNeub My bad, the attribute is The template you use is just fine as guide. I will change it for a comprehension point of view, but for performances, in the case of the code generator, it will not change anything as the For dynamic Perhaps I should had a special method that would trigger the |
Perhaps I should had a special method that would trigger the init generation on demand? Leaving the code with your patch as normal behavior and trigerring the generation/recompilation only in case the user wants it? |
One additional thing came up. The init doesn't call the init function of the supertypes. Only the structuralFeatures are overtaken. I want to replace the init function of my root element to generate some uuid. And so i figured out that is function will be never called. So far I didn't managed to call the supertypes. I always end up in a recursive loop. |
Hi @AnNeub ; Arrrg, I think it's related to a problem in the way I'm handling keywords with the notification system. Also, I just saw your issue on pyecore/pyecoregen#31 , perhaps there is a connection here. I'll dig that in details asap. |
I was working with a generated model so far. By refactoring my code to also work with dynamic loaded models I run into this issue.
The generator generates for features with upperBound != 1 something like this
if you intialize a dynamic loaded class the initialization looks like this:
which will not work if you provide a list as argument.
I change it to this to get it running.
I dont know if there are some drawbacks i have missed. From my point of view both implementation (generated and dynamic) shall behave similar to make it easier to switch between dynamic and generated.
Best regards,
Andreas
The text was updated successfully, but these errors were encountered: