O'Reilly logo

Python 3 Web Development Beginner's Guide by Michel Anders

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action adapting MetaRelation

In the Display class, we used the information about the type of relation stored by the MetaRelation metaclass. This is necessary because in recognizing that there is more than one type of relation, we need some way to indicate that when we define a new relation and act upon that information when creating a new class. Look at the following example code:

class A(Entity):
	pass
class B(Entity):
	pass
class AhasmanyB(Relation):
	a=A
	b=B

Here we express the relation between A and B to be one-to-many. If we would like to express the notion that an instance of A may refer only to a single B instance, we need some way to indicate that in the definition. One way of doing so is by reversing the assignments in the class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required