2011-05-09 39 views
1

我正在開發一個新版本的collective.imagetags,其中瀏覽器視圖(imagetags-manage)攜帶的所有功能現在都移動到一個新的適配器(尚未提交),它幾乎提供了同樣的界面,瀏覽器視圖::爲zope組件提供向後兼容

class IManageTags(Interface): 
    """ 
    imagetags-manage view interface 
    Tag management browser view 
    """ 

    def get_tag(id, create_on_fail=True): 
     """ Gets/creates a specific tag """ 

    def get_tags(): 
     """ Gets all the tags for the object """ 

    def get_sorted_tags(): 
     """ Sorted list of tags 
     """ 

    def save_tag(data): 
     """ Saves a tag with the passed data """ 

我真的不知道,如果有人在一個項目中使用這款產品,但是,我認爲這將是一個明智的想法提供一些向後兼容機制,如果任何人在開箱即用功能之外使用瀏覽器視圖方法。

我該怎麼辦? 使用在新適配器上進行中繼的存根方法保留瀏覽器視圖的接口? 有什麼建議嗎?

+0

這問題可能更適合產品開發人員列表:http://plone.org/support/forums/addons。 – aclark 2011-05-09 17:14:32

+0

@aclark,如果你認爲我應該關閉這個問題,請讓我知道並關閉它。 – marcosfromero 2011-05-09 17:48:16

+0

正如@aclark所建議的,在不同的論壇中遵循此主題(http://plone.293351.n2.nabble.com/Providing-backward-compatibility-for-a-zope-component-td6345399.html)。編者:請關閉這個問題。不刪除它以保留歷史記錄並跟進。 – marcosfromero 2011-05-11 18:55:47

回答

1

這種變化很難!這不是API的問題,而是設計問題。

  • 瀏覽器視圖是您將使用/請求與上下文混合使用的組件。
  • 適配器是您不關心用戶或其請求的組件。
  • 實用程序是您不關心上下文的組件。

所以你應該保持你的瀏覽器視圖,並使其使用適配器,它應該足以保持兼容性。

當您更改默認配置文件時會使用升級。首先metadata.xml中的版本必須是整數(1000經常被用來作爲第一個穩定版本)接下來,每次更改配置文件應遵循此版本號的增加,你必須添加一個升級步驟:

<gs:upgradeStep 
    title="Upgrade collective.myaddon from 1000 to 1010" 
    description="" 
    source="1000" 
    destination="1010" 
    handler=".upgrades.upgrade_1000_1010" 
    profile="collective.myaddon:default"/> 


upgrades.py 
def upgrade_1000_1010(context): 
    """documentation 
    """ 
    context.runImportStepFromProfile(default_profile, 'viewlets') 
    portal_javascripts = getToolByName(context, 'portal_javascripts') 
    portal_javascripts.cookResources()