Adding yet more index maintenance
Clearly, the index maintenance aspect of a shelf can grow. With our simple data model, we could easily add more top-level indexes for tags, dates, and titles of Posts
. Here's another access layer implementation that defines two indices for Blogs
. One index simply lists the keys for Blog
entries. The other index provides keys based on the Blog
title. We'll assume the titles are not unique. We'll present this access layer in three parts. Here's the Create part of the CRUD processing:
class Access4( Access2 ):
def new( self, *args, **kw ):
super().new( *args, **kw )
self.database['_DB:Blog']= list()
self.database['_DB:Blog_Title']= defaultdict(list)
def add_blog( self, blog ):
self.max['Blog'] += 1
key= "Blog:{id}".format(id=self.max['Blog'])
blog._id= key
blog._post_list= []
self.database[blog._id]= blog
self.database['_DB:Blog'].append( blog._id )
blog_title= self.database...