I'm trying to setup a basic feed:
from stream_framework.feeds.redis import RedisFeed
class PinFeed(RedisFeed):
key_format = 'feed:normal:%(user_id)s'
class UserPinFeed(PinFeed):
key_format = 'feed:user:%(user_id)s'
feed = UserPinFeed(13)
But when I run feed[:2] after adding a single activity, I keep getting this error:
<ipython-input-25-41b7cd0d0d8c> in <module>()
----> 1 feed[:2]
/Users/home/venv/lib/python2.7/site-packages/stream_framework/feeds/base.pyc in __getitem__(self, k)
303 try:
304 results = self.get_activity_slice(
--> 305 start, bound)
306 except StopIteration:
307 # There's nothing left, even though the bound is higher.
/Users/home/venv/lib/python2.7/site-packages/stream_framework/feeds/base.pyc in get_activity_slice(self, start, stop, rehydrate)
354 print 'line 350'
355 if self.needs_hydration(activities) and rehydrate:
--> 356 activities = self.hydrate_activities(activities)
357 return activities
358
/Users/home/venv/lib/python2.7/site-packages/stream_framework/feeds/base.pyc in hydrate_activities(self, activities)
332 activity_data = {a.serialization_id: a for a in activity_list}
333 print activity_data
--> 334 return [activity.get_hydrated(activity_data) for activity in activities]
335
336 def needs_hydration(self, activities):
/Users/home/venv/lib/python2.7/site-packages/stream_framework/activity.pyc in get_hydrated(self, activities)
42
43 '''
---> 44 activity = activities[int(self.serialization_id)]
45 activity.dehydrated = False
46 return activity
KeyError: 14929294667170000000001005L
I'm able to print out [<stream_framework.activity.DehydratedActivity object at 0x10e114e90>] and [u'14929294667170000000001005'].
Any clue what could be causing this?
There is a mismatch of types here, between the Key being shown in the
KeyErrorstack trace and the printed representation of[u'14929294667170000000001005']u'14929294667170000000001005'is a unicode string while14929294667170000000001005Lis alongtype integer.Either the Key itself or the value you are attempting to use as the lookup key will have to change so the types are identical. Note that an int with or without the L suffix (signifying the
longtype) will work to retrieve a value from a pythondict. A simple demonstration: