1.As mentioned in [1], we should avoid using six.iteritems to achieve
iterators. We can use dict.items instead, as it will return iterators
in PY3 as well. And dict.items/keys will more readable.
2.In py2, the performance about list should be negligible, see the
link [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html
Change-Id: I45fa65427318e1c35bb521de46e81ea12ca7b770
ObjectStore is a container for all of the objects that are either
loaded from object model or created at runtime. Thus ObjectStore
instance is required in order to either use new() function or use
class() contract with object model snippet.
In current implementation each object had a object_store property
that was pointing to the ObjectStore instance used to create it (the
one that has the object). In order to create new object an ObjectStore
of the $this object was used for that purpose. This approach caused
several issues:
* There is no $this object in static methods and thus no way to obtain
current ObjectStore
* Objects are bind to their stores so temporary ObjectStore instances
cannot be used to load object graphs
This refactoring moves ObjectStore instances to the thread-local attribute.
Thus there is always a "current" ObjectStore.
Also because ObjectStore has a reference to the MuranoDslExecutor instance
it becomes possible to get current executor and everything else that it contains
(current execution session, attribute store, package loader) from the local
thread storage without passing it in the hidden context variables.
Change-Id: I19a08b391486c1ae1b98ca559c8d3fafaca6e1ef
* New method type: extension methods. Extension methods enable you
to "add" methods to existing types without modifying the original type.
Extension methods are a special kind of static method, but they are
called as if they were instance methods on the extended type.
Extension methods are identified by "Usage: Extension" and the
type they extend is determined by their first argument contract.
Thus such methods must have at lease one parameter.
* New type-level keyword "Import" which can be either list or
scalar that specifies type names which extensions methods
should be imported into class context and thus become available
to type members.
Change-Id: If757327857376ac66784acd4bd29471e6f28b612
Because the're going to be many different types of classes
(like meta-classes) it is reasonable to distinguish murano_class
from a "type", that can refer to any type of class (type)
Change-Id: I05993eb7a37627aaeacbc6c828250791e145d706
* MuranoType and MuranoObjectParameterType smart types
were merged into a single smart type because their functionality overlap
to a large degree. New smart type is called MuranoObjectParameter
* Other smart types were renamed to have the same name pattern:
ThisParameterType -> ThisParameter,
InterfacesParameterType -> InterfacesParameter
* For MuranoObjectInterface instead of saying obj.data().propertyName
the syntax now is obj.properties.propertyName
Change-Id: I3c925d1ba1a4ac0864987377a3e90c6f166823a7
Now it is possible to get type info with typeinfo() function and using
it as a starting point obtain information about the class, its methods
and properties as well as the package of the class.
See TestReflection.yaml for detailed usage.
Also some refactoring to existing code model were made.
Change-Id: Ic8a719e874126d735c26b956a49cb790d434c64c
* Remove all code that now available as part of yaql 1.1
* New format version MuranoPL/1.3 that is identical to 1.2
but protects apps that uses yaql 1.1 new features from being
imported to Murano Liberty
Change-Id: I2d8fc7050403be082e9389ebe5e682816ec6aca1
This also adds a check to murano/hacking/checks.py that
should catch this error in the future.
Blueprint murano-python-3-support
Change-Id: Ib8b2b91a40577d18739f0c1bf2c37b7cf4060560
Previously property was looked up in the original class.
Add unit test to check this situation.
Closes-Bug: #1525890
Change-Id: I7ba9efc58fbcc4b8ff281909473d1c972f0a2507
This commit adds opportunity to call original method
in mock method. Corresponding test is attached.
Targets blueprint mocking-machinery
Change-Id: I889bb576e708d28a083c0a25f66c999a6492057f
Functions for injecting class methods or objects with mocks are added:
* mock can be provided as method name
* mock can be provided as YAQL expression
* Also, withOriginal function is added.
withOriginal allows to use data from the original context in mock function.
Targets blueprint mock-context-manager
Depends-On: I9a55d07188ff06bdf98248f011a700c297e33417
Change-Id: Iefee767390209bfad0cca4f39389e0205cd3c9e2
It is used in murano-test-runner.
Mocks are inserted into new context, that is created
from the current context:
If mock for the current object exist, new linked context
(``murano.dsl.linked_context.LinkedContext``) will be returned. It links
existing context with the new context, where mock definition is presented.
So if mocked function will be called, context will contain two
definitions with that function: mock and original one, but mock will have
higher priority.
If there is no mock for the current object or class, existing context
will be returned. If there is no existing context, *None* will be returned.
Targets blueprint mock-context-manager
Depends-On: I9eccdf3af1802c731bfdfb93df92c4ad902a4d34
Change-Id: I9a55d07188ff06bdf98248f011a700c297e33417