Example #1
0
 def get(self, component, contentID, **kwargs):
     u"""
     This get method is the core routine to make the adapter produce content. 
     There are two levels of dispatching matches: search for an adapter method that matches 
     the contentID and if that cannot be found the method that matches the component class name.
     contentID of "featuredArticles" will search for adapter method "getFeaturedArticles"
     component class "MainContent" will search for adapter method "getMainContent".
     All adapter method need to answer a Data instance, where the requested data is embedded.
     """
     data = hook1 = hook2 = None
     if contentID is not None:
         hook1 = TX.asGetMethodName(contentID)
         if hasattr(self, hook1):
             data = getattr(self, hook1)(component, **kwargs)
     if data is None:
         hook2 = TX.asGetMethodName(component.__class__.__name__)
         if hook1 != hook2 and hasattr(self, hook2):
             data = getattr(self, hook2)(component, **kwargs)
     if data is None:
         data = Data(
             error='[Component] Could not find adapter.%s() or adapter.%s()'
             % (hook1, hook2))
         print data.error
     return data
Example #2
0
 def get(self, contentID=None, **kwargs):
     u"""
     This get method is the core routine to make the adapter produce content.
     There is a dispatcher level to search for an adapter method that matches
     the contentID.
     All adapter method need to answer a Data instance, where the requested data is embedded
     as one of the attributes @(article.text, article.url, article.chapters)@.
     """
     article = hook = None
     if contentID is not None:
         hook = TX.asGetMethodName(contentID)
         if hasattr(self, hook):
             article = getattr(self, hook)(**kwargs)
     if article is None:
         message = '[%s] Could not find adapter.%s()' % (self, hook)
         article = self.newArticle(error=message, text=message)
         print article.error
     return article
Example #3
0
 def get(self, contentID=None, **kwargs):
     u"""
     This get method is the core routine to make the adapter produce content. 
     There is a dispatcher level to search for an adapter method that matches 
     the contentID.
     All adapter method need to answer a Data instance, where the requested data is embedded
     as one of the attributes <b>(data.text, data.url, data.items)</b>.
     """
     data = hook = None
     if contentID is not None:
         hook = TX.asGetMethodName(contentID)
         if hasattr(self, hook):
             data = getattr(self, hook)(**kwargs)
     if data is None:
         message = '[%s] Could not find adapter.%s()' % (self, hook)
         data = self.newData(error=message, text=message)
         print data.error
     return data