[pythonscript][dejavu-orm]有關dejavu

Introduction


Dejavu is a thread-safe Object-Relational Mapper for python application.It 's designed to provide the *Model* third part of an MVC application. When you build an application using dejavu, you must supply the Controllers and views yourself. Dejavu does not provide these.

Basic Structure


  • Creating table by instantiating class which subclass dejavu.Unit.
  • Each subclass possess a sets of attributes known as *properties*,which you can think of as columns in your database table.
  • These attributes are generally formed from a UnitProperty descriptor.
  • Unit classes can also possess arbitrary methods and attributes which aid their use within the application.
  • Unit classes can be associated to other Unit classes. This means that one of the properties of UnitA maps to one of the properties of UnitB. Related objects may then be looked up more easily.
  •  Unit are managed in memory by Sandbox objects, which function as *Identity Maps*: in-memory caches of Units which keep commit conflicts to a minimum. Unit objects can be *memorized* and *recalled* from a Sandbox, using pure Python lambda expressions as a query language. The lambda is wrapped in an Expression object to make it portable.
  • Sandboxes persist Unit data by StorageManager objects. Each persistence mechanism has its own subclass of the StorageManager class; for example, persisting Unit data to a Microsoft SQL Server database requires a StorageManagerADO_SQLServer object. When recalling data, Storage Managers receive Expression objects; database SM's, for example, will typically examine these Expressions and produce SQL statements from them, which they then use to retrieve data. Storage Managers also handle the creation of new Units, and their destruction.
  • Dejavu provides a core Arena class which you should be able to leverage for any sort of application you are building. The Arena object functions as a top-level *Application* object, collecting the global settings for an application into one place. It doles out Shandboxes,maintains a registry of Units and their associations, and manages startup and shutdown operations.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章