高级库和API设计

时间:2011-05-02 16:02:57

标签: python api cmis

我正在开发一个使用CMIS兼容存储作为后端的库(在我的案例中是Alfresco)。我非常想创建一个类似于Flask-SQLAlchemy和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()

由于整个对象模型将有一个后端,我希望从Model继承的每个类都使用相同的连接,而不必显式注册它。

非常感谢任何帮助:)

1 个答案:

答案 0 :(得分:2)

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

API为您提供“文档”和“文件夹”等对象。我认为你必须编写一些Django中间件来做你想要做的模型,但至少cmislib会让你免于编写与Alfresco的交互编码。

希望有所帮助,

杰夫