Module userland.models.message
Message model
Sub-modules
userland.models.message.api
-
Shared userland messages API
userland.models.message.message_tags
-
Message tag relationship model
userland.models.message.tag
-
Message tag model
Classes
class Message (**data)
-
Expand source code
class Message(SQLModel, table=True): """Message model""" id: int | None = Field(primary_key=True, default=None) """Unique ID""" parent_id: int | None = Field(foreign_key="message.id", default=None) """Parent message ID (if any)""" parent: Optional["Message"] = Relationship( back_populates="children", sa_relationship_kwargs={"remote_side": "Message.id"}, ) """Parent message (if any)""" children: list["Message"] = Relationship(back_populates="parent") """Child messages""" author_id: int | None = Field(foreign_key="user.id", default=None) """Author ID of the message""" author: User | None = Relationship( sa_relationship_kwargs={ "primaryjoin": "Message.author_id == User.id", } ) """Author of the message""" recipient_id: int | None = Field(foreign_key="user.id", default=None) """Recipient ID of the message (`None` for public messages)""" recipient: User | None = Relationship( sa_relationship_kwargs={ "primaryjoin": "Message.recipient_id == User.id", } ) """Recipient of the message""" created: datetime = Field(default_factory=datetime.now) """Creation time""" title: str = Field(max_length=120) """Title of the message""" content: str = Field() """The message's content""" def __init__(self, **data: Any): super().__init__(**data) def __repr__(self): # pragma: no cover return f"Message(#{self.id})"
Message model
Ancestors
- sqlmodel.main.SQLModel
- pydantic.main.BaseModel
Class variables
var model_config
Instance variables
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
Author of the message
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
Author ID of the message
var children : sqlalchemy.orm.base.Mapped[list[Message]]
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
Child messages
var content : str
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
The message's content
var created : datetime.datetime
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
Creation time
var id : int | None
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
Unique ID
var parent : sqlalchemy.orm.base.Mapped[Message | None]
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
Parent message (if any)
var parent_id : int | None
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
Parent message ID (if any)
var recipient : sqlalchemy.orm.base.Mapped[User | None]
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
Recipient of the message
var recipient_id : int | None
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
Recipient ID of the message (
None
for public messages) var title : str
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
Title of the message