Search Results

Search found 33 results on 2 pages for 'gql'.

Page 2/2 | < Previous Page | 1 2 

  • Using sub filters/queries in Google App Engine

    - by fredrik
    Hi, I'm trying to use figure out how to sub query a query that uses a filter. From what I've figured out so far while using .filter() it changes the original query, that leads to a second .filter() would also have to match the first filter. I would like to make something like this: modules = data.Modules.all().filter('page = ', page.key()) modules.filter('name = ', 'Test') modules.filter('name = ', 'Test2') I can't get the "Test2" filter to work. The only solution I have at the moment is to make all new queries. data.Modules.all().filter('page = ', page.key()).filter('name = ', "Test").get() data.Modules.all().filter('page = ', page.key()).filter('name = ', "Test2").get() Or write the same as an GQL. But for me it seams quite stupid way to go. I've looked at using ancestors, but I don't quite understand it and honestly don't know if that's the way to go. Any ideas? ..fredrik

    Read the article

  • GAE datastore eager loading in python api

    - by tomus
    I have two models in relation one-to-many: class Question(db.Model): questionText = db.StringProperty(multiline=False) class Answer(db.Model): answerText = db.StringProperty(multiline=False) question = db.ReferenceProperty(Question, collection_name='answers') I have front-end implemented in Flex and use pyamf to load data. When i try to load all answers with related questions all works as desired and I can access field answer.question however in case of loading questions (e.g. by Questions.all() ), 'question.answers' remains empty/null (though on server/python side I can revise question.answers without problem - probably after lazy-loading). So is it possible to load all questions along with answers ? (I know this is possible in JPA Java api but what about python ?) Shoud I use additional setting, GQL query or django framework to make it work ?

    Read the article

  • Use Google AppEngine datastore outside of AppEngine project

    - by Holtwick
    For my little framework Pyxer I would like to to be able to use the Google AppEngine datastores also outside of AppEngine projects, because I'm now used to this ORM pattern and for little quick hacks this is nice. I can not use Google AppEngine for all of my projects because of its's limitations in file size and number of files. A great alternative would also be, if there was a project that provides an ORM with the same naming as the AppEngine datastore. I also like the GQL approach very much, since this is a nice combination of ORM and SQL patterns. Any ideas where or how I might find such a solution? Thanks.

    Read the article

  • On Google AppEngine what is the best way to merge two tables?

    - by gpjones
    If I have two tables, Company and Sales, and I want to display both sets of data in a single list, how would I do this on Google App Engine using GQL? The models are: class Company(db.Model): companyname = db.StringProperty() companyid = db.StringProperty() salesperson = db.StringProperty() class Sales(db.Model): companyid = db.StringProperty() weeklysales = db.StringProperty() monthlysales = db.StringProperty() The views are: def company(request): companys = db.GqlQuery("SELECT * FROM Company") sales = db.GqlQuery("SELECT * FROM Sales") template_values = { 'companys' : companys, 'sales' : sales } return respond(request, 'list', template_values) List html includes: {%for company in companys%} {% for sale in sales %} {% ifequal company.companyid sales.companyid %} {{sales.weeklysales}} {{sales.monthlysales}} {% endifequal %} {% endfor %} {{company.companyname}} {{company.companyid}} {{company.salesperson}} {%endfor%} Any help would be greatly appreciated.

    Read the article

  • NoneType has no attribute Append

    - by Rosarch
    I'm new to Python. I can't understand why a variable is None at a certain point in my code: class UsersInRoom(webapp.RequestHandler): def get(self): room_id = self.request.get("room_id") username = self.request.get("username") UserInRoom_entities = UserInRoom.gql("WHERE room = :1", room_id).get() if UserInRoom_entities: for user_in_room in UserInRoom_entities: if user_in_room.username == username: user_in_room.put() # last_poll auto updates to now whenenever user_in_room is saved else: user_in_room = UserInRoom() user_in_room.username = username user_in_room.put() UserInRoom_entities = [] UserInRoom_entities.append(user_in_room) // error here # name is `user_at_room` intead of `user_in_room` to avoid confusion usernames = [user_at_room.username for user_at_room in UserInRoom_entities] self.response.out.write(json.dumps(usernames)) The error is: Traceback (most recent call last): File "C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 507, in __call__ handler.get(*groups) File "path\to\chat.py", line 160, in get AttributeError: 'NoneType' object has no attribute 'append' How is this possible? I'm setting UserInRoom_entities = [] immediately before that call. Or is something else the None in question?

    Read the article

  • Querying datetime.datetime on appengine acts different then dev server help!

    - by Alon Carmel
    Hey, I'm having some trouble with stuff that work locally and dont work on the app engine python environment: Basically, i want to get a program from an epg between ranges of date and time. i know i cannot do two where < so i saw a suggestion to save the dates as list as datetime.datetime which i did. [datetime.datetime(2010, 5, 10, 14, 25), datetime.datetime(2010, 5, 10, 15, 0)] This is ok. but when i try to compare to it: progranon = get_object(Programs2Channel, 'channel_id =', channelobj.key(), 'endstartdate >', programstart_minex, 'endstartdate <', programstart_minex ) This for some reason works locally, but fails to retrieve the data on the app engine. *Im using Google app engine django patch which uses the get_object to retrieve data in transactions. Please help. Here are more details: this is the LIST: [datetime.datetime(2010, 5, 13, 10, 45), datetime.datetime(2010, 5, 13, 11, 30)] #this is the query: programstart = ""+year+"-"+month+"-"+day+" "+hour+":"+minute programstart_minex = datetime.strptime(programstart, "%Y-%m-%d %H:%M") progranon = Programs2Channel.gql('WHERE channel_id = :channelid AND endstartdate > :programstartx AND endstartdate < :programstartx',channelid = channelobj.key(),programstartx=programstart_minex).get()

    Read the article

  • Dynamically generate client-side HTML form control using JavaScript and server-side Python code in Google App Engine

    - by gisc
    I have the following client-side front-end HTML using Jinja2 template engine: {% for record in result %} <textarea name="remark">{{ record.remark }}</textarea> <input type="submit" name="approve" value="Approve" /> {% endfor %} Thus the HTML may show more than 1 set of textarea and submit button. The back-end Python code retrieves a variable number of records from a gql query using the model, and pass this to the Jinja2 template in result. When a submit button is clicked, it triggers the post method to update the record: def post(self): if self.request.get('approve'): updated_remark = self.request.get('remark') record.remark = db.Text(updated_remark) record.put() However, in some instances, the record updated is NOT the one that correspond to the submit button clicked (eg if a user clicks on record 1 submit, record 2 remark gets updated, but not record 1). I gather that this is due to the duplicate attribute name remark. I can possibly use JavaScript/jQuery to generate different attribute names. The question is, how do I code the back-end Python to get the (variable number of) names generated by the JavaScript? Thanks.

    Read the article

  • get_by_id method on Model classes in Google App Engine Datastore

    - by tarn
    I'm unable to workout how you can get objects from the Google App Engine Datastore using get_by_id. Here is the model from google.appengine.ext import db class Address(db.Model): description = db.StringProperty(multiline=True) latitude = db.FloatProperty() longitdue = db.FloatProperty() date = db.DateTimeProperty(auto_now_add=True) I can create them, put them, and retrieve them with gql. address = Address() address.description = self.request.get('name') address.latitude = float(self.request.get('latitude')) address.longitude = float(self.request.get('longitude')) address.put() A saved address has values for >> address.key() aglndWVzdGJvb2tyDQsSB0FkZHJlc3MYDQw >> address.key().id() 14 I can find them using the key from google.appengine.ext import db address = db.get('aglndWVzdGJvb2tyDQsSB0FkZHJlc3MYDQw') But can't find them by id >> from google.appengine.ext import db >> address = db.Model.get_by_id(14) The address is None, when I try >> Address.get_by_id(14) AttributeError: type object 'Address' has no attribute 'get_by_id' How can I find by id? EDIT: It turns out I'm an idiot and was trying find an Address Model in a function called Address. Thanks for your answers, I've marked Brandon as the correct answer as he got in first and demonstrated it should all work.

    Read the article

< Previous Page | 1 2