Module userland.models
Default userland models
Sub-modules
userland.models.message
-
Message model
userland.models.oneliner
-
Oneliner 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
class MessageTag (**data)
-
Expand source code
class MessageTag(SQLModel, table=True): """Message tag model""" name: str | None = Field(max_length=32, primary_key=True, default=None) """The tag's name""" created: datetime = Field(default_factory=datetime.now) """When the tag was created""" __tablename__ = "message_tag" # type: ignore def __init__(self, **data: Any): super().__init__(**data) def __repr__(self): # pragma: no cover return f"MessageTag({self.name})"
Message tag model
Ancestors
- sqlmodel.main.SQLModel
- pydantic.main.BaseModel
Class variables
var model_config
Instance variables
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]
When the tag was created
var name : str | 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]
The tag's name
class MessageTags (**data)
-
Expand source code
class MessageTags(SQLModel, table=True): """Message tag model""" message_id: int = Field(foreign_key="message.id", primary_key=True) """The tagged message ID""" tag_name: str = Field(foreign_key="message_tag.name", primary_key=True) """The name of the tag""" __tablename__ = "message_x_message_tag" # type: ignore def __init__(self, **data: Any): super().__init__(**data)
Message tag model
Ancestors
- sqlmodel.main.SQLModel
- pydantic.main.BaseModel
Class variables
var model_config
Instance variables
var message_id : int
-
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 tagged message ID
var tag_name : 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 name of the tag
class Oneliner (**data)
-
Expand source code
class Oneliner(SQLModel, table=True): """Oneliner model""" MAX_LENGTH: ClassVar = 120 """Maximum length of oneliner messages""" id: int | None = Field(primary_key=True, default=None) """Unique ID""" user_id: int | None = Field(foreign_key="user.id", default=None) """User ID of the author""" user: User | None = Relationship() """Author of the oneliner""" message: str = Field(max_length=MAX_LENGTH) """The oneliner message""" timestamp: datetime = Field(default_factory=datetime.now) """When the oneliner was posted""" def __init__(self, **data: Any): super().__init__(**data) def __repr__(self): # pragma: no cover return f"Oneliner(#{self.id})"
Oneliner model
Ancestors
- sqlmodel.main.SQLModel
- pydantic.main.BaseModel
Class variables
var MAX_LENGTH : ClassVar
-
Maximum length of oneliner messages
var model_config
Instance variables
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 message : 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 oneliner message
var timestamp : 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]
When the oneliner was posted
var user : 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]
Author of the oneliner
var user_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]
User ID of the author