高级库和API设计

2024-06-25 06:27:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在开发一个使用CMIS兼容存储作为后端的库(在我的例子中是Alfresco)。我非常想创建一个“性感”的API,类似于Flask SQLAlchemy和Django。问题是我对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()

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

如有任何帮助,我们将不胜感激:)


Tags: thename模型apimodelherefoobar
1条回答
网友
1楼 · 发布于 2024-06-25 06:27:57

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

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

希望有帮助

杰夫

相关问题 更多 >