For example, I have this database structure:
db.define_table('sections',
Field('title', 'string')
)
db.define_table('threads',
Field('title', 'string'),
Field('section_id', db.sections),
)
How can I get all sections and by 1 random thread per each section?
This works:
rows =
Hi,
I am having issues with an SQLFORM with list:string and having
requires=IS_IN_SET on the field.
By default this works when using the select drop down I am able to
overwrite the validation (by detecting a particular post key e.g.
draft) and use IS_EMPTY_OR on the
Jim and Richard,
Thanks for your replies, problem solved.
Kind regards,
Annet.
On Wednesday, November 16, 2011 12:50:18 AM UTC-5, Viren Patel wrote:
Hi,
We can directly find and change in tools.py
Still not clear in which file to put the code for SPAN helper object so
that we do not need to modify tools.py
Assuming auth.navbar() is included in your layout.html so it
Jim,
I've been curious about this myself. Here is what I discovered.
Tested on 1.99.2. Should be adaptable to a custom form.
Obviously one would want something more sophisticated than a string
for the key value in a real app.
from controllers/dogs.py, for grid:
def index():
grid =
On Tuesday, November 15, 2011 10:59:27 PM UTC-5, Ray (a.k.a. Iceberg) wrote:
Hi Anthony,
So you are quite familiar with the web2py internal, this time the
navbar. Are you the programmer of that function? Would you comment on
this issue?
Hello,
I have a text field in my db with a default instructive text like
Enter your comment here, but i would like when the user tries to
input text, the default text to disappear without having to delete it
manually
You can use a comment instead of a default:
Fields(..., comment='Enter your comment here')
though that will display next to or below the input field (depending on
your formstyle) rather than in the text box itself.
As an alternative, you can set the HTML5 'placeholder' attribute for the
Thnx a lot!
On Nov 16, 10:42 am, Anthony abasta...@gmail.com wrote:
You can use a comment instead of a default:
Fields(..., comment='Enter your comment here')
though that will display next to or below the input field (depending on
your formstyle) rather than in the text box itself.
As
Hi!
We recently upgraded from 1.98.2 to 1.99.2, and seem to find a
regression. An SQLFORM renders boolean database fields as checkboxes.
If you (un)check a box and hit submit, calling myform.accepts() and
redisplaying the form used to render the fields with the new, updated
values. Since the
Hi All,
I still get a ticket if I use fields code as mentioned by
Johann (I am using latest stable - web2py 1.99.2 not trunk) , does it
work with the trunk version?
Result1:
fields = (db.projects_post.title, db.projects_posts.project_details,
I found listing the controllers explicitly as Bruno mentioned fixed the problem.
Previously domain/non-default-controller returned: invalid function
(default/non-default-controller)
I would expect all controllers to work by default.
Richard
On Wed, Nov 16, 2011 at 2:36 PM, Jonathan Lundell
On 16 November 2011 14:24, Rahul rahul.dhak...@gmail.com wrote:
Hi All,
I still get a ticket if I use fields code as mentioned by
Johann (I am using latest stable - web2py 1.99.2 not trunk) , does it
work with the trunk version?
Result1:
fields = (db.projects_post.title,
Hi Folks!
I've created some functions on my model because I need to use them often
but seems that I can't update a record using it, example of code:
sandbox/models/db.py
db.define_table('mytable',
Field('myfield','string'),
Field('state','integer')
)
On 16 November 2011 15:57, Tito Garrido titogarr...@gmail.com wrote:
sandbox/models/db.py
db.define_table('mytable',
Field('myfield','string'),
Field('state','integer')
)
sandbox/models/db_functions.pydef test(id):
r=db.mytable[id]
r.update(state=55)
Try:
def
On 16 November 2011 16:07, Johann Spies johann.sp...@gmail.com wrote:
On 16 November 2011 15:57, Tito Garrido titogarr...@gmail.com wrote:
sandbox/models/db.py
db.define_table('mytable',
Field('myfield','string'),
Field('state','integer')
)
sandbox/models/db_functions.pydef
On Wednesday, November 16, 2011 8:57:10 AM UTC-5, Tito Garrido wrote:
sandbox/models/db_functions.py
def test(id):
r=db.mytable[id]
r.update(state=55)
In the above, 'r' is a Row object, so all you are doing is updating the Row
object itself, not the original record in the db. To
in trunk!
On Nov 13, 8:24 am, Ray (a.k.a. Iceberg) iceb...@21cn.com wrote:
Hi Massimo,
Following code snippet comes from gluon/tools.py 's line 3029~3030.
elif not request.extension in ('html','load'):
raise HTTP(401)
I suggest to change it into:
elif not
select(...,orbderby='random',limitby=(0,3))
On Nov 16, 2:27 am, LightOfMooN vladsale...@yandex.ru wrote:
For example, I have this database structure:
db.define_table('sections',
Field('title', 'string')
)
db.define_table('threads',
Field('title', 'string'),
On Wed, Nov 16, 2011 at 11:32 AM, Richard Baron Penman
richar...@gmail.comwrote:
I found listing the controllers explicitly as Bruno mentioned fixed the
problem.
Previously domain/non-default-controller returned: invalid function
(default/non-default-controller)
I would expect all
please open ticket about this and I will deal with it asap.
Inside Auth(...) there is this logic
if auth and auth.last_visit and auth.last_visit + \
datetime.timedelta(days=0, seconds=auth.expiration)
request.now:
self.user = auth.user
# this is a trick to speed up
sessions
if (request.now -
Ok, so what I want is to know how to verify if it authentification has
expired...
I hope I am clear I don't know the exact wording for what I want...
But I would trigger a update on my flag (logged_on : TRUE/FALSE) in case
user don't clic disconnect before close browser or if he leave his
On Nov 16, 2011, at 5:32 AM, Richard Baron Penman wrote:
I found listing the controllers explicitly as Bruno mentioned fixed the
problem.
Previously domain/non-default-controller returned: invalid function
(default/non-default-controller)
I would expect all controllers to work by default.
On Nov 16, 3:34 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
please open ticket about this and I will deal with it asap.
Ah, so there _is_ an issue tracker... I found one on Google Code, but
there's no link to it from web2py.com, only to Google Groups. I'm
opening a ticket there in a
hi,
I just managed to use codemirror instead of editarea using
python mode and html mixed mode for views
and codemirror-ui toolbar
I propose to include it in web2py as an alternative to eamy and
editarea,
may be as a default one
I can send the code and files that I used
By this way we get just 3 records at all. But I need to get ALL
sections, and by 3 thread per section.
So, I need a query to make this structure:
section1
thread1
thread4
section2
thread5
section3
thread7
thread8
thread9
It can be done by many queries like:
sections =
Sounds good if it works in all browsers. Editarea doesn't work in IE9 (and
has some display problems even in IE7-8), and Amy doesn't work in IE9.
On Wednesday, November 16, 2011 11:33:09 AM UTC-5, elffikk wrote:
hi,
I just managed to use codemirror instead of editarea using
python mode
Hi,
Thanks for this replay, showed example with if logic is very
interesting,
Regards
Miroslav
On Nov 15, 11:59 am, Khalil KHAMLICHI khamlichi.kha...@gmail.com
wrote:
Hi,
you can as well put you logic in the menu.py file like this :
if auth.user:
if auth.user.id 10 and
Ok so I just need look into : auth.is_logged_in()=False
So what about this :
def user_logged_on_update(flag, user_id):
Update of logged_on auth_user field. True = logged on.
if user_id != None and flag != None:
db.auth_user[user_id] = dict(logged_on = flag)
return
I do not think so.
On Nov 16, 10:37 am, LightOfMooN vladsale...@yandex.ru wrote:
By this way we get just 3 records at all. But I need to get ALL
sections, and by 3 thread per section.
So, I need a query to make this structure:
section1
thread1
thread4
section2
thread5
Now I understand what you want to do.
What you propose would not work because there is no logout event.
Unless the user clicks the logout button, the logout happens when the
user tries to access the site and the session time exceeds expiration.
If the user logins and turns the browser off, the
There may be an update on this that i missed, but can I ask if this
fix is sufficient?
I believe that the ret parameter is the effected row count, correct?
If you just deleted the record, can you reliably retrieve it from the
table and record id in ondelete, i.e. before a subsequent commit? My
Good Catch both of you! :-)
update_record works!
Thanks!
On Wed, Nov 16, 2011 at 12:12 PM, Anthony abasta...@gmail.com wrote:
On Wednesday, November 16, 2011 8:57:10 AM UTC-5, Tito Garrido wrote:
sandbox/models/db_functions.**py
def test(id):
r=db.mytable[id]
r.update(state=55)
Ok...
I was trying to avoid this mostly cause I have no time to look into it
comet... And also because it's something I don't master at this time.
Is it straight foward to put on?
Thank you for your help.
Richard
On Wed, Nov 16, 2011 at 1:51 PM, Massimo Di Pierro
massimo.dipie...@gmail.com
Hi,
I'm trying to create a CSV view for a set of rows. Here's the code for
the view:
{{import StringIO, csv}}
{{outfile = StringIO.StringIO()}}
{{mywriter = csv.writer(outfile, dialect=csv.excel_tab)}}
{{mywriter.writerow(['Name', 'Address', 'City', 'State'])}}
{{for row in places:}}
{{mydata =
There is way what I did works at least imperfectly ?
I want to make a quick gain for a couples of weeks...
After then I will have more time to look into comet_messaging..
Richard
On Wed, Nov 16, 2011 at 1:51 PM, Massimo Di Pierro
massimo.dipie...@gmail.com wrote:
Now I understand what you
For some reason, I need to simultaneously update a bunch of records
together in the same form. Specifically, records come from different
tables but field names sometimes overlaps, this not allowing to simply
merge the standard CRUD SQLFORMs.
I like a feature in the Drupal Forms API that's
Man!
I think you got a nice solution for this exact problem...
I had tried with jQuery in the pass to manage this by duplicating the field
that I want to bunch insert for... It was working but was breaking the
workflow of form validation if I remember... Web2py has change a lot since
then and I
Does anybody have example code showing how to package the return from
executesql as a gluon.sql.Rows object?
I have tried:
raw_rows = legacy_db.executesql(sqlstr, as_dict=True)
from gluon import sql
columns = ['col1', 'col2', 'col3']
rowsobj = sql.Rows(legacy_db, raw_rows,
Hi,
I upgraded web2py to latest version. everything works fine exept the
autocomplete widget
I use MySQL as my database.
The autocomplete is reading from a db VIEW. The reason for this is
that I have 2 columns in a db:
short_name and ISIN that is the name, and ISIN that is the ID. By
doing
I keep getting burned by how web2py handles datetimes; specifically, my
project requires millisecond precision of timestamps. The two databases I
care about support it, pgsql has microsecond resolution and sqlite is
agnostic (pysqlite3 specifically supports microseconds). MySQL and Oracle,
Actually, the number of blank lines is exactly 6 + (3 x number of rows). In
web2py templates, every {{...}} that doesn't write anything to the view
still generates a blank line in the output. Your code (up to and including
the response.write line) includes 6 blocks of {{...}} that are called
hi Roberto,
a few questions about uwsgi 1:
- how it is running by default: threaded or async?
- does it limits memory usage or I have to use as before --limit-as
80 ? I suppose that I have to pass parameter as it doesn't know the
memory limit
please tell me what you think about my command
Aha! Thank you so much.
My first time writing a non-HTML view-- didn't realize the braces
generated a blank line, or that I could include multiple lines within
braces. You've solved the problem, and made my code look nicer too!
Thanks
Nate
On Nov 16, 4:34 pm, Anthony abasta...@gmail.com wrote:
The CSV example in the book does it this way
(http://web2py.com/book/default/chapter/09#CSV), but it doesn't explicitly
mention the gotcha.
On Wednesday, November 16, 2011 4:57:04 PM UTC-5, Nate Atkinson wrote:
Aha! Thank you so much.
My first time writing a non-HTML view-- didn't realize
I found we can just JOIN the table and specify the fields you want to
display. It's nice if grid does it automatically but this is easy
enough.
def admin():
db.Product.id.readable = False
query = db.Product.Model_ID == db.Model.id
products =
Thank you to bring this up.
I was actually going to report the same issue.
I have a check box in a form. After I checked and click submit, it
will be unchecked(Reset) if there is validation error on the form.
On Nov 16, 10:23 am, pgergo pge...@deverto.com wrote:
On Nov 16, 3:34 pm, Massimo Di
Why send legacy_db into sql.Rows()?
It is not needed for anything at that point.
Maybe just send in None or some default as the first arg.
On Nov 16, 2:43 pm, David Watson davidthewat...@gmail.com wrote:
Does anybody have example code showing how to package the return from
executesql as a
Hi,
one dirty way of getting the same result = to open the rows in excel :
would be to
1/ generate a normal html table
2/ end the filename with .xls as extension
that would make usage of excel's ability to read xhtml data without going
thru StringIO
khalil
If you're just looking to use SQLTABLE, you should be able to just send the
results of executesql directly to SQLTABLE...I think.
Anthony
On Wednesday, November 16, 2011 3:43:56 PM UTC-5, David Watson wrote:
Does anybody have example code showing how to package the return from
executesql as
Hi,
I believe all you want is execute some of your own sql code inside web2py.
If I am right , all you need to have to do is run your query and catch
return value into 'results'
1/ results=db.executesql(your-sql-query-goes-here)
to send it to the view
2/ return dict(results=results)
once
On Wednesday, November 16, 2011 5:56:01 PM UTC-5, Anthony wrote:
If you're just looking to use SQLTABLE, you should be able to just send
the results of executesql directly to SQLTABLE...I think.
Oops, sorry, that's wrong.
On the other hand, you can do db.executesql(..., as_dict=True) and
from gluon.storage import Storage
from gluon.dal import Rows
result = db.executesql(SELECT first_name, last_name FROM auth_user,
as_dict=True)
result = [Storage(item) for item in result]
newrows = Rows(records=result)
newrows[0].first_name
u'Bruno'
wait, there is a better way.
from gluon.dal import Rows, Row
result = access.db.executesql(SELECT first_name, last_name FROM
auth_user, as_dict=True)
rows = Rows(records=[Row(item) for item in result])
rows[0].first_name
u'Bruno'
You can set other values for each Row.
One of the recent releases has broken computed fields.
My application uses several instances of computed fields. They all
worked perfectly in 1.94.6 to which I have now reverted.
In 1.99.2 (and possibly intervening releases) the behavior of computed
fields is unpredictable. In my case, they
Please, can you share some parts of your models?
Specially an example of a computed field declaration and what are you using
in compute=?, also it is important to have an example of what types the the
other fields.
It is important to reproduce the problem for fixing (if a bug)
also, can you
On Wednesday, November 16, 2011 8:39:54 PM UTC-5, David Manns wrote:
This is all very alarming in a framework which boasts of always
maintaining backward compatibility - quote taken from the preface of
the book.
The intention was certainly not to break backward compatibility. If
something
I have a config table, and I query for values like this from a cron
program:
db(db.config.name=='api_key').select(db.config.value).first().value
This query always returns the same value, even after I change it via
the admin app's database editor.
Is the DAL doing some sort of caching? Is there
Hey DenesL,
Could you explain how adding in definitions for 'reference FK' and
'reference TFK' helps when setting migrate=False? As far as I can tell,
those two fields are only used to generate create table queries, which are
not needed when one doesn't want web2py to change the database at
Another way around this would be to generate the csv file in the controller
instead of in the view. Set the appropriate headers and the simply return
outfile.getvalue() from the controller and your browser will download the
csv file generated in the controller.
DAL does not cache anything unless you explicit pass cache argument to
select()
db(db.config.name=='api_key').select(db.config.value, cache=(cache.ram,
50)).first().value
Are you sure the value has changed in database?
Are you assigning the returned value in to a to level class attribute? it
Hello. Here's how I define my models:
db.define_table('owner', Field('name'), format='%(name)s')
db.define_table('retail', Field('owner_id', db.owner), Field('name'),
format='%(name)s')
db.define_table('administer', Field('retail_id', db.retail),
Field('name'))
How can I select all administers
Does your cron program run continuously? what database are you using?
If you are using a database that supports mvcc (Oracle, Postgres, MySQL
with InnoDB tables, possibly others), your first select (of any kind, not
just this query) logically freezes the state of the database, and you will
not
I have a question to the mercurial users out there. Did anybody managed to
upload applications to fluxflex with the mercurial-git plugin.
I don't wanna use git for web2py development.
Regards,
Marco
what did you upgrade from?
On Nov 16, 3:07 pm, Ole Martin Maeland olemael...@gmail.com wrote:
Hi,
I upgraded web2py to latest version. everything works fine exept the
autocomplete widget
I use MySQL as my database.
The autocomplete is reading from a db VIEW. The reason for this is
that I
I believe this is a bug and it has already been fixed in trunk and
nightly build. can you confirm?
On Nov 16, 8:23 pm, Anthony abasta...@gmail.com wrote:
On Wednesday, November 16, 2011 8:39:54 PM UTC-5, David Manns wrote:
This is all very alarming in a framework which boasts of always
Hello Casey, Can you show us your test?
On Nov 16, 1:14 pm, Casey Schroeder vizqu...@gmail.com wrote:
There may be an update on this that i missed, but can I ask if this
fix is sufficient?
I believe that the ret parameter is the effected row count, correct?
If you just deleted the record,
Hi Johann, All,
Thanks! that worked like a charm :) Thanks everyone for your
immediate help, I'll put up a slice (on web2pyslices) by weekend for
with the necessary things needed for making SQLForm.grid up and
running with web2py.
Now some more questions (for making SQLForm.grid more
Hi ,
i used inbuilt import function provided by web2py on GAE but after
import my id's in the table were changing so i opted for BULKLOADER to
perform import via command line (i want id's in the datastore table to
be same as they are in the file)
1. while importing a file via command line i am
On 17 November 2011 08:57, Rahul rahul.dhak...@gmail.com wrote:
How can I make it use existing functions (that are there by default
SQLForm.grid) associated with View, Edit and Delete (CRUD)'s ?
Some time ago I have asked the same question and got the following answer
form simo...@gmail.com:
Hi Massimo,
upgrade from version 1.89.5 (2010-11-21), so old version.
I have tried to substitute the built in autocomplete with s-cubism
suggest_widget. It works the same way - no function when I try to read
from db view, but works fine when directly from db.
regards
Martin
On Thu, Nov 17,
what web2py version are you using? I have 1.99.2
This is the only variable I have defined in routes.py:
routers = dict(
BASE = dict(
domains = {
'domain1' : 'forum',
'domain2' : 'sales',
},
controllers = ['default', 'appadmin', 'view'], # also tried
73 matches
Mail list logo