{ "info": { "author": "Zope Corporation and Contributors", "author_email": "zope3-dev@zope.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Zope3", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP" ], "description": "The package seeks to allow Python code to be stored in the ZODB. The main\nbenefits are that this code can then be easily transferred to other servers\nand be changed at run time.\n\n\nDetailed Documentation\n**********************\n\n==================\nPersistent Modules\n==================\n\nDocument Overview\n-----------------\n\nThis document seeks to capture technical information about persistent modules\nto guide and document their design.\n\nGoals\n-----\n\nThese goals largely come from Zope 3. It would be worth while considering\nother applications.\n\n- Persistent modules are used to support management of software using the\n ZODB.\n\n- Software can be updated using network clients, such as web browsers and\n file-synchonozation tools.\n\n- Application-server clusters can be updated transactionally without requiring\n server restarts.\n\n- Persistent modules leverage a familiar model, modules, for managing Python\n software.\n\n- Persistent modules can be synchronized to a file-system using the Zope\n file-system synchronization framework. Persistent modules are synchronized\n for purposes including:\n\n o Use of traditional tools such as editors and code-analysis tools\n\n o Revision control\n\n Ideally, the file-system representation would consist of a Python source\n file.\n\nUse cases\n---------\n\n- Create classes and functions that implement Zope 3 components.\n\n o Utility, Adapter, View, and service classes and factories.\n\n o Content components, which are typically persistent and/or\n pickleable.\n\n- Define interfaces, including schema\n\n- Import classes, functions, and interfaces from other modules.\n\n- Import classes, functions, and interfaces from other persistent objects. For\n example, an adapter registration object might have a direct reference to a\n persistent-module-defined class.\n\n- Change module source\n\n - Changes are reflected in module state\n\n - Changes are reflected in objects imported into other modules.\n\n- Synchronize modules with a file-system representation.\n\nEdge cases\n----------\n\n ???\n\nFundamental dilema\n------------------\n\nPython modules were not designed to change at run time. The source of a\nPython module normally doesn't change while a Python program is running.\nThere is a crude reload tool that allows modules to be manually reloaded to\nhandle source changes.\n\nPython modules contain mutable state. A module has a dictionary that may be\nmutated by application code. It may contain mutable data that is modified at\nrun time. This is typeically used to implement global registries.\n\nWhen a module is reloaded, it is reexecuted with a dictionary that includes\nthe results of the previous execution.\n\nPrograms using the ZODB may be said to have logical lifetimes that exceed the\nlifetimes of individual processes. In addition, the program might exist as\nmultiple individual processes with overlapping run-times.\n\nThe lifetime of a persistent program is long enough that it is likely that\nmodule source code will change during the life time of the program.\n\nIssues\n------\n\nShould the state of a module be represented soley by the module source?\n\nConsider the possibilities:\n\nA. Module state is represented soley by it's source.\n\n- This would be a departure from the behavior of standard Python modules.\n Standard Python modules retain a module dictionary that is not overwritten\n by reloads. Python modules may be mutated from outside and may contain\n mutable data structures that are modified at run time.\n\n OTOH, a regular module's state is not persistent or shared accross\n processes.\n\n For standard Python modules, one could view the module source as an\n expression of the initial state of the module. (This isn't quite right\n either, since some modules are written in such a way that they anticipate\n module reloads.)\n\n- Deleting variables from a module's source that have been imported by other\n modules or objects will cause the imported values to become disconnected\n from the module's source. Even if the variables are added back later, the\n previously-imported values will be disconnected.\n\n It is tempting to introduce a data structure to record imports make from a\n module. For example, suppose module M1 imports X from M2. It's tempting to\n record that fact in M2, so that we disallow M2 to be removed or to be\n changed in such a way that M2 no-longer defines X. Unfortunately, that\n would introduce state that isn't captured by my M2's source.\n\n- Persistent modules could only be used for software. You wouldn't be able to\n use them to store mutable data, such as registries or counters, that are\n updated outside of the execution of the module source.\n\nB. Module state isn't represented soley by it's source.\n\n - It would become possible to allow mutable data, such as registries in\n persistent modules.\n\n - It could be very difficult to see what a module's state is. If a module\n contained mutable data, you'd need some way to get to that data so you\n could inspect and manipulate it.\n\n - When a module is synchronized to the file system, you'd need to syncronize\n it's source and you'd also need to synchronize it's contents in some\n way. Synchronization of the contents could be done using an XML pickle, but\n management of the data using file-system-based tools would be cumbersome.\n\n You'd end up with data duplicated between the two representations. It\n would be cumbersome to manage the duplicated data in a consistent way.\n\nC. Module state is represented soley by it's source, but allow additional meta\n data.\n\n This is the same as option A, except we support meta-data management. The\n meta data could include dependency information. We'd keep track of external\n usage (import) of module variables to influence whether deletion of the\n module or defined variables is allowed, or whether to issue warnings when\n variables are deleted.\n\n Note that the management of the meta data need not be the responsibility of\n the module. This could be done via some application-defined facility, in\n which case, the module facility would need to provide an api for\n implimenting hooks for managing this information.\n\nSpecial cases\n-------------\n\nThis section contains examples that may introduce challenges for persistent\nmodules or that might motivate or highlight issues described above,\n\n- Persistent classes\n\n Persistent classes include data that are not represented by the class\n sources. A class caches slot definitions inherited from base classes. This\n is information that is only indirectly represented by it's source.\n Similarly, a class manages a collection of it's subclasses. This allows a\n class to invalidate cached slots in subclasses when a new slot definition is\n assigned (via a setattr). The cached slots and collection of subclasses is\n not part of a persistent class' state. It isn't saved in the database, but\n is recomputed when the class is loaded into memory or when it's subclasses\n are loaded into memory.\n\n Consider two persistent modules, M1, which defines class C1, and M2, which\n defines class C2. C2 subclasses C1. C1 defines a __getitem__ slot, which\n is inherited and cached by C2.\n\n Suppose we have a process, P1, which has M1 and M2 in memory. C2 in P1 has\n a (cached) __getitem__ slot filled with the definition inherited from C1 in\n P1. C1 in P1 has C2 in it's collection of subclasses. In P1, we modify M1,\n by editing and recompiling its source. When we recompile M1's source, we'll\n update the state of C1 by calling it's __setstate__ method, passing the new\n class dictionary. The __setstate__ method will, in turn, use setattr to\n assign the values from the new dictionary. If we set a slot attribute, the\n __setattribute__ method in C1 will notify each of it's subclasses that the\n slot has changed. Now, suppose that we've added a __len__ slot definition\n when we modified the source. When we set the __len__ attribute in C1, C2\n will be notified that there is a new slot definition for __len__.\n\n Suppose we have a process P2, which also has M1 and M2 loaded into memory.\n As in P1, C2 in P2 caches the __getitem__ slot and C1 in P2 has C2 in P2 in\n it's collection of subclasses. Now, when M1 in P1 is modified and the\n corresponding transaction is committed, an invalidation for M1 and all of\n the persistent objects it defines, including C1, is sent to all other\n processes. When P2 gets the invalidation for C1, it invalidates C1. It\n happens that persistent classes are not allowed to be ghosts. When a\n persistent class is invalidated, it immediately reloads it's state, rather\n than converting itself into a ghost. When C2's state is reloaded in P2, we\n assign it's attributes from the new class dictionary. When we assign slots,\n we notify it's subclasses, including C2 in P2.\n\n Suppose we have a process P3, that only has M1 in memory. In P3, M2 is not\n in memory, nor are any of it's subobjects. In P3, C2 is not in the\n collection of subclasses of C1, because C2 is not in memory and the\n collection of subclasses is volatile data for C1. When we modify C1 in P1\n and commit the transaction, the state of C1 in P3 will be updated, but the\n state of C2 is not affected in P3, because it's not in memory.\n\n Finally, consider a process, P4 that has M2, but not M1 in memory. M2 is\n not a ghost, so C2 is in memory. Now, since C2 is in memory, C1 must be in\n memory, even though M1 is not in memory, because C2 has a reference to C1.\n Further, C1 cannot be a ghost, because persistent classes are not allowed to\n be ghosts. When we commit the transation in P1 that updates M1, an\n invalidation for C1 is sent to P4 and C1 is updated. When C1 is updated,\n it's subclasses (in P4), including C2 are notified, so that their cached\n slot definitions are updated.\n\n When we modify M1, all copies in memory of C1 and C2 are updated properly,\n even though the data they cache is not cached persistently. This works, and\n only works, because persistent classes are never ghosts. If a class could\n be a ghost, then invalidating it would have not effect and non-ghost\n dependent classes would not be updated.\n\n- Persistent interfaces\n\n Like classes, Zope interfaces cache certain information. An interface\n maintains a set of all of the interfaces that it extends. In addition,\n interfaces maintain a collection of all of their sub-interfaces. The\n collection of subinterfaces is used to notify sub=interfaces when an\n interface changes.\n\n (Interfaces are a special case of a more general class of objects, called\n \"specifications\", that include both interfaces and interface declareations.\n Similar caching is performed for other specifications and related data\n structures. To simplify the discussion, however, we'll limit ourselves to\n interfaces.)\n\n When designing persistent interfaces, we have alternative approaches to\n consider:\n\n A. We could take the same approach as that taken with persistent classes.\n We would not save cached data persistently. We would compute it as\n objects are moved into memory.\n\n To take this approach, we'd need to also make persistent interfaces\n non-ghostifiable. This is necessary to properly propigate object\n changes.\n\n One could argue that non-ghostifiability if classes is a necessary wart\n forced on us by details of Python classes that are beyond our control,\n and that we should avoid creating new kinds of objects that require\n non-ghostifiability.\n\n B. We could store the cached data persistently. For example, we could store\n the set of extended interfaces and the set of subinterfaces in persistent\n dictionaries.\n\n A significant disadvantage of this approach is that persistent interfaces\n would accumulate state is that not refelcted in their source code,\n however, it's worth noting that, while the dependency and cache data\n cannot be derived from a single module source, it *can* be derived from\n the sources of all of the modules in the system. We can implement\n persistent interface in such a way that execution of module code causes\n all dependcies among module-defined interfaces to be recomputed\n correctly.\n\n (This is, to me, Jim, an interesting case: state that can be computed\n during deserialization from other serialized state. This should not be\n surprising, as we are essentially talking about cached data used for\n optimization purposes.)\n\nProposals\n---------\n\n- A module's state must be reprersented, directly or indirectly, by it's\n source. The state may also include information, such as caching data, that\n is derivable from it's source-represented state.\n\n It is unclear if or how we will enforce this. Perhaps it will be just a\n guideline. The module-synchronization adapters used in Zope will only\n synchronize the module source. If a module defines state that is not\n represented by or derivable from it's source, then that data will be lost in\n synchronization. Of course, applications that don't use the synchronization\n framework would be unaffected by this limitation. Alternatively, one could\n develop custom module-synchronization adapters that handled extra module\n data, however, development of such adapters will be outside the scope of the\n Zope project.\n\nNotes\n-----\n\n- When we invalidate a persistent class, we need to delete all of the\n attributes defined by it's old dictionary that are not defined by the new\n class dictionary.\n\n\n\n=======\nCHANGES\n=======\n\n3.4.0 (2007-10-10)\n------------------\n\n- No changes since beta 2, but verified test success within the stable set.\n\n\n3.4.0b2 (2007-10-10)\n--------------------\n\n- Adjust code to work with latest version of ZODB (3.8).\n\n- Converted ``module.txt`` to REST from STX.\n\n- Improved package meta-data.\n\n\n3.4.0b1 (2007-??-10)\n--------------------\n\n- Initial release independent of the main Zope tree.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://cheeseshop.python.org/pypi/zodbcode", "keywords": "zodb persistent code", "license": "ZPL 2.1", "maintainer": null, "maintainer_email": null, "name": "zodbcode", "package_url": "https://pypi.org/project/zodbcode/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/zodbcode/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://cheeseshop.python.org/pypi/zodbcode" }, "release_url": "https://pypi.org/project/zodbcode/3.4.0/", "requires_dist": null, "requires_python": null, "summary": "Allows Python code to live in the ZODB", "version": "3.4.0" }, "last_serial": 802313, "releases": { "0.1dev": [ { "comment_text": "", "digests": { "md5": "6ce6044c479eef2b1ae440894091e0aa", "sha256": "dfe015c87c59daae0528aa8a8545d021d7d5a5da2ff93f7115bd9328325dc55c" }, "downloads": -1, "filename": "zodbcode-0.1dev-py2.4.egg", "has_sig": false, "md5_digest": "6ce6044c479eef2b1ae440894091e0aa", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 62236, "upload_time": "2007-03-21T07:28:16", "url": "https://files.pythonhosted.org/packages/b3/29/b094a6989429c4d9ede907a8d4ece9fe5e2aae2ab14138cd7da69cdfc7d6/zodbcode-0.1dev-py2.4.egg" } ], "3.4.0": [ { "comment_text": "", "digests": { "md5": "9b128f89aa2a2117fae4f74757eefeff", "sha256": "e0fbdb36c6218b7b0fd190e83f3dd1dfdac1bc70d292b393c15895d43adf4402" }, "downloads": -1, "filename": "zodbcode-3.4.0.tar.gz", "has_sig": false, "md5_digest": "9b128f89aa2a2117fae4f74757eefeff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30854, "upload_time": "2007-10-10T16:35:30", "url": "https://files.pythonhosted.org/packages/35/59/e80edc1709cad826f005cb560394a4d74d08bb3f527a55d52f9887f4f3ee/zodbcode-3.4.0.tar.gz" } ], "3.4.0b1dev-r75670": [ { "comment_text": "", "digests": { "md5": "92093abe9f50d54a1a8b6f5334c868f0", "sha256": "bafa8149f697ba69609aabbcf5ed63f3a37158a5904ab6408eb4a82423ece7d8" }, "downloads": -1, "filename": "zodbcode-3.4.0b1dev-r75670.tar.gz", "has_sig": false, "md5_digest": "92093abe9f50d54a1a8b6f5334c868f0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25734, "upload_time": "2007-05-10T13:16:32", "url": "https://files.pythonhosted.org/packages/35/7f/c8b716cda8ebc3a1c75310b0640b02bbfebfb61535619ea3f69c6672319a/zodbcode-3.4.0b1dev-r75670.tar.gz" } ], "3.4.0b2": [ { "comment_text": "", "digests": { "md5": "7af5ab901133055b7ba3b1a065aa1de6", "sha256": "1967fa0cb9deea0cc839b4821f007ea344853364e8ee1771ddb64b6b215a7626" }, "downloads": -1, "filename": "zodbcode-3.4.0b2.tar.gz", "has_sig": false, "md5_digest": "7af5ab901133055b7ba3b1a065aa1de6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30803, "upload_time": "2007-10-10T16:31:45", "url": "https://files.pythonhosted.org/packages/38/b6/89742bd0151aa40636583549507b94436a95ef741c72caa4028b101f504e/zodbcode-3.4.0b2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9b128f89aa2a2117fae4f74757eefeff", "sha256": "e0fbdb36c6218b7b0fd190e83f3dd1dfdac1bc70d292b393c15895d43adf4402" }, "downloads": -1, "filename": "zodbcode-3.4.0.tar.gz", "has_sig": false, "md5_digest": "9b128f89aa2a2117fae4f74757eefeff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30854, "upload_time": "2007-10-10T16:35:30", "url": "https://files.pythonhosted.org/packages/35/59/e80edc1709cad826f005cb560394a4d74d08bb3f527a55d52f9887f4f3ee/zodbcode-3.4.0.tar.gz" } ] }