Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6823711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:48:55+00:00 2026-05-26T21:48:55+00:00

I’m trying code nearly identical to the example from the manual to enable a

  • 0

I’m trying code nearly identical to the example from the manual to enable a download counter but I get an exception:

File “/media/Lexar/montao/wwwblob/handler.py”, line 117, in FileInfo
download_count = db.IntegerProperty(required=True, count=0) TypeError: init() got an unexpected keyword argument ‘count’

Here’s the code I try to run:

from google.appengine.ext import deferred
from google.appengine.runtime import DeadlineExceededError


    class Mapper(object):

    # Subclasses should replace this with a model class (eg, model.Person).

    KIND = None

    # Subclasses can replace this with a list of (property, value) tuples to filter by.

    FILTERS = []

    def __init__(self):
        self.to_put = []
        self.to_delete = []

    def map(self, entity):
        """Updates a single entity.

        Implementers should return a tuple containing two iterables (to_update, to_delete).
        """

        return ([], [])

    def finish(self):
        """Called when the mapper has finished, to allow for any final work to be done."""

        pass

    def get_query(self):
        """Returns a query over the specified kind, with any appropriate filters applied."""

        q = self.KIND.all()
        for (prop, value) in self.FILTERS:
            q.filter('%s =' % prop, value)
        q.order('__key__')
        return q

    def run(self, batch_size=100):
        """Starts the mapper running."""

        self._continue(None, batch_size)

    def _batch_write(self):
        """Writes updates and deletes entities in a batch."""

        if self.to_put:
            db.put(self.to_put)
            self.to_put = []
        if self.to_delete:
            db.delete(self.to_delete)
            self.to_delete = []

    def _continue(self, start_key, batch_size):
        q = self.get_query()

        # If we're resuming, pick up where we left off last time.

        if start_key:
            q.filter('__key__ >', start_key)

        # Keep updating records until we run out of time.

        try:

            # Steps over the results, returning each entity and its index.

            for (i, entity) in enumerate(q):
                (map_updates, map_deletes) = self.map(entity)
                self.to_put.extend(map_updates)
                self.to_delete.extend(map_deletes)

                # Do updates and deletes in batches.

                if (i + 1) % batch_size == 0:
                    self._batch_write()

                # Record the last entity we processed.

                start_key = entity.key()
            self._batch_write()
        except DeadlineExceededError:

            # Write any unfinished updates to the datastore.

            self._batch_write()

            # Queue a new task to pick up where we left off.

            deferred.defer(self._continue, start_key, batch_size)
            return
        self.finish()

class FileInfo(db.Model):

    blob = blobstore.BlobReferenceProperty(required=True)
    download_count = db.IntegerProperty(required=True, count=0)
    uploaded_by = db.UserProperty(required=True)
    uploaded_at = db.DateTimeProperty(required=True, auto_now_add=True)


    class DailyTotal(db.Model):

        date = db.DateProperty(required=True, auto_now_add=True)
        file_count = db.IntegerProperty(required=True)
        download_count = db.IntegerProperty(required=True)


    class DownloadCountMapper(Mapper):

        KIND = FileInfo

        def __init__(self):
            self.file_count = 0
            self.download_count = 0

        def map(self, file):
            self.file_count += 1
            self.download_count += file.download_count

        def finish(self):
            total = DailyTotal(file_count=self.file_count,
                               download_count=self.download_count)
            total.put()

Can you tell me what I should do?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:48:56+00:00Added an answer on May 26, 2026 at 9:48 pm

    This line is the culprit:

    download_count = db.IntegerProperty(required=True, count=0)
    

    The IntegerProperty constructor doesn’t know what to do with count. Maybe you meant this:

    download_count = db.IntegerProperty(required=True, default=0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to render a haml file in a javascript response like so:
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.