def from_dict(cls, dt): item = cls() item.title = dt.get('title',None) item.content = dt.get('content',None) item.article_id = dt.get('parent',None) item.updated = item.published = rfc3339.now().replace(tzinfo=None) return item
def update_from_dict(self, dt): #self.atom_id = dt.get('atom_id',None) self.title = dt.get('title',None) self.content = dt.get('content',None) self.tags.clear() for label in dt.get('tags',[]): tag = Tag.get_from_id(slugify(label)) or Tag(label=label) self.tags.add(tag) self.updated = rfc3339.now().replace(tzinfo=None)
def quick(cls, dt): item = cls() item.title = dt['upload'].filename item.content = dt.get('content',u'') item.updated = item.published = rfc3339.now().replace(tzinfo=None) item._upload_file(dt) #upload_url = url_gen('story',permalink=item.permalink) #item.atom_id = get_tag_uri(upload_url,item.published,basename) return item
def from_dict(cls, dt): item = cls() item.id = dt.get('id',None) #item.atom_id = dt.get('atom_id',None) item.title = dt.get('title',None) item.content = dt.get('content',None) for label in dt.get('tags',[]): tag = Tag.get_from_id(slugify(label)) or Tag(label=label) item.tags.add(tag) item.updated = item.published = rfc3339.now().replace(tzinfo=None) basename = item._upload_file(dt) item.title = basename if item.title is None else item.title #upload_url = url_gen('story',permalink=item.permalink) #item.atom_id = get_tag_uri(upload_url,item.published,basename) return item
def update_from_dict(self, dt, default_thumb=None): self.title = dt.get('title',None) self.published = dt.get('published',None) self.content = dt.get('content',None) self.sticky = dt.get('sticky',None) self.can_comment = dt.get('can_comment',None) self.page_id = dt.get('page_id',None) self.metacontent = html.striphtml(self.content) self.summary = html.stripobjects(self.content) media_data = html.get_metamedia_data(self.content, default_thumb) self.links = media_data.get('link',{}) self.metatags = media_data.get('meta',{}) self.tags.clear() for label in dt.get('tags',[]): tag = Tag.get_from_id(slugify(label)) or Tag(label=label) self.tags.add(tag) self.updated = rfc3339.now().replace(tzinfo=None)
def from_dict(cls, dt, default_thumb=None): item = cls() item.title = dt.get('title',None) item.published = dt.get('published',None) item.content = dt.get('content',None) item.sticky = dt.get('sticky',None) item.can_comment = dt.get('can_comment',None) item.page_id = dt.get('page_id',None) item.contributors = [] item.metacontent = html.striphtml(item.content) item.summary = html.stripobjects(item.content) media_data = html.get_metamedia_data(item.content, default_thumb) item.links = media_data.get('link',{}) item.metatags = media_data.get('meta',{}) for label in dt.get('tags',[]): tag = Tag.get_from_id(slugify(label)) or Tag(label=label) item.tags.add(tag) item.updated = rfc3339.now().replace(tzinfo=None) if item.created is None: item.created = item.updated return item
def update_from_dict(self, dt): self.title = dt.get('title',None) or self.title self.content = dt.get('content',None) or self.content self.updated = rfc3339.now().replace(tzinfo=None)
def test_now(self): res = rfc3339.now() self.assertEquals(res.tzinfo,rfc3339.UTC)