Massimo,
I am still struggling with this part of my application. I built a
simple mock application containing only the relevant part of the
problem.
The model defines one table: image:
db.define_table('image',
SQLField('organisation'),
SQLField('title'),
SQLField('div'),
SQLField('file','upload'),
migrate='image.table')
db.image.title.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB
(db,db.image.title)]
The controller contains 2 functions: index() and download().
I hard-coded the image.organisation variable because it bears no
relevance to solving the problem.
def index():
response.view='image_layout.html'
images=db(db.image.organisation==1).select(db.image.ALL)
return dict(images=images)
def download():
import os
path=os.path.join(request.folder,'uploads',request.args[0])
return response.stream(path)
The view contains the <style></style> element which I want to generate
dynamically based on the contents of the image table.
<link href="{{=URL(r=request,c='static',f='images.css')}}"
rel="stylesheet" type="text/css" media="screen" charset="utf-8" />
<style type="text/css">
{{for image in images:}}
#{{=image.div}} {
background-image: url{{=URL
(r=request,f='download',args=image.file)}};
}
{{pass}}
</style>
<div id="container">
<div id="header">
<div id="logo">
</div> <!-- logo -->
<div id="image">
</div> <!-- image -->
</div> <!-- header -->
<div id="content">
</div> <!-- content -->
<div id="footer">
</div> <!-- footer -->
</div> <!-- container -->
The image.css file reads like:
#container {
background-color: gray;
width: 984px;
height: 576px;
}
#header {
width: 100%;
}
#logo {
float: left;
width: 240px;
height: 144px;
}
#image {
float: right;
width: 720px;
height: 144px;
}
#content {}
#footer {}
When I expose the index function, the source code of the html page
reads like:
<link href="/images/static/images.css" rel="stylesheet" type="text/
css" media="screen" charset="utf-8" />
<style type="text/css">
#logo {
background-image: url/images/default/download/image.file.8bdf62bb-
ee59-411c-94ac-ef7d729dfa75.gif;
}
#image {
background-image: url/images/default/download/image.file.5d948237-
de5b-4a71-a0b6-24e2688a0d4c.jpg;
}
</style>
<div id="container">
<div id="header">
<div id="logo">
</div> <!-- logo -->
<div id="image">
</div> <!-- image -->
</div> <!-- header -->
<div id="content">
</div> <!-- content -->
<div id="footer">
</div> <!-- footer -->
</div> <!-- container -->
The contents of <style type="text/css"></style> should read something
like:
<style type="text/css">
#logo {
background-image: url('url/images/default/download/image.file.
8bdf62bb-ee59-411c-94ac-ef7d729dfa75.gif');
}
#image {
background-image: url('url/images/default/download/image.file.
5d948237-de5b-4a71-a0b6-24e2688a0d4c.jpg');
}
</style>
Where the code between ('...'); should reference the image file, which
it doesn't.
I hope that with the information provided you will be able to help me
solve this problem.
Best regards,
Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---