Anand, here my code :

--- index.html in /templates folder :

$def with (name,links, article)
$# File: templates/index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
        <html>
        <head>
        </head>
<body>
                <h3>$name</h3>

                        $for i in links:
                                <a href="$i">$i</a><br>
                <em>
                        $for j in article:
                                $j
                </em>

        </body>
        </html>


--- My  charsetproblem.mysql :

# Record this in iso-8859-15 ! #
# Usage:        mysql -u mylogin -p mybase < charsetproblem.mysql #
#               Open  : mysql -u mylogin -p mybase                      #
#                       mysql>     SHOW TABLES;                         #
#                       mysql>     select * from articles;              #
#                       mysql>     DROP TABLE IF EXISTS articles;       #
#                                                                               
                #

# --- create table ---#

CREATE TABLE articles (
id int(10) NOT NULL auto_increment,
titre char(80)  DEFAULT "" NOT NULL,
article text(4096)  DEFAULT "" NOT NULL,
PRIMARY KEY (id)
)DEFAULT CHARACTER SET utf8;




# --- insert datas ---#

INSERT INTO articles VALUES (NULL, "simple link without french
characters", "Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua.");

INSERT INTO articles VALUES (NULL, "simple link with frènch
chàracters", "Lorém ipsum dôlor sit amet, çonsèctetur àdipisicing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua.");



--- My code.py :

#!/usr/bin/env python
#-*- coding: utf-8 -*-

# Note:

import web
from web import form
import urllib

web.config.debug = False

db = web.database(dbn='mysql', user='myname', pw='mypassword',
db='mydb')


render = web.template.render('templates/')

urls = (
        '/(.*)', 'index'
        )

app = web.application(urls, globals())

# =========
class index:
        """ """
        def __init__(self):
                """  """

        def GET(self, name = "index"):
                """ """
                web.header("Content-Type", "text/html; charset= utf-8")

                links = []
                article =[]

                # So i record my "charsetproblem.mysql" test in "iso-8859-15" 
with
Gedit.
                # Then i have this :

                # --- LINKS - All titles become links
                # My queries and what's happened when i change line 124 in 
/usr/lib/
python2.5/site-packages/web/db.py
                # Query 1 :     self.items = [str(items)]       ->      ok
                #                       self.items = [items]            ->      
ok
                #result_titre_db = db.query('select titre from articles;')


                # Query 2 :     self.items = [str(items)]       ->      ok
                #                       self.items = [items]            ->      
ok
                result_titre_db = db.select("articles", what='titre')



                for i in result_titre_db:
                        links.append(i.titre)



                # --- ARTICLES -
                # My queries and what's happened when i change line 124 in 
/usr/lib/
python2.5/site-packages/web/db.py
                # Query 3 :     self.items = [str(items)]       ->      Error
                #                       self.items = [items]            ->      
ok
                #result_article_db = db.query('select article from articles 
where
articles.titre = "%s";' % name)

                # Query 4 :     self.items = [str(items)]       ->      ok
                #                       self.items = [items]            ->      
ok
                result_article_db = db.query("select * from articles where
articles.titre = $title",vars=dict(title=name))



                for i in result_article_db:
                        article.append(i.article)


                return render.index(name, links, article)

if __name__ == "__main__":
        app.run()



So if i use :

result_article_db = db.query("select * from articles where
articles.titre = $title",vars=dict(title=name))

I have no problem and I do not need to change the line 124 deb.py ;)

Thanks !

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to