How to use the persistence.Persistent function in Persistence

To help you get started, we’ve selected a few Persistence examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scanlime / picogui / apps / nifty / Nifty / Poing / db.py View on Github external
transaction.get_transaction().commit()
        print 'Poing db saved'

    save = commit

    def __getattr__(self, name):
        return self._r[name]

    def __setattr__(self, name, value):
        self._r[name] = value
        self.commit()

    def dir(self):
        return [(n, o) for n, o in self._r.items() if getattr(o, 'widget', None)]

class Container(persistence.Persistent):
    widget = Lister

    def dir(self):
        return [(n, o) for n, o in self.__dict__.items()
                if getattr(o, 'widget', None) and n[0] != '_']

    def save(self):
        transaction.get_transaction().commit()
        print 'Poing db saved'

class List(persistence.list.PersistentList):
    widget = Lister

    def save(self):
        transaction.get_transaction().commit()
        print 'Poing db saved'
github owenmorris / chandler / chandler / parcels / osaf / calendar / ColumnarSubView.py View on Github external
__copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"

from wxPython.wx import *
from wxPython.xrc import *
from mx import DateTime

from application.Application import app
from application.SimpleCanvas import wxSimpleCanvas

from persistence import Persistent
from persistence.dict import PersistentDict

from OSAF.calendar.CalendarEvents import *

class ColumnarSubView (Persistent):
    def __init__(self, columnarView):
        self.columnarView = columnarView
        
        # Subclasses should set these attributes
        # self.xrcName = None
        # self.viewHeight = 0
        
    def SynchronizeView(self, view):
        view.OnInit(self)
    
    def getViewWidth(self):
        return self.columnarView.viewWidth
    
    def getDaysPerView(self):
        return self.columnarView.daysPerView
github owenmorris / chandler / chandler / parcels / osaf / calendar / MonthNavigator.py View on Github external
__revision__  = "$Revision$"
__date__      = "$Date$"
__copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"

from wxPython.calendar import *
from wxPython.wx import *
from wxPython.xrc import *

from persistence import Persistent

from OSAF.calendar.CalendarEvents import *

from mx import DateTime

class MonthNavigator(Persistent):
    def __init__(self):
        pass
        
    def SynchronizeView(self, view):
        view.OnInit(self)
        

class wxMonthNavigator(wxCalendarCtrl):
    def __init__(self):
        value = wxPreCalendarCtrl()
        self.this = value.this
        self._setOORInfo(self)
        
    def OnInit(self, model):
        self.model = model
        self.SetWindowStyle(wxCAL_SUNDAY_FIRST |
github scanlime / picogui / pg1 / apps / dev / nifty / Nifty / Poing / Data.py View on Github external
def __init__(self, **kw):
        persistence.Persistent.__init__(self)
        Buffer.__init__(self)
        self.__dict__.update(kw)
github scanlime / picogui / pg1 / apps / dev / nifty / Nifty / Poing / Data.py View on Github external
def __init__(self, name, widget=None):
        persistence.Persistent.__init__(self)
        self.name = name
        self.widget = widget or 'Field'
github owenmorris / chandler / chandler / parcels / osaf / calendar / ColumnarViewer.py View on Github external
from mx import DateTime
from persistence.dict import PersistentDict
from persistence import Persistent

from application.Application import app

from OSAF.calendar.ColumnarHeadView import ColumnarHeadView
from OSAF.calendar.ColumnarTimeView import ColumnarTimeView
from OSAF.calendar.ColumnarFootView import ColumnarFootView

from OSAF.calendar.CalendarEvents import *

# @@@ Note, lots in common with MonthViewer, perhaps create a common
#     superclass

class ColumnarViewer(Persistent):
    def __init__(self, calendarView):
        self.xrcClass = "wxPanel"
        self.xrcName = "ColumnarViewer"
        self.displayName = _(" View Week ")
        self.calendarView = calendarView
        
        self.daysPerView = 7
        self.hoursPerView = 24
        
        self.offset = 40
        
        # @@@ not sure how/if this should be initialized
        #     read from xrc, prefs, etc.
        self.viewWidth = 500
        
        self.rangeIncrement = DateTime.RelativeDateTime(days=7)
github scanlime / picogui / pg1 / apps / dev / nifty / Nifty / Poing / Data.py View on Github external
from Nifty.Buffer import Buffer
from Views import Viewer
import persistence, transaction

class Field(persistence.Persistent):
    def __init__(self, name, widget=None):
        persistence.Persistent.__init__(self)
        self.name = name
        self.widget = widget or 'Field'

class PoingEditable(persistence.Persistent, Buffer):
    widget = Viewer

    def __init__(self, **kw):
        persistence.Persistent.__init__(self)
        Buffer.__init__(self)
        self.__dict__.update(kw)

    def __getstate__(self):
        state = persistence.Persistent.__getstate__(self)
        del state['observers']
github owenmorris / chandler / chandler / parcels / osaf / calendar / TableViewer.py View on Github external
__date__      = "$Date$"
__copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
__license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"

from wxPython.wx import *
from wxPython.gizmos import *

from mx import DateTime

from persistence import Persistent

from application.Application import app

from OSAF.calendar.CalendarEvents import *

class TableViewer(Persistent):
    def __init__(self, calendarViewer):
        self.xrcClass = "wxPanel"
        self.xrcName = "TableViewer"
        self.displayName = _(" View Table ")
        
        self.calendarViewer = calendarViewer
        
        self.rangeIncrement = DateTime.RelativeDateTime(months=1)
        self.updateRange(DateTime.today())
        
    def UpdateItems(self):
        viewer = app.association[id(self)]
        viewer._loadEvents()
        viewer._displayEvents()
        viewer.Refresh()
github scanlime / picogui / apps / nifty / Nifty / Poing / Data.py View on Github external
from Nifty.Buffer import Buffer
from Views import Viewer
import persistence, transaction

class Field(persistence.Persistent):
    def __init__(self, name, widget=None):
        persistence.Persistent.__init__(self)
        self.name = name
        self.widget = widget or 'Field'

class PoingEditable(persistence.Persistent, Buffer):
    widget = Viewer

    def __init__(self, **kw):
        persistence.Persistent.__init__(self)
        Buffer.__init__(self)
        self.__dict__.update(kw)

    def __getstate__(self):
        state = persistence.Persistent.__getstate__(self)
        del state['observers']
        del state['python_ns']
        return state

    def __setstate__(self, state):
        persistence.Persistent.__setstate__(self, state)
        self.observers = []
github scanlime / picogui / pg1 / apps / dev / nifty / Nifty / Poing / Data.py View on Github external
def __getstate__(self):
        state = persistence.Persistent.__getstate__(self)
        del state['observers']
        del state['python_ns']
        return state