Python 高级库和API设计

Python 高级库和API设计,python,api,cmis,Python,Api,Cmis,我正在开发一个库,它使用CMIS兼容的存储作为后端(在我的例子中是Alfresco)。我非常想创建一个类似于Alchemy和Django的“性感”API。问题是我对Python中的这种高级编程还不熟悉。以下是使用此库的想象方式: # Here is the connector that does the actual request to the CMIS server c = CMISConnector('url', 'username', 'password') # Here I decl

我正在开发一个库,它使用CMIS兼容的存储作为后端(在我的例子中是Alfresco)。我非常想创建一个类似于Alchemy和Django的“性感”API。问题是我对Python中的这种高级编程还不熟悉。以下是使用此库的想象方式:

# Here is the connector that does the actual request to the CMIS server
c = CMISConnector('url', 'username', 'password')

# Here I declare the model with the desired property fields. A model
# can be either a folder or a document in Alfresco
class SomeModel(c.Model):
    name = c.Property('cmis:name')

# Some query and create examples...
foo = SomeModel.query.first(name='John Doe')
print foo.name
bar = SomeModel(name='Jane Doe')
bar.save()
因为整个对象模型将有一个后端,所以我希望从模型继承的每个类都使用相同的连接,而不必显式注册它

任何帮助都将不胜感激:)

您看了吗?它是用Python编写的CMIS客户端API。它允许您使用Alfresco(或任何其他符合CMIS的存储库)中的对象

API为您提供了“文档”和“文件夹”等对象。我认为您必须编写一些Django中间件来完成您正试图完成的模型工作,但至少cmislib可以避免您编写与Alfresco的交互代码

希望有帮助


Jeff

My library是cmislib的封装,允许使用类似于django数据库对象的模型。我使用cmislib来处理所有“幕后”工作:)