Fom

Merge lp:~ntoll/fom/instance-pre-populate-search-812246 into lp:fom

Proposed by Nicholas Tollervey
Status: Merged
Merge reported by: Nicholas Tollervey
Merged at revision: not available
Proposed branch: lp:~ntoll/fom/instance-pre-populate-search-812246
Merge into: lp:fom
Diff against target: 0 lines
To merge this branch: bzr merge lp:~ntoll/fom/instance-pre-populate-search-812246
Reviewer Review Type Date Requested Status
Jamu Kakar Approve
Review via email: mp+68252@code.launchpad.net

Description of the change

This branch introduces the following changes:

1) When calling the filter() method on subclasses of Object FOM will use the /values API to attempt to pre-populate the attribute values. This ensures that the results are instantiated *with* initial values and no more lazy-getting of attributes is required (thus saving time and calls to Fluidinfo).

2) Changes in the unit tests to reflect this new functionality.

This change was made in light of behaviour observed whilst writing the O'Reilly book.

To post a comment you must log in.
151. By Nicholas Tollervey

Whitespace clean

Revision history for this message
Jamu Kakar (jkakar) wrote :

[1]

         self.db.add_resp(200, 'application/json',
- '{"ids": ["466"]}')
+ '''{"results":{"id": {"05eee31e-fbd1-43cc-9500-0469707a9bc3":{
+ "fluiddb/users/username":{"value": "ntoll"},
+ "fluiddb/users/name":{"value": "Nicholas"},
+ "fluiddb/about": {"value": "Object about the user ntoll"}}}}}''')

There are a few bits of code like this. I think they'd be easier to
read if the data was split up a bit and used the json module:

         objectValues = {
             'fluiddb/users/username': {'value': 'ntoll'},
             'fluiddb/users/name': {'value': 'Nicholas'},
             'fluiddb/about': {'value': 'Object about the user ntoll'}}
         resultValues = {'05eee31e-fbd1-43cc-9500-0469707a9bc3': objectData}
         self.db.add_resp(200, 'application/json',
                          dumps({'results': {'id': resultValues}}))

Nice work, +1!

review: Approve
Revision history for this message
Jamu Kakar (jkakar) wrote :

Er, s/objectData/objectValues/ in the example above.

152. By Nicholas Tollervey

Updated the unit tests to make the expected response slightly more clear

Preview Diff

Empty

Subscribers

People subscribed via source and target branches

to all changes: