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 4589218
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:02:04+00:00 2026-05-21T22:02:04+00:00

Is there a way of moving all attributes within a model with a value

  • 0

Is there a way of moving all attributes within a model with a value set to True to another model?
I am writing in Python and have the following:

 class crimechecker(webapp.RequestHandler):
    def get(self):
        #Checks for crime
        articles = Article.all().filter('crime = ', None)
        for article in articles:
            crime = False
            for word in triggers:
                body = article.body
                if body.find(word) != -1:
                    crime = True
            article.crime = crime
            a = article.put()

Then a separate cron is run: and each crime story is added to Story with their location.
But the stories are not appearing in the Story model?!

class place(webapp.RequestHandler):
    def post(self):
        # Check for any article which was classified as "TRUE" therefore it is a crime document
        crimes = Article.all().filter('crime = ', True)
        for crimestory in crimes:
            if Story.all().filter('title = ', crimestory.title).count() == 0:
                #Yahoo Placemaker key
                p = placemaker('HSnG9pPV34EUBcexz.tDYuSrZ8Hnp.LowswI7TxreF8sXrdpVyVIKB4uPGXBYOA9VjjF1Ca42ipd_KhdJsKYjI5cXRo0eJM-')
                #Encoding for symbols and euro signs etc.
                print p.find_places(crimestory.body.encode('utf-8'))
                for place in p.places:
                    splitted = place.name.split()
                    #Check for locations within Ireland (IE)
                    if 'IE' in splitted:
                        story = Story(long=place.centroid.longitude, lat=place.centroid.latitude, link=crimestory.link, loc_name=place.name, title=crimestory.title, date=crimestory.date).put()
                        logging.info(story)

I have 2 models: an Article and Story.
All articles are stored in the article model and any article with crime = True is set to be in the Story model.
For some reason it is not moving the stories.
The cron is running and not having any log errors.
Can I do this task in my dashboard?
I have queried both models :

SELECT * FROM Article ORDER BY date DESC

The Article model has stories from todays date (May 2nd)

Story has articles from April 19th and no more since then.
Can I query the models and say move all entities with crime set to true to the Story model?

  • 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-21T22:02:05+00:00Added an answer on May 21, 2026 at 10:02 pm

    I don’t see anything obviously wrong with your code. Since we’ve already established that there are no errors, my advice would be to add more logging.info calls higher up to see which if statement is evaluating to false, or which for loop is iterating over an empty set. Also, have you confirmed that crimechecker is successfully setting new crime stories to True? It doesn’t sound like you’ve determined which of your two cron jobs is at fault.

    More fundamentally, I think you should re-consider the basic design of this task. Let’s classify it as 3 steps:

    1. User creates a new Article entity with a title and body
    2. If the body contains certain keywords, flag it as containing a crime.
    3. If it contains a crime, create a corresponding Story entity.

    Why not just do all of this work in one handler when the article is saved? Why break it out three distinct parts? Besides making the operation complex, your 2nd cron job is also inefficient at scale. You’re fetching every crime story since the beginning of time and doing one query for each to see if there’s a corresponding story. If you accumulate any significant number of articles, this won’t complete in time.

    If you’re worried about the performance impact of doing all of these tasks when the article is first saved, use the task queue. When the article is first saved, create one task to scan it for crime keywords. If the keywords are found, create one task to store the corresponding story entity. Pass the entity key around in the task parameters so you don’t have to query for anything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to suspend all anchored controls on a form from moving
Is there a way to prevent the user from moving the cursor in a
Is there any way to temporarily disable ALL events on an windows form? I
Is there any way to process all Windows messages while the UI thread is
Is there any way I can pause all UI Update commands in Winforms? Or
I was wondering if there is any known way of moving MATLAB figures to
Is there a way to pass a newly created object(not saved yet) to another
Is there way in next piece of code to only get the first record?
is there way thats i can preselect an item when the page loads or
is there way how to get name ov event from Lambda expression like with

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.