Dear developers, many internals have changed in SMW recently, and quite a few changes are still to come. Yet, most of the restructuring is done, so I can give a first explanation of the news in SMW 1.6. I still need to find time to write a more detailed guide, but the main changes are as follows:
* Data is now stored in objects of type SMWDataItem. A data item is a small immutable data container that holds a property value. * There is a fixed, predefined set of basic data item classes (e.g. SMWDINumber or SMWDIWikiPage). * The old SMWDataValue classes are just wrappers around a data item. For example, SMWStringValue has a member of type SMWDIString that is used to store the actual data. The DV classes remain in SMW but are only used to parse user inputs and to format outputs. * All places where we only handle data (SMWSemanticData, the store, query results, etc.) are using data items. DVs are only created on demand when they are needed for some input or output. * The architecture allows extensions to add new DVs but not new data items. A DV class can decide how to process user input, and how to display data to users, but it cannot introduce new *forms* of data (as this is what data items are). So every DV has to pick one existing data item that is suitable for storing its data in. * There will be a data item for compound data (basically a container that can hold tree-like semantic data, like in a Factbox). This should be flexible enough to capture complex data structures. But most DVs should work just as well by storing their data as a string, blob, number, etc. It does not mean that the user will ever see the data in its raw (e.g. string) form. * Old functions like getDBkeys and setDBkeys will vanish. For some time, the class SMWCompatibilityHelpers will provide static substitute methods for getting the same data. * The registration functions for custom properties and DVs have changed slightly. Properties are now registered with helper methods in SMWDIProperty, not in SMWProeprtyValue as before. DVs are still registered in SMWDatavalueFactory but they additionally need to tell which type of data item they are based on. The main change for SMW extension developers is to revisit all uses of datavalues and decide whether to replace them by data items, or whether to convert between datavalues and data items as appropriate (it is possible to create a datavalue for every data item by calling SMWDataValuefactory::newDataItemValue(), and to get a data item from a datavalue by calling getDataItem(); so you can easily switch between the views as needed; but the idea really is to use the clean and clear data items in favour of DVs whenever possible). Many type checks have been added to PHP to throw errors as early as possible to avoid problems going unnoticed. Consider installing xdebug for more useful backtraces with PHP errors and exceptions. With this, it is often quite easy to identify and update incompatible code. Result formats in queries may not need any change in most cases. However, instead of the method getNextObject() they should call getNextdataValue() (or, if more suitable, getNextdataItem()). Developers who have own DV classes must change them to use their member m_dataitem for storing data (they can decide which class to use). They might also need to implement setDataItem() to do necessary initialisations when given a new data item. The registration of DV classes works as before, but the registration function now additionally needs the key of a data item that the DV is built on (each dataitem is identified in SMW by a numeric constant, see SMWDataItem for the list). While the change is some work (it was even more work in SMW itself), it provides a much cleaner and more manageable data model. Code that processes data (not user input or output) now only has to handle a fixed set of possible data types given by the data item classes, instead of implementing generic handling methods for an array of "DBkeys". DBkeys will vanish as the main format of data description in SMW. Let me know if there are any problems with the transition -- I can still change things before SMW 1.6. Cheers, Markus ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel