|
|
@ -85,7 +85,54 @@ class Mysql(object): |
|
|
|
suffix = "s" |
|
|
|
return cls._tableprefix + name + cls._tablesuffix |
|
|
|
def changedp(self): |
|
|
|
return self in self.session.dirty |
|
|
|
return self.session.is_modified(self) |
|
|
|
|
|
|
|
|
|
|
|
class MutableSet(MutableSet): |
|
|
|
""" |
|
|
|
Extended version of the mutable set for our states |
|
|
|
""" |
|
|
|
|
|
|
|
def has(self, item): |
|
|
|
""" |
|
|
|
Check if item is in set |
|
|
|
|
|
|
|
@param item Item to check |
|
|
|
""" |
|
|
|
return item in self |
|
|
|
|
|
|
|
def add(self, item): |
|
|
|
""" |
|
|
|
Extended add method, which only result in changed object if there is |
|
|
|
really an item added. |
|
|
|
|
|
|
|
@param item Item to add |
|
|
|
""" |
|
|
|
if not item in self: |
|
|
|
super().add(item) |
|
|
|
|
|
|
|
def discard(self, item): |
|
|
|
""" |
|
|
|
Wrapper for extended remove below |
|
|
|
|
|
|
|
@param item Item to discard |
|
|
|
""" |
|
|
|
self.remove(item) |
|
|
|
|
|
|
|
def remove(self, item, weak=True ): |
|
|
|
""" |
|
|
|
Extended remove method, which only results in changed object if there |
|
|
|
is really an item removed. Additionally, combine remove and discard! |
|
|
|
|
|
|
|
@param item Item to remove/discard |
|
|
|
@param weak Set to false to use remove, else discard behavior |
|
|
|
""" |
|
|
|
if item in self: |
|
|
|
if weak: |
|
|
|
super().discard(item) |
|
|
|
else: |
|
|
|
super().remove(item) |
|
|
|
|
|
|
|
|
|
|
|
class ColumnList( list, MutableComposite ): |
|
|
|
""" |
|
|
@ -249,13 +296,25 @@ class MysqlRedPage( Mysql, Base ): |
|
|
|
pageid = Column( Integer, unique=True, primary_key=True ) |
|
|
|
revid = Column( Integer, unique=True, nullable=False ) |
|
|
|
pagetitle = Column( String(255), nullable=False ) |
|
|
|
status = Column( MutableSet.as_mutable(Status(255)), nullable=True ) |
|
|
|
__status = Column( 'status', MutableSet.as_mutable(Status(255)), nullable=True ) |
|
|
|
|
|
|
|
redfams = relationship( |
|
|
|
"MysqlRedFam", order_by=MysqlRedFam.famhash, back_populates="redpage", |
|
|
|
collection_class=attribute_mapped_collection("famhash")) |
|
|
|
|
|
|
|
@property |
|
|
|
def status( self ): |
|
|
|
""" |
|
|
|
Current fam status |
|
|
|
""" |
|
|
|
return self.__status |
|
|
|
|
|
|
|
@status.setter |
|
|
|
def status( self, status ): |
|
|
|
if status: |
|
|
|
self.__status = MutableSet( status ) |
|
|
|
else: |
|
|
|
self.__status = MutableSet() |
|
|
|
|
|
|
|
Base.metadata.create_all(engine) |
|
|
|
|
|
|
|