Пример #1
0
    def post(self):
        # We set the same parent key on the 'Greeting' to ensure each Greeting
        # is in the same entity group. Queries across the single entity group
        # will be consistent. However, the write rate to a single entity group
        # should be limited to ~1/second.
        sender = users.get_current_user()
        if sender:            
            guestbook_name = urllib.unquote_plus(self.request.get('guestbook_name',
                                          users.get_current_user().user_id() or DEFAULT_GUESTBOOK_NAME))
            greeting = Greeting(parent=guestbook_key(guestbook_name))
            greeting.author = users.get_current_user().nickname()
            greeting.user_id = users.get_current_user().user_id()
        else:
            guestbook_name = urllib.unquote_plus(self.request.get('guestbook_name', DEFAULT_GUESTBOOK_NAME))
            greeting = Greeting(parent=guestbook_key(guestbook_name))



        if self.request.get('img'):
            avatar = images.resize(self.request.get('img'),300,300)
            greeting.avatar = db.Blob(avatar)
        greeting.content = self.request.get('content')
        greeting.date = datetime.now()
        greeting.put()

        query_params = {'guestbook_name': guestbook_name}
        self.redirect('/?' + urllib.urlencode(query_params))
Пример #2
0
 def post(self):
   greeting = Greeting(parent=guestbook_key(DB_NAME))
   user_name = self.request.get('name')
   user_email = self.request.get('email')
   greeting.author = Author(name=user_name, email=user_email)
   greeting.content = self.request.get('content')
   greeting.put()
   self.redirect('/greet')
Пример #3
0
  def post(self):
    greeting = Greeting()

    if users.get_current_user():
      greeting.author = users.get_current_user()

    greeting.content = self.request.get('content')
    greeting.put()
    self.redirect('/')
Пример #4
0
 def post(self):
   greeting = Greeting()
   if users.get_current_user():
       greeting.author = users.get_current_user()
   greeting.content = self.request.get("content")
   avatar = images.resize(self.request.get("img"), 64, 64)
   greeting.avatar = db.Blob(avatar)
   greeting.put()
   self.redirect('/guestbook/')
Пример #5
0
    def post(self):
        greeting = Greeting()

        if users.get_current_user():
            greeting.author = users.get_current_user()

        greeting.content = self.request.get('content')
        greeting.put()
        self.redirect('/')
Пример #6
0
def post_guest_view(request):
    greeting = Greeting(parent=guestbook_key())

    if users.get_current_user():
        greeting.author = users.get_current_user()

    greeting.content = request.params['content']
    greeting.put()
    user = '******'
    if users.get_current_user():
        user = users.get_current_user().nickname()
    return {'greeting': greeting.content, 'user': user}
Пример #7
0
    def post(self):
        guestbook_name = self.request.get('guestbook_name')
        greeting = Greeting(parent=guestbook_key(guestbook_name))

        if users.get_current_user():
            greeting.author = users.get_current_user().nickname()

        greeting.content = self.request.get('content')
        greeting.put()

        # redirect to home page
        self.redirect('/%s' % guestbook_name)
Пример #8
0
def sign(request):
    # We set the same parent key on the 'Greeting' to ensure each greeting
    # is in the same entity group. Queries across the single entity group
    # will be consistent. However, the write rate to a single entity group
    # should be limited to ~1/second.
    guestbook_name = request.GET.get('guestbook_name', DEFAULT_GUESTBOOK_NAME)

    greeting = Greeting(parent=guestbook_key(guestbook_name))

    if users.get_current_user():
        greeting.author = users.get_current_user()

    greeting.content = request.POST.get('content')
    greeting.put()

    #query_params = {'guestbook_name': guestbook_name}
    #self.redirect('/?' + urllib.urlencode(query_params))
    return HttpResponseRedirect('/')
Пример #9
0
    def post(self):
        # We set the same parent key on the 'Greeting' to ensure each
        # Greeting is in the same entity group. Queries across the
        # single entity group will be consistent. However, the write
        # rate to a single entity group should be limited to
        # ~1/second.
        guestbook_name = self.request.get('guestbook_name',
                                          DEFAULT_GUESTBOOK_NAME)
        greeting = Greeting(parent=guestbook_key(guestbook_name))

        if users.get_current_user():
            greeting.author = Author(
                identity=users.get_current_user().user_id(),
                email=users.get_current_user().email())

        greeting.content = self.request.get('content')
        logging.debug("greeting %s", str(greeting))
        greeting.put()

        query_params = {'guestbook_name': guestbook_name}
        self.redirect('/?' + urllib.urlencode(query_params))
Пример #10
0
    def post(self):
        # We set the same parent key on the 'Greeting' to ensure each
        # Greeting is in the same entity group. Queries across the
        # single entity group will be consistent. However, the write
        # rate to a single entity group should be limited to
        # ~1/second.
        guestbook_name = self.request.get('guestbook_name',
                                          DEFAULT_GUESTBOOK_NAME)
        greeting = Greeting(parent=guestbook_key(guestbook_name))
        
        if users.get_current_user():
            greeting.author = Author(
                    identity=users.get_current_user().user_id(),
                    email=users.get_current_user().email())

        greeting.content = self.request.get('content')
        logging.debug("greeting %s",str(greeting))
        greeting.put()

        query_params = {'guestbook_name': guestbook_name}
        self.redirect('/?' + urllib.urlencode(query_params))
Пример #11
0
    def post_greeting(self):
        """
        Accepts a greeting from the client and saves it to the database.
        """
        self.response.headers['Content-Type'] = 'application/json'

        self.request.get('content')

        greeting = Greeting(content=)

        key = greeting.put()

        self.response.message = BaseAPIMessage({'id': key})
Пример #12
0
def template_file(request):
    #copied this from: https://developers.google.com/appengine/articles/django-nonrel
    user = users.get_current_user()

    g1 = Greeting()
    g1.author = user
    g1.content = "Whatever"
    g1.put()
    print("Created:" + str(g1.key()))

    context = {
        'user': user,
        'greetings': [g1],
        'login': '******',
        'logout': '/logout',
    }

    # hard way
    # t = get_template('index.html')
    # return http.HttpResponse(t.render(Context(context)))

    # easy way using django shortcuts
    return render(request, 'index.html', context)