Re: Delivery Status Notification (Failure)
Mekdelawit Woldegabriel <[email protected]> Fri, 17 Mar 2017 09:23:15 +0300
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <CAMBUDO+Mwg7UJZ+W34ZQRqse=m0E5O_JS1A2Mn8jfFUDNK36ZA@mail.gmail.com> |
ello everyone ,
I am a newbie to web application and Cherrypy.i tried the tutorials on the
documentation and i couldn't eliminate the error raised at tutorial 9 Data
is all my life.The html,CSS works fine .The data base and the table are
created properly.But error comes on the generator function.The code is as
follows.
import os ,os.path
import random
import sqlite3
import string
import time
import cherrypy
DB_STRING = "C:\SQLite\pythonsqlite2.db"
class StringGenerator(object):
@cherrypy.expose
def index(self):
return open('index.html')
@cherrypy.expose
class StringGeneratorWebService(object):
@cherrypy.tools.accept(media='text/plain')
def GET(self):
with sqlite3.connect(DB_STRING) as c:
cherrypy.session['ts'] = time.time()
r = c.execute("SELECT value FROM user_string WHERE session_id=?",
[cherrypy.session.id])
return r.fetchone()
def POST(self, length=8):
some_string = ''.join(random.sample(string.hexdigits, int(length)))
with sqlite3.connect(DB_STRING) as c:
cherrypy.session['ts'] = time.time()
r = c.execute("INSERT INTO user_string VALUES (?, ?)",
[cherrypy.session.id, some_string])
return some_string
def PUT(self, another_string):
with sqlite3.connect(DB_STRING) as c:
cherrypy.session['ts'] = time.time()
c.execute("UPDATE user_string SET value=? WHERE session_id=?",
[another_string, cherrypy.session.id])
def DELETE(self):
cherrypy.session.pop('ts', None)
with sqlite3.connect(DB_STRING) as c:
c.execute("DELETE FROM user_string WHERE session_id=?",
[cherrypy.session.id])
def setup_database():
"""Create the `user_string` table in the database
on server startup """
with sqlite3.connect(DB_STRING) as con:
con.execute("CREATE TABLE user_string (session_id, value)")
def cleanup_database():
""" Destroy the `user_string` table from the database
on server shutdown.
"""
with sqlite3.connect(DB_STRING) as con:
con.execute("DROP TABLE user_string")
if __name__ == '__main__':
conf = {
'/': {
'tools.sessions.on': True,
'tools.staticdir.root': os.path.abspath(os.getcwd())
},
'/generator': {
'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
'tools.response_headers.on': True,
'tools.response_headers.headers': [('Content-Type', 'text/plain')],
},
'/static': {
'tools.staticdir.on': True,
'tools.staticdir.dir': '.\static'
}
}
cherrypy.engine.subscribe('start', setup_database)
cherrypy.engine.subscribe('stop', cleanup_database)
webapp = StringGenerator()
webapp.generator = StringGeneratorWebService()
cherrypy.quickstart(webapp, '/', conf)
The error is
webapp.generator = StringGeneratorWebService()
TypeError: expose_() missing 1 required positional argument: 'func'
please help as soon as possible.
On Thu, Mar 16, 2017 at 5:39 PM, Mail Delivery Subsystem <
[email protected]> wrote:
> Hello [email protected],
>
> We're writing to let you know that the group you tried to contact
> (cherrypy-users) may not exist, or you may not have permission to post
> messages to the group. A few more details on why you weren't able to post:
>
> * You might have spelled or formatted the group name incorrectly.
> * The owner of the group may have removed this group.
> * You may need to join the group before receiving permission to post.
> * This group may not be open to posting.
>
> If you have questions related to this or any other Google Group, visit the
> Help Center at https://groups.google.com/support/.
>
> Thanks,
>
> Google Groups
>
>
>
> ----- Original message -----
>
> X-Received: by 10.25.193.213 with SMTP id r204mr1345832lff.24.
> 1489675160283;
> Thu, 16 Mar 2017 07:39:20 -0700 (PDT)
> Return-Path: <[email protected]>
> Received: from mail-wr0-x236.google.com (mail-wr0-x236.google.com.
> [2a00:1450:400c:c0c::236])
> by gmr-mx.google.com with ESMTPS id i76si346684wmh.1.2017.03.16.
> 07.39.20
> for <cherrypy-users-/[email protected]>
> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
> Thu, 16 Mar 2017 07:39:20 -0700 (PDT)
> Received-SPF: pass (google.com: domain of [email protected] designates
> 2a00:1450:400c:c0c::236 as permitted sender) client-ip=2a00:1450:400c:c0c::
> 236;
> Authentication-Results: gmr-mx.google.com;
> dkim=pass [email protected];
> spf=pass (google.com: domain of [email protected] designates
> 2a00:1450:400c:c0c::236 as permitted sender) smtp.mailfrom=megdiwg@gmail.
> com;
> dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
> Received: by mail-wr0-x236.google.com with SMTP id u48so33423953wrc.0
> for <cherrypy-users-/[email protected]>; Thu, 16 Mar 2017 07:39:20
> -0700 (PDT)
> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
> d=gmail.com; s=20161025;
> h=mime-version:from:date:message-id:subject:to;
> bh=8LD1FUbuKe3gP7eSRIaJRs3mF/XEOcEgq5jLBSnAfvU=;
> b=F7oShwighYLCVDf0x7XNtVpmLgSdGIap4fZcibcNMChAccLUABknbE6aSeSn
> z7w9zx
> z+5rd8jkeS77UkjS7wKlwI/3iaZuUHXcZt0UZJqUwe/
> puO6SH8P7QTj5HVLMnYV1GFWe
> xEY2Ql41xxQQyVZM5L75iF554K3XeQG7LR/sWKRkeNEYT/
> llJudcCwSmaf3hYu4pnrYO
> GfLCBqi5BhJIgKG6mUdinpeLXgwwg6K74tDvjvLfefloli4M0BEmghgHThNc
> BloH0LoI
> gzyMvfsBCpQQPCBhQ7HPdaTaAGDVnYZkWuNAhhNbL8yF0EmBJB38QHXQ0L/
> DE3OZ5Qc4
> gsTQ==
> X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
> d=1e100.net; s=20161025;
> h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
> bh=8LD1FUbuKe3gP7eSRIaJRs3mF/XEOcEgq5jLBSnAfvU=;
> b=Xp9J61MxyDkIY+LLihBBjGVuO0NgbTKtN0ha+
> 7haxYfz4+Ls9LI0ctoxF1yqYPkTrA
> 8mHnYbEfow0TqyQPES1o2JBdOboIVcU4U1fRVmKOTttuKgyrOTSh373S6c+
> 1v7WzbUH4
> wQDUJS/locPlC3/ROj5yJWuLRGttnGMDEVa2H+
> pubHXubkD/70KkDoK1jsN5aNVdfa8t
> EvQHy8/lgwhw/Ce0nKjgSHRJa7QCirUyamIJOvek+
> jQWgQG/wx9g2DVe6Ddv4oZE8b9C
> g57tmStiaefcQ23nAGc1715dVZJXmmJmF9ewhOOS1OCPRVEYhoTVdtmRXeAx
> r0iyEsea
> S5AA==
> X-Gm-Message-State: AFeK/H26EfduV8WWSqxJh1qeVgFKDQsisb4
> 7hZMcRVZciv19KrMxHuAs/NQJ8IzntGCJYcuYhcB4oRZ9PYIFqg==
> X-Received: by 10.223.172.137 with SMTP id o9mr9161320wrc.66.
> 1489675159851;
> Thu, 16 Mar 2017 07:39:19 -0700 (PDT)
> MIME-Version: 1.0
> Received: by 10.80.166.38 with HTTP; Thu, 16 Mar 2017 07:39:19 -0700 (PDT)
> From: Mekdelawit Woldegabriel <[email protected]>
> Date: Thu, 16 Mar 2017 17:39:19 +0300
> Message-ID: <CAMBUDOLyD3ARKgE5HH=eqnUMqrXT5WLoJC5ndsx17-KGeUikLw@mail.
> gmail.com>
> Subject: Help needed on SQLite wih cherrypy
> To: cherrypy-users-/[email protected]
> Content-Type: multipart/alternative; boundary=001a11477cb6bbdf65054ada06cd
>
> --001a11477cb6bbdf65054ada06cd
> Content-Type: text/plain; charset=UTF-8
>
> hello everyone ,
> I am a newbie to web application and Cherrypy.i tried the tutorials on the
> documentation and i couldn't eliminate the error raised at tutorial 9 Data
> is all my life.The html,CSS works fine .The data base and the table are
> created properly.But error comes on the generator function.The code is as
> follows.
>
> import os ,os.path
> import random
> import sqlite3
> import string
> import time
>
> import cherrypy
>
> DB_STRING = "C:\SQLite\pythonsqlite2.db"
>
> class StringGenerator(object):
> @cherrypy.expose
> def index(self):
> return open('index.html')
>
>
> @cherrypy.expose
> class StringGeneratorWebService(object):
>
> @cherrypy.tools.accept(media='text/plain')
> def GET(self):
> with sqlite3.connect(DB_STRING) as c:
> cherrypy.session['ts'] = time.time()
> r = c.execute("SELECT value FROM user_string WHERE session_id=?",
> [cherrypy.session.id])
> return r.fetchone()
>
> def POST(self, length=8):
> some_string = ''.join(random.sample(string.hexdigits, int(length)))
> with sqlite3.connect(DB_STRING) as c:
> cherrypy.session['ts'] = time.time()
> r = c.execute("INSERT INTO user_string VALUES (?, ?)",
> [cherrypy.session.id, some_string])
> return some_string
>
> def PUT(self, another_string):
> with sqlite3.connect(DB_STRING) as c:
> cherrypy.session['ts'] = time.time()
> c.execute("UPDATE user_string SET value=? WHERE session_id=?",
> [another_string, cherrypy.session.id])
>
> def DELETE(self):
> cherrypy.session.pop('ts', None)
> with sqlite3.connect(DB_STRING) as c:
> c.execute("DELETE FROM user_string WHERE session_id=?",
> [cherrypy.session.id])
>
> def setup_database():
> """Create the `user_string` table in the database
> on server startup """
>
> with sqlite3.connect(DB_STRING) as con:
> con.execute("CREATE TABLE user_string (session_id, value)")
>
> def cleanup_database():
>
> """ Destroy the `user_string` table from the database
> on server shutdown.
> """
> with sqlite3.connect(DB_STRING) as con:
> con.execute("DROP TABLE user_string")
>
> if __name__ == '__main__':
>
> conf = {
>
> '/': {
>
> 'tools.sessions.on': True,
> 'tools.staticdir.root': os.path.abspath(os.getcwd())
> },
>
> '/generator': {
>
> 'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
>
> 'tools.response_headers.on': True,
>
> 'tools.response_headers.headers': [('Content-Type',
> 'text/plain')],
> },
>
> '/static': {
>
> 'tools.staticdir.on': True,
>
> 'tools.staticdir.dir': '.\static'
> }
> }
>
> cherrypy.engine.subscribe('start', setup_database)
>
> cherrypy.engine.subscribe('stop', cleanup_database)
>
> webapp = StringGenerator()
>
> webapp.generator = StringGeneratorWebService()
>
> cherrypy.quickstart(webapp, '/', conf)
>
> The error is
>
> webapp.generator = StringGeneratorWebService()
> TypeError: expose_() missing 1 required positional argument: 'func'
>
>
> please help as soon as possible.
>
> --001a11477cb6bbdf65054ada06cd
> Content-Type: text/html; charset=UTF-8
> Content-Transfer-Encoding: quoted-printable
>
> <div dir=3D"ltr">hello everyone ,=C2=A0<div>I am a newbie to web
> applicatio=
> n and Cherrypy.i tried the tutorials on the documentation and i
> couldn'=
> t eliminate the error raised at tutorial 9 Data is all my life.The
> html,CSS=
> works fine .The data base and the table are created properly.But error
> com=
> es on the generator function.The code is as follows.</div><div><pre style=
> =3D"color:rgb(0,0,0);font-family:"courier
> new";font-size:9pt"><sp=
> an style=3D"color:rgb(0,0,128);font-weight:bold">import </span>os
> ,os.path<=
> br><span style=3D"color:rgb(0,0,128);font-weight:bold">import
> </span>random=
> <br><span sty
> ----- Message truncated -----
>
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.