跳转到主要内容

通用的Python ActivityPub库

项目描述

这是一个与
ActivityPub一起使用的Python库。
ActivityPub是一个用于开放、分布式社交网络的API。

安装

您可以使用以下命令安装activitypub的开发版本

pip install git+git://github.com/dsblank/activitypub

或使用以下命令安装最后打包的版本

pip install activitypub

要与redis一起使用

pip install redis redis_collections

或要与mongodb一起使用

pip install pymongo

或要与SQLAlchemy一起使用

pip install sqlalchemy

抽象

此模块旨在成为Python中通用的ActivityPub库。它针对三个不同级别的使用

  • ActivityPub对象API

  • ActivityPub数据库API

  • Web服务器API

这些级别可以单独使用,也可以一起使用。最好通过Manager一起使用它们

>>> from activitypub.manager import Manager
>>> from activitypub.database import ListDatabase
>>> db = ListDatabase()
>>> manager = Manager(database=db)
>>> p = manager.Person(id="alyssa")
>>> p.to_dict()
{'@context': 'https://www.w3.org/ns/activitystreams',
 'endpoints': {},
 'followers': 'https://example.com/alyssa/followers',
 'following': 'https://example.com/alyssa/following',
 'id': 'https://example.com/alyssa',
 'inbox': 'https://example.com/alyssa/inbox',
 'liked': 'https://example.com/alyssa/liked',
 'likes': 'https://example.com/alyssa/likes',
 'outbox': 'https://example.com/alyssa/outbox',
 'type': 'Person',
 'url': 'https://example.com/alyssa'}
>>> db.actors.insert_one(p.to_dict())
>>> db.actors.find_one({"id": 'https://example.com/alyssa'})
{'@context': 'https://www.w3.org/ns/activitystreams',
 'endpoints': {},
 'followers': 'https://example.com/alyssa/followers',
 'following': 'https://example.com/alyssa/following',
 'id': 'https://example.com/alyssa',
 'inbox': 'https://example.com/alyssa/inbox',
 'liked': 'https://example.com/alyssa/liked',
 'likes': 'https://example.com/alyssa/likes',
 'outbox': 'https://example.com/alyssa/outbox',
 'type': 'Person',
 'url': 'https://example.com/alyssa',
 '_id': ObjectId('5b579aee1342a3230c18fbf7')}

activitypub支持以下数据库

  • MongoDB

  • SQL方言 - 包括任何SQLAlchemy支持的方言

  • SQLite(包括内存中的SQLite)

  • Firebird

  • Microsoft SQL Server

  • MySQL

  • Oracle

  • PostgreSQL

  • Sybase

  • …等等!

  • 一个基于JSON的内存数据库,用于测试

  • Redis

activitypub数据库API是MongoDB的一个子集。

activitypub针对以下Web框架

  • Flask

  • Tornado

其他框架也可以支持。请提问!

activitypub Web服务API基于Flask的。

项目详情


下载文件

下载适用于您平台文件的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

activitypub-0.0.3.tar.gz (32.0 kB 查看散列值)

上传时间 源代码

构建分发

activitypub-0.0.3-py2.py3-none-any.whl (42.5 kB 查看散列值)

上传时间 Python 2 Python 3

支持者