ok
Direktori : /opt/alt/python38/lib64/python3.8/site-packages/playhouse/__pycache__/ |
Current File : //opt/alt/python38/lib64/python3.8/site-packages/playhouse/__pycache__/gfk.cpython-38.pyc |
U S��W� � @ s� d Z ddlT ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ e � Z i ZG dd � d e�ZG d d� deee��Zdd � ZG dd� de �ZG dd� de �ZG dd� de �ZdS )a Provide a "Generic ForeignKey", similar to Django. A "GFK" is composed of two columns: an object ID and an object type identifier. The object types are collected in a global registry (all_models), so all you need to do is subclass ``gfk.Model`` and your model will be added to the registry. Example: class Tag(Model): tag = CharField() object_type = CharField(null=True) object_id = IntegerField(null=True) object = GFKField('object_type', 'object_id') class Blog(Model): tags = ReverseGFK(Tag, 'object_type', 'object_id') class Photo(Model): tags = ReverseGFK(Tag, 'object_type', 'object_id') tag.object -> a blog or photo blog.tags -> select query of tags for ``blog`` instance Blog.tags -> select query of all tags for Blog instances � )�*)� BaseModel)�Model)�SelectQuery)�UpdateQuery)�with_metaclassc s e Zd Z� fdd�Z� ZS )r c s, t t| ��| |||�} |dkr(t�| � | S )N)Z_metaclass_helper_r )�superr �__new__� all_models�add)�cls�name�basesZattrs�� __class__� �/gfk.pyr '