예제 #1
0
파일: publish.py 프로젝트: sheyril/bridgy
    def _get_or_add_publish_entity(self, source_url):
        page = PublishedPage.get_or_insert(source_url)

        # Detect concurrent publish request for the same page
        # https://github.com/snarfed/bridgy/issues/996
        pending = Publish.query(Publish.status == 'new',
                                Publish.type != 'preview',
                                Publish.source == self.source.key,
                                ancestor=page.key).get()
        if pending:
            logging.warning(
                f'Collided with publish: {pending.key.urlsafe().decode()}')
            raise CollisionError()

        entity = Publish.query(Publish.status == 'complete',
                               Publish.type != 'preview',
                               Publish.source == self.source.key,
                               ancestor=page.key).get()
        if entity is None:
            entity = Publish(parent=page.key, source=self.source.key)
            if self.PREVIEW:
                entity.type = 'preview'
            entity.put()

        logging.debug("Publish entity: '%s'", entity.key.urlsafe().decode())
        return entity
예제 #2
0
파일: publish.py 프로젝트: stedn/bridgy
    def _get_or_add_publish_entity(self, source_url):
        page = PublishedPage.get_or_insert(source_url)
        entity = Publish.query(Publish.status == 'complete',
                               Publish.type != 'preview',
                               Publish.source == self.source.key,
                               ancestor=page.key).get()

        if entity is None:
            entity = Publish(parent=page.key, source=self.source.key)
            if self.PREVIEW:
                entity.type = 'preview'
            entity.put()

        logging.debug("Publish entity: '%s'", entity.key.urlsafe().decode())
        return entity
예제 #3
0
    def get_or_add_publish_entity(self, source_url):
        """Creates and stores Publish and (if necessary) PublishedPage entities.

    Args:
      source_url: string
    """
        page = PublishedPage.get_or_insert(source_url)
        entity = Publish.query(Publish.status == 'complete',
                               Publish.type != 'preview',
                               Publish.source == self.source.key,
                               ancestor=page.key).get()

        if entity is None:
            entity = Publish(parent=page.key, source=self.source.key)
            if self.PREVIEW:
                entity.type = 'preview'
            entity.put()

        logging.debug('Publish entity: %s', entity.key.urlsafe())
        return entity
예제 #4
0
  def get_or_add_publish_entity(self, source_url):
    """Creates and stores Publish and (if necessary) PublishedPage entities.

    Args:
      source_url: string
    """
    page = PublishedPage.get_or_insert(source_url)
    entity = Publish.query(
      Publish.status == 'complete', Publish.type != 'preview',
      Publish.source == self.source.key,
      ancestor=page.key).get()

    if entity is None:
      entity = Publish(parent=page.key, source=self.source.key)
      if self.PREVIEW:
        entity.type = 'preview'
      entity.put()

    logging.debug('Publish entity: %s', entity.key.urlsafe())
    return entity
예제 #5
0
  def get_or_add_publish_entity(self, source_url):
    """Creates and stores :class:`models.Publish` entity.

    ...and if necessary, :class:`models.PublishedPage` entity.

    Args:
      source_url: string
    """
    page = PublishedPage.get_or_insert(source_url)
    entity = Publish.query(
      Publish.status == 'complete', Publish.type != 'preview',
      Publish.source == self.source.key,
      ancestor=page.key).get()

    if entity is None:
      entity = Publish(parent=page.key, source=self.source.key)
      if self.PREVIEW:
        entity.type = 'preview'
      entity.put()

    logging.debug("Publish entity: '%s'", entity.key.urlsafe().decode())
    return entity
예제 #6
0
파일: publish.py 프로젝트: snarfed/bridgy
  def get_or_add_publish_entity(self, source_url):
    """Creates and stores :class:`models.Publish` entity.

    ...and if necessary, :class:`models.PublishedPage` entity.

    Args:
      source_url: string
    """
    page = PublishedPage.get_or_insert(native_str(source_url.encode('utf-8')))
    entity = Publish.query(
      Publish.status == 'complete', Publish.type != 'preview',
      Publish.source == self.source.key,
      ancestor=page.key).get()

    if entity is None:
      entity = Publish(parent=page.key, source=self.source.key)
      if self.PREVIEW:
        entity.type = 'preview'
      entity.put()

    logging.debug("Publish entity: '%s'", entity.key.urlsafe())
    return entity