kopia lustrzana https://gitlab.com/marnanel/chapeau
Object.get_by_url() added.
getitem['foo__obj'] now calls Object.get_by_url(). The old behaviour of calling find() is available at 'foo__find'. Follow activities no longer use explicit object fields.trilby
rodzic
29165f0b17
commit
bb21eb5785
|
@ -17,7 +17,7 @@ class Activity(thing.Object):
|
|||
if not self.is_local:
|
||||
return
|
||||
|
||||
actor = self['actor__obj']
|
||||
actor = self['actor__find']
|
||||
|
||||
logger.info('%s: going into %s\'s outbox',
|
||||
self.number,
|
||||
|
@ -59,7 +59,7 @@ class Delete(Activity):
|
|||
pass
|
||||
|
||||
class Follow(Activity):
|
||||
_explicit_object_field = True
|
||||
pass
|
||||
|
||||
class Add(Activity):
|
||||
pass
|
||||
|
|
|
@ -200,9 +200,11 @@ class Object(PolymorphicModel):
|
|||
except ThingField.DoesNotExist:
|
||||
result = None
|
||||
|
||||
if 'obj' in name_parts and result is not None:
|
||||
if 'find' in name_parts and result is not None:
|
||||
result = find(result,
|
||||
do_not_fetch=True)
|
||||
elif 'obj' in name_parts and result is not None:
|
||||
result = Object.get_by_url(url=result)
|
||||
|
||||
return result
|
||||
|
||||
|
@ -323,6 +325,32 @@ class Object(PolymorphicModel):
|
|||
self.number = _new_number()
|
||||
return self.save(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def get_by_url(cls, url):
|
||||
"""
|
||||
Retrieves an Object whose URL is "url".
|
||||
|
||||
This differs from find() in that it can
|
||||
find objects which were submitted to us over HTTP
|
||||
(as opposed to generated locally or fetched by us).
|
||||
find() would ignore these.
|
||||
"""
|
||||
|
||||
from django_kepi.find import find
|
||||
|
||||
result = find(url,
|
||||
local_only = True)
|
||||
|
||||
if result is None:
|
||||
try:
|
||||
result = cls.objects.get(
|
||||
remote_url = url,
|
||||
)
|
||||
except cls.DoesNotExist:
|
||||
result = None
|
||||
|
||||
return result
|
||||
|
||||
######################################
|
||||
|
||||
def _normalise_type_for_thing(v):
|
||||
|
|
Ładowanie…
Reference in New Issue