def add (self, path_spec, upload) : import werkzeug ### XXX path, gallery, file = path_spec MOM = self._scope.MOM if file : raise elFinder.Error ("errTrgFolderNotFound") pics = sorted (gallery.pictures, key = lambda p : -p.number) if pics : number = pics [0].number + 1 else : number = 0 name, ext = os.path.splitext \ (werkzeug.secure_filename (upload.filename)) img = self.PETM \ ( gallery , number = number , name = name , photo = MOM._Pic_ ( extension = ext ) , thumb = MOM._Thumb_ ( extension = ext ) ) upload.save (img.photo.path) i = PIL.Image.open (img.photo.path) img.photo.width, img.photo.height = i.size i.thumbnail (self.thum_size, PIL.Image.ANTIALIAS) i.save (img.thumb.path) img.thumb.width, img.thumb.height = i.size return self.file_entry (gallery, img)
def add(self, path_spec, upload): import werkzeug ### XXX path, gallery, file = path_spec MOM = self._scope.MOM if file: raise elFinder.Error("errTrgFolderNotFound") pics = sorted(gallery.pictures, key=lambda p: -p.number) if pics: number = pics[0].number + 1 else: number = 0 name, ext = os.path.splitext \ (werkzeug.secure_filename (upload.filename)) img = self.PETM \ ( gallery , number = number , name = name , photo = MOM._Pic_ ( extension = ext ) , thumb = MOM._Thumb_ ( extension = ext ) ) upload.save(img.photo.path) i = PIL.Image.open(img.photo.path) img.photo.width, img.photo.height = i.size i.thumbnail(self.thum_size, PIL.Image.ANTIALIAS) i.save(img.thumb.path) img.thumb.width, img.thumb.height = i.size return self.file_entry(gallery, img)
def _migrate(self, chunk_size, legacy_lifter): src = self.src e_iter = src.ems.pcm.produce_entities() c_iter = src.ems.pcm.produce_changes() if legacy_lifter: ll = MOM.Legacy_Lifter_Wrapper(self, legacy_lifter) e_iter = ll.entity_iter(e_iter) c_iter = ll.change_iter(c_iter) self.ems.pcm.consume(e_iter, c_iter, chunk_size, src.db_meta_data)
# Copyright (C) 2012 Mag. Christian Tanzer. All rights reserved # Glasauergasse 32, A--1130 Wien, Austria. [email protected] # **************************************************************************** # This package is part of the package MOM. # # This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # MOM.Graph.__init__ # # Purpose # Package providing graphical display of MOM object models # # Revision Dates # 16-Aug-2012 (CT) Creation # ««revision-date»»··· #-- from _TFL.Package_Namespace import Package_Namespace from _MOM import MOM Graph = Package_Namespace() MOM._Export("Graph") del Package_Namespace ### __END__ MOM.Graph.__init__
def _create_app_type (self, PNS, name) : from _MOM._EMS.Hash import Manager as EMS from _MOM._DBW._HPS.Manager import Manager as DBW PNS._Import_All () return MOM.App_Type (name, PNS).Derived (EMS, DBW)
import _MOM.Entity import _MOM.Error import _MOM.Link import _MOM.Object import _MOM.Q_Exp import _MOM.Selector import _MOM.Scope import _MOM._Attr.Selector from _MOM._Attr.Type import * from _MOM._Attr import Attr from _MOM._Pred import Pred from _MOM._Attr.Date_Time import * from _MOM._Attr.Structured import * import _MOM.Derived_PNS def import_full_model(): """Import all essential classes defined by MOM.""" import _MOM.Document import _MOM.Id_Entity_has_Tag # end def import_full_model MOM._Export("import_full_model") ### __END__ MOM.import_MOM
# # This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # GTW.OMP.NET.__init__ # # Purpose # Package defining a partial object model for network objects # # Revision Dates # 6-Mar-2012 (CT) Creation # 15-Jun-2013 (CT) Use `MOM.Derived_PNS` # ««revision-date»»··· #-- from _GTW._OMP import OMP from _MOM import MOM import _MOM.Derived_PNS _desc_ = __doc__ = """ Partial object model for network objects. """ NET = MOM.Derived_PNS (parent = MOM) OMP._Export ("NET") ### __END__ GTW.OMP.NET.__init__
# #++ # Name # auto_imports # # Purpose # Automatically import MOM-related modules that are needed during # sphinx run (import when a specific module is documented is too late!) # # Revision Dates # 17-Aug-2015 (CT) Creation # ««revision-date»»··· #-- from _MOM import MOM from _GTW._OMP._Auth import Auth from _GTW._OMP._EVT import EVT from _GTW._OMP._PAP import PAP from _GTW._OMP._SRM import SRM from _GTW._OMP._SWP import SWP MOM._Import_All () MOM.Attr._Import_All () Auth._Import_All () EVT._Import_All () PAP._Import_All () SRM._Import_All () SWP._Import_All () ### __END__ auto_imports
# This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # GTW.OMP.SWP.__init__ # # Purpose # Package defining a partial object model for static web pages # # Revision Dates # 31-Jan-2010 (CT) Creation # 9-Oct-2012 (CT) Add `_desc_` # 15-Jun-2013 (CT) Use `MOM.Derived_PNS` # ««revision-date»»··· #-- from _GTW._OMP import OMP from _MOM import MOM import _MOM.Derived_PNS _desc_ = __doc__ = """ Partial object model for static web pages. """ SWP = MOM.Derived_PNS(parent=MOM, pns_alias="SWP") OMP._Export("SWP") ### __END__ GTW.OMP.SWP.__init__
# You should have received a copy of the GNU Affero General Public License # along with this module. If not, see <http://www.gnu.org/licenses/>. # #*** </License> ***********************************************************# # #++ # Name # FFM.__init__ # # Purpose # Package defining the common node model for Funkfeuer... # # Revision Dates # 6-Mar-2012 (CT) Creation # 9-Oct-2012 (CT) Add `_desc_` # 15-Jun-2013 (CT) Use `MOM.Underived_PNS` # ««revision-date»»··· #-- from __future__ import absolute_import, division, print_function, unicode_literals from _MOM import MOM import _MOM.Derived_PNS _desc_ = """ Object model defining the common node model for Funkfeuer. """ FFM = MOM.Underived_PNS() ### __END__ FFM.__init__
# This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # GTW.OMP.EVT.__init__ # # Purpose # Package defining a partial object model for calendary events # # Revision Dates # 10-Mar-2010 (CT) Creation # 9-Oct-2012 (CT) Add `_desc_` # 15-Jun-2013 (CT) Use `MOM.Derived_PNS` # ««revision-date»»··· #-- from _GTW._OMP import OMP from _MOM import MOM import _MOM.Derived_PNS _desc_ = __doc__ = """ Partial object model for calendary events. """ EVT = MOM.Derived_PNS (parent = MOM, pns_alias = "EVT") OMP._Export ("EVT") ### __END__ GTW.OMP.EVT.__init__
from a container association. DFC-synthesis is specified for the association that needs synthetic `DFC_Links` by defining the property `dfc_synthesizer` (which must be an instance of a subclass of :class:`~_MOM.DFC_Link.DFC_Synthesizer`) for the role related to `X`. For instance, given `C`, `X`, and `X_in_C` as described above, DFC-synthesis for an association `X_has_P` would be defined like:: class X_has_P (Link2) : class _Attributes (Link2._Attributes) : class left (Link2._Attributes.left) : role_type = X dfc_synthesizer = MOM.DFC_Synthesizer_LL (X_in_C) # end class left class right (Link2._Attributes.right) : role_type = P # end class right # end class _Attributes """ if __name__ != "__main__" : MOM._Export ("*", "_Link_n_") ### __END__ MOM.Link
# This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # GTW.OMP.SRM.__init__ # # Purpose # Package defining a partial object model for sailing regattas # # Revision Dates # 15-Apr-2010 (CT) Creation # 9-Oct-2012 (CT) Add `_desc_` # 15-Jun-2013 (CT) Use `MOM.Derived_PNS` # ««revision-date»»··· #-- from _GTW._OMP import OMP from _MOM import MOM import _MOM.Derived_PNS _desc_ = __doc__ = """ Partial object model for the management of sailboat regattas. """ SRM = MOM.Derived_PNS(parent=MOM, pns_alias="SRM") OMP._Export("SRM") ### __END__ GTW.OMP.SRM.__init__
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from _MOM import MOM from _TFL import TFL import _TFL.Sorted_By class UI_Spec (object) : """UI specification for E_Types defined by MOM.""" Document = dict \ ( list_display = ("entity", "url", "type") ) Id_Entity_has_Tag = dict \ ( ) Tag = dict \ ( list_display = ("name", "description") ) # end class UI_Spec if __name__ != "__main__" : MOM._Export ("UI_Spec") ### __END__ MOM.UI_Spec
pap_subject_has_phone.pid AS pap_subject_has_phone_pid, pap_subject_has_property."desc" AS pap_subject_has_property_desc, pap_subject_has_property."left" AS pap_subject_has_property_left, pap_subject_has_property."right" AS pap_subject_has_property_right, pap_subject_has_property.pid AS pap_subject_has_property_pid FROM mom_id_entity JOIN pap_subject_has_property ON mom_id_entity.pid = pap_subject_has_property.pid LEFT OUTER JOIN pap_subject_has_phone ON pap_subject_has_property.pid = pap_subject_has_phone.pid LEFT OUTER JOIN pap_association AS pap_association__1 ON pap_association__1.pid = pap_subject_has_property."left" LEFT OUTER JOIN pap_company AS pap_company__1 ON pap_company__1.pid = pap_subject_has_property."left" LEFT OUTER JOIN pap_phone ON pap_phone.pid = pap_subject_has_property."right" WHERE (pap_association__1.pid IS NOT NULL OR pap_company__1.pid IS NOT NULL) AND pap_phone.cc = :cc_1 In a different application that doesn't import ``PAP.Association``, exactly the same query would result in **one less join** (because there wouldn't be a table ``pap_association``). """ if __name__ != "__main__" : MOM._Export ("Q") MOM._Export_Module () ### __END__ MOM.Q_Exp
# -*- coding: utf-8 -*- # Copyright (C) 2009 Mag. Christian Tanzer All rights reserved # Glasauergasse 32, A--1130 Wien, Austria. [email protected] # **************************************************************************** # This module is part of the package _MOM. # # This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # # ++ # Name # MOM.Product_Version # # Purpose # Model product version of form `major.minor.patchlevel' # # Revision Dates # 18-Dec-2009 (CT) Creation # ««revision-date»»··· # -- from _MOM import MOM from _TFL.Product_Version import * if __name__ == "__main__": MOM._Export("Product_Version") ### __END__ MOM.Product_Version
# Name # MOM.Pred.__init__ # # Purpose # Initialize package `MOM.Pred` # # Revision Dates # 17-Sep-2009 (CT) Creation (factored from TOM.Pred) # ««revision-date»»··· #-- from _TFL.Package_Namespace import Package_Namespace from _MOM import MOM Pred = Package_Namespace() MOM._Export("Pred") del Package_Namespace __doc__ = """ .. moduleauthor:: Christian Tanzer <*****@*****.**> `MOM.Pred` provides a framework for the definition and implementation of essential and non-essential predicates of :class:`objects<_MOM.Object.Object>` and :class:`links<_MOM.Link.Link>` of essential object models. A predicate defines a condition that must be satisfied by the instances of an essential class or association. Some predicates must hold at all times during the life of an entity (commonly called `invariants`_), others must only be satisfied at certain points in
from __future__ import print_function from __future__ import unicode_literals from _MOM import MOM from _TFL import TFL import _TFL.Sorted_By class UI_Spec(object): """UI specification for E_Types defined by MOM.""" Document = dict \ ( list_display = ("entity", "url", "type") ) Id_Entity_has_Tag = dict \ ( ) Tag = dict \ ( list_display = ("name", "description") ) # end class UI_Spec if __name__ != "__main__": MOM._Export("UI_Spec") ### __END__ MOM.UI_Spec
# Copyright (C) 2009-2010 Mag. Christian Tanzer. All rights reserved # Glasauergasse 32, A--1130 Wien, Austria. [email protected] # **************************************************************************** # This package is part of the package _MOM. # # This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # MOM.EMS.__init__ # # Purpose # Package for entity manager strategies for MOM # # Revision Dates # 14-Oct-2009 (CT) Creation # ««revision-date»»··· #-- from _MOM import MOM from _TFL.Package_Namespace import Package_Namespace EMS = Package_Namespace() MOM._Export("EMS") del Package_Namespace ### __END__ MOM.EMS.__init__
# Name # MOM.SCM.__init__ # # Purpose # Initialize package `MOM.SCM` # # Revision Dates # 17-Sep-2009 (CT) Creation (factored from `TOM.Pred`) # ««revision-date»»··· #-- from _TFL.Package_Namespace import Package_Namespace from _MOM import MOM SCM = Package_Namespace() MOM._Export("SCM") del Package_Namespace __doc__ = """ .. moduleauthor:: Christian Tanzer <*****@*****.**> Requirements ============ Each scope needs to keep track of changes to the its objects: - Entity changes: * create * remove
# This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # #*** </License> ***********************************************************# # #++ # Name # CNDB.OMP__init__ # # Purpose # Package defining the common node database model for Community Networks. # # Revision Dates # 07-Jul-2014 (CT) Creation # ««revision-date»»··· #-- from __future__ import absolute_import, division, print_function, unicode_literals from _MOM import MOM from _CNDB import CNDB import _MOM.Derived_PNS _desc_ = """ Object model defining the common node database model for Community Networks. """ OMP = MOM.Derived_PNS(parent=MOM, pns_alias="CNDB") CNDB._Export("OMP") ### __END__ CNDB.OMP__init__
import _MOM.App_Type import _MOM.Entity import _MOM.Error import _MOM.Link import _MOM.Object import _MOM.Q_Exp import _MOM.Selector import _MOM.Scope import _MOM._Attr.Selector from _MOM._Attr.Type import * from _MOM._Attr import Attr from _MOM._Pred import Pred from _MOM._Attr.Date_Time import * from _MOM._Attr.Structured import * import _MOM.Derived_PNS import _TFL.fix_datetime_pickle_2_vs_3 def import_full_model () : """Import all essential classes defined by MOM.""" import _MOM.Document import _MOM.Id_Entity_has_Tag # end def import_full_model MOM._Export ("import_full_model") ### __END__ MOM.import_MOM
# **************************************************************************** # #++ # Name # MOM.DBW.__init__ # # Purpose # Package for database wrappers # # Revision Dates # 20-Sep-2009 (MG) Creation # ««revision-date»»··· #-- from _MOM import MOM from _TFL.Package_Namespace import Package_Namespace DBW = Package_Namespace() MOM._Export("DBW") del Package_Namespace __doc__ = """ .. moduleauthor:: Christian Tanzer <*****@*****.**> `MOM.DBW` contains packages with database wrappers for various backends. """ ### __END__ MOM.DBW.__init__
# #++ # Name # auto_imports # # Purpose # Automatically import MOM-related modules that are needed during # sphinx run (import when a specific module is documented is too late!) # # Revision Dates # 17-Aug-2015 (CT) Creation # ««revision-date»»··· #-- from _MOM import MOM from _GTW._OMP._Auth import Auth from _GTW._OMP._EVT import EVT from _GTW._OMP._PAP import PAP from _GTW._OMP._SRM import SRM from _GTW._OMP._SWP import SWP MOM._Import_All() MOM.Attr._Import_All() Auth._Import_All() EVT._Import_All() PAP._Import_All() SRM._Import_All() SWP._Import_All() ### __END__ auto_imports
# -*- coding: utf-8 -*- # Copyright (C) 2009 Mag. Christian Tanzer All rights reserved # Glasauergasse 32, A--1130 Wien, Austria. [email protected] # **************************************************************************** # This module is part of the package _MOM. # # This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # MOM.Product_Version # # Purpose # Model product version of form `major.minor.patchlevel' # # Revision Dates # 18-Dec-2009 (CT) Creation # ««revision-date»»··· #-- from _MOM import MOM from _TFL.Product_Version import * if __name__ == "__main__" : MOM._Export ("Product_Version") ### __END__ MOM.Product_Version
.. data:: SQ `SQ` is an instance of :class:`_SQ_`. >>> sq = SQ ["PAP.Person"] >>> print (sq) SQ [PAP.Person] >>> print (sq.order_by (- Q.last_name)) SQ [PAP.Person].order_by (- Q.last_name) >>> print (sq.order_by (- Q.last_name).limit (5).offset (10)) SQ [PAP.Person] .order_by (- Q.last_name) .limit (5) .limit (10) >>> print (sq.filter (Q.last_name.STARTSWITH ("tanzer"))) SQ [PAP.Person].filter (Q.last_name.startswith ('tanzer',)) >>> print (sq) SQ [PAP.Person] >>> SQ [Q.PAP.Person] is sq True >>> sq.order_by (- Q.last_name) is sq False >>> SQ [Q.PAP.Person_has_Phone] is sq False """ if __name__ != "__main__" : MOM._Export ("SQ") ### __END__ MOM.SQ
# Name # MOM.Prop.__init__ # # Purpose # Initialize package `MOM.Prop` # # Revision Dates # 24-Sep-2009 (CT) Creation (factored from TOM classes) # ««revision-date»»··· #-- from _TFL.Package_Namespace import Package_Namespace from _MOM import MOM Prop = Package_Namespace () MOM._Export ("Prop") del Package_Namespace __doc__ = """ .. moduleauthor:: Christian Tanzer <*****@*****.**> `MOM.Prop` provides a framework for the definition and implementation of essential attributes and predicates of :class:`objects<_MOM.Object.Object>` and :class:`links<_MOM.Link.Link>` of essential object models. """ ### __END__ MOM.Prop.__init__
# Copyright (C) 2009-2010 Mag. Christian Tanzer. All rights reserved # Glasauergasse 32, A--1130 Wien, Austria. [email protected] # **************************************************************************** # This package is part of the package _MOM. # # This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # MOM.EMS.__init__ # # Purpose # Package for entity manager strategies for MOM # # Revision Dates # 14-Oct-2009 (CT) Creation # ««revision-date»»··· #-- from _MOM import MOM from _TFL.Package_Namespace import Package_Namespace EMS = Package_Namespace () MOM._Export ("EMS") del Package_Namespace ### __END__ MOM.EMS.__init__
# MOM.Meta.__init__ # # Purpose # Initialize package `MOM.Meta` # # Revision Dates # 17-Sep-2009 (CT) Creation (factored from TOM.Meta) # ««revision-date»»··· #-- from _TFL.Package_Namespace import Derived_Package_Namespace from _TFL import TFL from _MOM import MOM import _TFL._Meta Meta = Derived_Package_Namespace (parent = TFL.Meta) MOM._Export ("Meta") del Derived_Package_Namespace __doc__ = """ .. moduleauthor:: Christian Tanzer <*****@*****.**> `MOM.Meta` provides meta classes for the definition and implementation of essential object models (see :mod:`MOM<_MOM>`). """ ### __END__ MOM.Meta.__init__
# Name # MOM.SCM.__init__ # # Purpose # Initialize package `MOM.SCM` # # Revision Dates # 17-Sep-2009 (CT) Creation (factored from `TOM.Pred`) # ««revision-date»»··· #-- from _TFL.Package_Namespace import Package_Namespace from _MOM import MOM SCM = Package_Namespace () MOM._Export ("SCM") del Package_Namespace __doc__ = """ .. moduleauthor:: Christian Tanzer <*****@*****.**> Requirements ============ Each scope needs to keep track of changes to the its objects: - Entity changes: * create * remove
# Copyright (C) 2012 Mag. Christian Tanzer. All rights reserved # Glasauergasse 32, A--1130 Wien, Austria. [email protected] # **************************************************************************** # This package is part of the package MOM. # # This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # MOM.Graph.__init__ # # Purpose # Package providing graphical display of MOM object models # # Revision Dates # 16-Aug-2012 (CT) Creation # ««revision-date»»··· #-- from _TFL.Package_Namespace import Package_Namespace from _MOM import MOM Graph = Package_Namespace () MOM._Export ("Graph") del Package_Namespace ### __END__ MOM.Graph.__init__
pap_subject_has_phone.pid AS pap_subject_has_phone_pid, pap_subject_has_property."desc" AS pap_subject_has_property_desc, pap_subject_has_property."left" AS pap_subject_has_property_left, pap_subject_has_property."right" AS pap_subject_has_property_right, pap_subject_has_property.pid AS pap_subject_has_property_pid FROM mom_id_entity JOIN pap_subject_has_property ON mom_id_entity.pid = pap_subject_has_property.pid LEFT OUTER JOIN pap_subject_has_phone ON pap_subject_has_property.pid = pap_subject_has_phone.pid LEFT OUTER JOIN pap_association AS pap_association__1 ON pap_association__1.pid = pap_subject_has_property."left" LEFT OUTER JOIN pap_company AS pap_company__1 ON pap_company__1.pid = pap_subject_has_property."left" LEFT OUTER JOIN pap_phone ON pap_phone.pid = pap_subject_has_property."right" WHERE (pap_association__1.pid IS NOT NULL OR pap_company__1.pid IS NOT NULL) AND pap_phone.cc = :cc_1 In a different application that doesn't import ``PAP.Association``, exactly the same query would result in **one less join** (because there wouldn't be a table ``pap_association``). """ if __name__ != "__main__": MOM._Export("Q") MOM._Export_Module() ### __END__ MOM.Q_Exp
# This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # GTW.OMP.DNS.__init__ # # Purpose # Package defining a partial object model for Domain-Name Service # (DNS) # # Revision Dates # 27-Aug-2012 (RS) Creation # 15-Jun-2013 (CT) Use `MOM.Derived_PNS` # ««revision-date»»··· #-- from _GTW._OMP import OMP from _MOM import MOM import _MOM.Derived_PNS _desc_ = __doc__ = """ Partial object model for domain name service. """ DNS = MOM.Derived_PNS(parent=MOM, pns_alias="DNS") OMP._Export("DNS") ### __END__ GTW.OMP.DNS.__init__
# Name # MOM.Prop.__init__ # # Purpose # Initialize package `MOM.Prop` # # Revision Dates # 24-Sep-2009 (CT) Creation (factored from TOM classes) # ««revision-date»»··· #-- from _TFL.Package_Namespace import Package_Namespace from _MOM import MOM Prop = Package_Namespace() MOM._Export("Prop") del Package_Namespace __doc__ = """ .. moduleauthor:: Christian Tanzer <*****@*****.**> `MOM.Prop` provides a framework for the definition and implementation of essential attributes and predicates of :class:`objects<_MOM.Object.Object>` and :class:`links<_MOM.Link.Link>` of essential object models. """ ### __END__ MOM.Prop.__init__
.. data:: SQ `SQ` is an instance of :class:`_SQ_`. >>> sq = SQ ["PAP.Person"] >>> print (sq) SQ [PAP.Person] >>> print (sq.order_by (- Q.last_name)) SQ [PAP.Person].order_by (- Q.last_name) >>> print (sq.order_by (- Q.last_name).limit (5).offset (10)) SQ [PAP.Person] .order_by (- Q.last_name) .limit (5) .limit (10) >>> print (sq.filter (Q.last_name.STARTSWITH ("tanzer"))) SQ [PAP.Person].filter (Q.last_name.startswith ('tanzer',)) >>> print (sq) SQ [PAP.Person] >>> SQ [Q.PAP.Person] is sq True >>> sq.order_by (- Q.last_name) is sq False >>> SQ [Q.PAP.Person_has_Phone] is sq False """ if __name__ != "__main__": MOM._Export("SQ") ### __END__ MOM.SQ
( obj, AQ = None, level = 1, indent = " ", skip_attrs = {} , _ui_name = None ) : return "\n".join \ (formatted_iter (obj, AQ, level, indent, skip_attrs, _ui_name)) # end def formatted def formatted_iter \ ( obj, AQ = None, level = 1, indent = " ", skip_attrs = {} , _ui_name = None ) : if AQ is None : AQ = Selector.editable head = indent * level yield _ui_name or obj.ui_name_T for ak in AQ (obj) : t_skip_attrs = skip_attrs.get (ak.name, {}) show = isinstance (t_skip_attrs, dict) or not t_skip_attrs if show and ak.has_substance (obj) : if ak.E_Type : t_skip_attrs = dict \ (skip_attrs.get (ak.E_Type.type_name, {}), ** t_skip_attrs) fa = formatted_attr (ak, obj, AQ, level+1, indent, t_skip_attrs) if fa is not None : yield head + fa # end def formatted_iter if __name__ != "__main__" : MOM._Export ("formatted") ### __END__ MOM.formatted
( TFL.Meta.BaM ( MOM._Id_Entity_Destroyed_Mixin_ , metaclass = MOM.Meta.M_E_Type_Object_Destroyed ) ) : """Mixin triggering an exception on any attribute access to a destroyed object. """ # end class _Object_Destroyed_Mixin_ @TFL.Add_To_Class ("_Reload_Mixin_", Object) class _Object_Reload_Mixin_ \ ( TFL.Meta.BaM ( MOM._Id_Entity_Reload_Mixin_ , metaclass = MOM.Meta.M_E_Type_Object_Reload ) ) : """Mixin triggering a reload from the database on any attribute access.""" # end class _Object_Reload_Mixin_ __doc__ = """ """ if __name__ != "__main__" : MOM._Export ("*") ### __END__ MOM.Object
# **************************************************************************** # #++ # Name # GTW.OMP.PAP.__init__ # # Purpose # Package defining a partial object model for Persons, Addresses, and # Phone-Numbers # # Revision Dates # 30-Dec-2009 (CT) Creation # 9-Oct-2012 (CT) Add `_desc_` # 15-Jun-2013 (CT) Use `MOM.Derived_PNS` # ««revision-date»»··· #-- from _GTW._OMP import OMP from _MOM import MOM import _MOM.Derived_PNS _desc_ = __doc__ = """ Partial object model for (natural and legal) persons and their (contact) properties. """ PAP = MOM.Derived_PNS(parent=MOM, pns_alias="PAP") OMP._Export("PAP") ### __END__ GTW.OMP.PAP.__init__
# This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # GTW.OMP.Auth.__init__ # # Purpose # Package defining a partial object model for Authentication # # Revision Dates # 13-Jan-2010 (MG) Creation # 9-Oct-2012 (CT) Add `_desc_` # 15-Jun-2013 (CT) Use `MOM.Derived_PNS` # ««revision-date»»··· #-- from _GTW._OMP import OMP from _MOM import MOM import _MOM.Derived_PNS _desc_ = __doc__ = """ Partial object model for authentication: accounts, groups, and their relations. """ Auth = MOM.Derived_PNS (parent = MOM, pns_alias = "Auth") OMP._Export ("Auth") ### __END__ GTW.OMP.Auth.__init__
def app_type(self): from _MOM._DBW._HPS.Manager import Manager as DBW from _MOM._EMS.Hash import Manager as EMS apt = MOM.App_Type(self.PNS._._bname, self.PNS) return apt.Derived(EMS, DBW)
def destroy(self): self.ems.close() self.__dict__.clear() # end def destroy def _migrate(self, chunk_size, legacy_lifter): src = self.src e_iter = src.ems.pcm.produce_entities() c_iter = src.ems.pcm.produce_changes() if legacy_lifter: ll = MOM.Legacy_Lifter_Wrapper(self, legacy_lifter) e_iter = ll.entity_iter(e_iter) c_iter = ll.change_iter(c_iter) self.ems.pcm.consume(e_iter, c_iter, chunk_size, src.db_meta_data) # end def _migrate def __str__(self): return "%s <%s>" % (self.__class__.__name__, self.db_url) # end def __str__ # end class DB_Man if __name__ != "__main__": MOM._Export("*") ### __END__ MOM.DB_Man
# Name # MOM.Attr.__init__ # # Purpose # Initialize package `MOM.Attr` # # Revision Dates # 17-Sep-2009 (CT) Creation (factored from TOM.Attr) # ««revision-date»»··· # -- from _TFL.Package_Namespace import Package_Namespace from _MOM import MOM Attr = Package_Namespace() MOM._Export("Attr") del Package_Namespace __doc__ = """ .. moduleauthor:: Christian Tanzer <*****@*****.**> `MOM.Attr` provides a framework for the definition and implementation of essential and non-essential attributes of :class:`objects<_MOM.Object.Object>` and :class:`links<_MOM.Link.Link>` of essential object models. Each attribute is characterized by - its :class:`type<_MOM._Attr.Type.A_Attr_Type>`
# Name # MOM.Pred.__init__ # # Purpose # Initialize package `MOM.Pred` # # Revision Dates # 17-Sep-2009 (CT) Creation (factored from TOM.Pred) # ««revision-date»»··· #-- from _TFL.Package_Namespace import Package_Namespace from _MOM import MOM Pred = Package_Namespace () MOM._Export ("Pred") del Package_Namespace __doc__ = """ .. moduleauthor:: Christian Tanzer <*****@*****.**> `MOM.Pred` provides a framework for the definition and implementation of essential and non-essential predicates of :class:`objects<_MOM.Object.Object>` and :class:`links<_MOM.Link.Link>` of essential object models. A predicate defines a condition that must be satisfied by the instances of an essential class or association. Some predicates must hold at all times during the life of an entity (commonly called `invariants`_), others must only be satisfied at certain points in
) if iht_p : result ["MOM.Id_Entity"]._add \ ( ET.MOM.Id_Entity_has_Tag ( IS_A.MOM.Link2 , Role.left () , Role.right ( IS_A.MOM.Object , offset = CD.N ) , offset = CD.E ) ) return result # end def graph class Command (MOM.Graph.Command) : @TFL.Meta.Class_and_Instance_Once_Property def PNS (self) : return MOM # end def PNS # end class Command if __name__ != "__main__" : MOM._Export_Module () else : Command () () ### __END__ MOM.graph
# **************************************************************************** # #++ # Name # MOM.DBW.__init__ # # Purpose # Package for database wrappers # # Revision Dates # 20-Sep-2009 (MG) Creation # ««revision-date»»··· #-- from _MOM import MOM from _TFL.Package_Namespace import Package_Namespace DBW = Package_Namespace () MOM._Export ("DBW") del Package_Namespace __doc__ = """ .. moduleauthor:: Christian Tanzer <*****@*****.**> `MOM.DBW` contains packages with database wrappers for various backends. """ ### __END__ MOM.DBW.__init__