kopia lustrzana https://github.com/dsblank/activitypub
Set defaults to http/5000 for testing
rodzic
a7677a27ee
commit
ae700d67a4
|
@ -156,7 +156,7 @@ class ObjectId(object):
|
||||||
>>> later = ObjectId.from_datetime(gen_time)
|
>>> later = ObjectId.from_datetime(gen_time)
|
||||||
>>> result = m.database.activities.find({"_id": {"$lt": later}})
|
>>> result = m.database.activities.find({"_id": {"$lt": later}})
|
||||||
>>> result # doctest: +ELLIPSIS
|
>>> result # doctest: +ELLIPSIS
|
||||||
[{'@context': 'https://www.w3.org/ns/activitystreams', '_id': ObjectId('...'), 'attributedTo': 'alyssa', 'id': 'alyssa/note/$attributedTo/note/$id', 'type': 'Note'}]
|
[{'@context': 'https://www.w3.org/ns/activitystreams', '_id': ObjectId('...'), 'attributedTo': 'alyssa', 'type': 'Note'}]
|
||||||
|
|
||||||
:Parameters:
|
:Parameters:
|
||||||
- `generation_time`: :class:`~datetime.datetime` to be used
|
- `generation_time`: :class:`~datetime.datetime` to be used
|
||||||
|
|
|
@ -104,7 +104,7 @@ class Manager():
|
||||||
|
|
||||||
>>> note = manager.Note(
|
>>> note = manager.Note(
|
||||||
... **{'sensitive': False,
|
... **{'sensitive': False,
|
||||||
... 'attributedTo': 'http://localhost:5005',
|
... 'attributedTo': 'http://localhost:5000',
|
||||||
... 'cc': ['http://localhost:5005/followers'],
|
... 'cc': ['http://localhost:5005/followers'],
|
||||||
... 'to': ['https://www.w3.org/ns/activitystreams#Public'],
|
... 'to': ['https://www.w3.org/ns/activitystreams#Public'],
|
||||||
... 'content': '<p>$source.content</p>',
|
... 'content': '<p>$source.content</p>',
|
||||||
|
@ -141,10 +141,11 @@ class Manager():
|
||||||
## Put dependent ones first:
|
## Put dependent ones first:
|
||||||
self.defaults = {
|
self.defaults = {
|
||||||
"$DOMAIN": "$SCHEME://$HOST:$PORT",
|
"$DOMAIN": "$SCHEME://$HOST:$PORT",
|
||||||
"$SCHEME": "https",
|
"$SCHEME": "http",
|
||||||
"$HOST": self.host,
|
"$HOST": self.host,
|
||||||
"$PORT": self.port,
|
"$PORT": self.port,
|
||||||
"$UUID": lambda: str(uuid.uuid4()),
|
"$UUID4": lambda: str(uuid.uuid4()),
|
||||||
|
"$UUID": lambda: binascii.hexlify(os.urandom(8)).decode("utf-8"),
|
||||||
"$NOW": lambda: (datetime.datetime.utcnow()
|
"$NOW": lambda: (datetime.datetime.utcnow()
|
||||||
.replace(microsecond=0).isoformat() + "Z"),
|
.replace(microsecond=0).isoformat() + "Z"),
|
||||||
}
|
}
|
||||||
|
@ -236,7 +237,7 @@ class Manager():
|
||||||
>>> m = Manager()
|
>>> m = Manager()
|
||||||
>>> n = m.Note(attributedTo="alyssa", id="23")
|
>>> n = m.Note(attributedTo="alyssa", id="23")
|
||||||
>>> n.to_dict()
|
>>> n.to_dict()
|
||||||
{'@context': 'https://www.w3.org/ns/activitystreams', 'attributedTo': 'alyssa', 'id': 'alyssa/note/23', 'type': 'Note'}
|
{'@context': 'https://www.w3.org/ns/activitystreams', 'attributedTo': 'alyssa', 'id': '23', 'type': 'Note'}
|
||||||
|
|
||||||
A default can be a $-variable, or the name of a "Class.field_name".
|
A default can be a $-variable, or the name of a "Class.field_name".
|
||||||
"""
|
"""
|
||||||
|
@ -250,7 +251,6 @@ class Manager():
|
||||||
"Person.inbox": "$id/inbox",
|
"Person.inbox": "$id/inbox",
|
||||||
"Person.outbox": "$id/outbox",
|
"Person.outbox": "$id/outbox",
|
||||||
"Person.url": "$id",
|
"Person.url": "$id",
|
||||||
"Note.id": "$attributedTo/note/$id",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def user_agent(self):
|
def user_agent(self):
|
||||||
|
@ -292,6 +292,9 @@ class Manager():
|
||||||
val = self.get_item_from_dotted("ap_" + key[1:], obj)
|
val = self.get_item_from_dotted("ap_" + key[1:], obj)
|
||||||
else:
|
else:
|
||||||
raise Exception("expansion requires %s" % key[1:])
|
raise Exception("expansion requires %s" % key[1:])
|
||||||
|
if string == key:
|
||||||
|
string = val
|
||||||
|
else:
|
||||||
string = string.replace(key, str(val))
|
string = string.replace(key, str(val))
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
@ -300,7 +303,7 @@ class Manager():
|
||||||
|
|
||||||
>>> manager = Manager()
|
>>> manager = Manager()
|
||||||
>>> manager.Person(id="alyssa").to_dict()
|
>>> manager.Person(id="alyssa").to_dict()
|
||||||
{'@context': 'https://www.w3.org/ns/activitystreams', 'endpoints': {}, 'followers': 'https://localhost:5000/alyssa/followers', 'following': 'https://localhost:5000/alyssa/following', 'id': 'https://localhost:5000/alyssa', 'inbox': 'https://localhost:5000/alyssa/inbox', 'liked': 'https://localhost:5000/alyssa/liked', 'likes': 'https://localhost:5000/alyssa/likes', 'outbox': 'https://localhost:5000/alyssa/outbox', 'type': 'Person', 'url': 'https://localhost:5000/alyssa'}
|
{'@context': 'https://www.w3.org/ns/activitystreams', 'endpoints': {}, 'followers': 'http://localhost:5000/alyssa/followers', 'following': 'http://localhost:5000/alyssa/following', 'id': 'http://localhost:5000/alyssa', 'inbox': 'http://localhost:5000/alyssa/inbox', 'liked': 'http://localhost:5000/alyssa/liked', 'likes': 'http://localhost:5000/alyssa/likes', 'outbox': 'http://localhost:5000/alyssa/outbox', 'type': 'Person', 'url': 'http://localhost:5000/alyssa'}
|
||||||
"""
|
"""
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
# Find all items that don't depend on anything:
|
# Find all items that don't depend on anything:
|
||||||
|
|
Ładowanie…
Reference in New Issue