Re: [web2py] SQLFORM for keyed table

2012-06-04 Thread Johann Spies
On 4 June 2012 21:21, obad hemaily  wrote:

>
> Can I insert data with SQLFORM at keyed table
> the table in postgresql db
> the table created with web2py
>


Yes :)

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


[web2py] Re: Error when inserting SQLCustomType

2012-06-04 Thread Alexander Shashkevych
I tried another field name, but result the same. I think dal has incomplete 
handling of custom types. I analyzed dal code and found that constructed 
query for my example was:

INSERT INTO posts(content,html,title) VALUES 
(\xd0\x94\xd0\xb2\xd0\xb0,\xd0\xa2\xd1\x80\xd0\xb8,\xd0\x9e\xd0\xb4\xd0\xb8\xd0\xbd);

As you can see values are not enclosed by quotes. This is incorrect as for 
me. I rewrote my custom type:

utext = SQLCustomType(
type="text",
native="text",
encoder = lambda x: "'%s'" % x.replace("'", "''").encode("utf-8"),
decoder = lambda x: x.decode("utf-8")
)

And it works after such update, but example from the web2py book wouldn't 
work also:

compressed = SQLCustomType(
 type ='text',
 native='text',
 encoder =(lambda x: zlib.compress(x or '')),
 decoder = (lambda x: zlib.decompress(x))
)

Further analysis shown that DAL doesn't check SQLCustomType.type while 
constructing query and simply calls SQLCustomType.encoder(). But it should 
check the type of SQLCustomType and enclose it with quotes in case of 
string/text type. I updated BaseAdapter.represent() with following code:

...
if isinstance(fieldtype, SQLCustomType):
if fieldtype.type == "string" or fieldtype.type == "text": # added
   return self.adapt(fieldtype.encoder(obj))   # added
return fieldtype.encoder(obj)
...

Now my custom type doesn't require code that adds quotes - now this does 
DAL. =)

Could you comment how my fix fits DAL design?


[web2py] Re: access an uploaded but not stored file?

2012-06-04 Thread Massimo Di Pierro
In gluon main there is this code:

request.body = copystream_progress(request) ### stores request body 
if (request.body and request.env.request_method in ('POST', 'PUT', 
'BOTH')):
dpost = 
cgi.FieldStorage(fp=request.body,environ=environ,keep_blank_values=1)
request.body.seek(0)

- request.body is a temporary copy of input stream (contains the multipart 
form, which may have files in it)
- cgi.FieldStorage(fp=request.body) parses the request stream and return a 
dictionary of FieldStorage objects (including files that may be in there)

Perhaps this helps.





On Monday, 4 June 2012 23:55:23 UTC-5, Charles Tang wrote:
>
> I have test request.vars.file_field.file, it can only be accesssed after 
> the whole file is uploaded.Should I do it at a lower level?
>
> On Tuesday, June 5, 2012 11:41:28 AM UTC+8, Charles Tang wrote:
>>
>> Can the request.vars.file_fileid.file be accessed before the video is 
>> completely uploaded?
>>
>> On Monday, June 4, 2012 11:36:35 PM UTC+8, Massimo Di Pierro wrote:
>>>
>>> The file is in request.vars.file_field.file which is a read-only stream. 
>>> You can shutil.copyfile it to a temporary folder.
>>>
>>> On Friday, 14 January 2011 18:56:41 UTC-6, Thomas Dall'Agnese wrote:

 Dear community, 

 I have a form with an upload field that I use to upload a text file, 
 parse information from this file and store this information into the 
 database, but not the file itself. 

 The form is for example defined by: 
 form = FORM(INPUT(_name='file_field', _type = 'file', requires = 
 IS_NOT_EMPTY()), 
   INPUT(_type='submit')) 

 I can access the file content with request.vars.file_field.file.read() 
 but this function does not detect the file encoding and open all my 
 file as utf-8. 
 So instead I would like to use codecs.open(xxx, "r", charset) to 
 define the charset (utf-8, iso-8859-1, ...). 
 However, as I don't store the file, I can't find the file in the 
 uploads/ directory. 
 How can I find the temporary file path if there is any? 

 Or do you have any suggestion to read the uploaded file with the right 
 encoding (without chardet)? 

 Best regards, 

 $p00ky
>>>
>>>

[web2py] Re: access an uploaded but not stored file?

2012-06-04 Thread Charles Tang
I have test request.vars.file_field.file, it can only be accesssed after 
the whole file is uploaded.Should I do it at a lower level?

On Tuesday, June 5, 2012 11:41:28 AM UTC+8, Charles Tang wrote:
>
> Can the request.vars.file_fileid.file be accessed before the video is 
> completely uploaded?
>
> On Monday, June 4, 2012 11:36:35 PM UTC+8, Massimo Di Pierro wrote:
>>
>> The file is in request.vars.file_field.file which is a read-only stream. 
>> You can shutil.copyfile it to a temporary folder.
>>
>> On Friday, 14 January 2011 18:56:41 UTC-6, Thomas Dall'Agnese wrote:
>>>
>>> Dear community, 
>>>
>>> I have a form with an upload field that I use to upload a text file, 
>>> parse information from this file and store this information into the 
>>> database, but not the file itself. 
>>>
>>> The form is for example defined by: 
>>> form = FORM(INPUT(_name='file_field', _type = 'file', requires = 
>>> IS_NOT_EMPTY()), 
>>>   INPUT(_type='submit')) 
>>>
>>> I can access the file content with request.vars.file_field.file.read() 
>>> but this function does not detect the file encoding and open all my 
>>> file as utf-8. 
>>> So instead I would like to use codecs.open(xxx, "r", charset) to 
>>> define the charset (utf-8, iso-8859-1, ...). 
>>> However, as I don't store the file, I can't find the file in the 
>>> uploads/ directory. 
>>> How can I find the temporary file path if there is any? 
>>>
>>> Or do you have any suggestion to read the uploaded file with the right 
>>> encoding (without chardet)? 
>>>
>>> Best regards, 
>>>
>>> $p00ky
>>
>>

[web2py] Re: access an uploaded but not stored file?

2012-06-04 Thread Charles Tang
Can the request.vars.file_fileid.file be accessed before the video is 
completely uploaded?

On Monday, June 4, 2012 11:36:35 PM UTC+8, Massimo Di Pierro wrote:
>
> The file is in request.vars.file_field.file which is a read-only stream. 
> You can shutil.copyfile it to a temporary folder.
>
> On Friday, 14 January 2011 18:56:41 UTC-6, Thomas Dall'Agnese wrote:
>>
>> Dear community, 
>>
>> I have a form with an upload field that I use to upload a text file, 
>> parse information from this file and store this information into the 
>> database, but not the file itself. 
>>
>> The form is for example defined by: 
>> form = FORM(INPUT(_name='file_field', _type = 'file', requires = 
>> IS_NOT_EMPTY()), 
>>   INPUT(_type='submit')) 
>>
>> I can access the file content with request.vars.file_field.file.read() 
>> but this function does not detect the file encoding and open all my 
>> file as utf-8. 
>> So instead I would like to use codecs.open(xxx, "r", charset) to 
>> define the charset (utf-8, iso-8859-1, ...). 
>> However, as I don't store the file, I can't find the file in the 
>> uploads/ directory. 
>> How can I find the temporary file path if there is any? 
>>
>> Or do you have any suggestion to read the uploaded file with the right 
>> encoding (without chardet)? 
>>
>> Best regards, 
>>
>> $p00ky
>
>

[web2py] Re: How to access temporary uploaded file?

2012-06-04 Thread Charles Tang
Maybe I should do it on cgi level?

On Monday, June 4, 2012 10:05:23 PM UTC+8, Anthony wrote:
>
> I'm not sure how you might be able to process the file *while* it is 
> uploading (i.e., process the bytes as they are received by the server), but 
> if you can wait until the file is fully uploaded, you can access the 
> uploaded file as a Python cgi.FieldStorage object:
>
> def upload():
> if request.vars.myfile:
> video = encode_video(request.vars.myfile.file)
> [do something with video]
> form = SQLFORM.factory(Field('myfile', 'upload', uploadfolder=
> '/path/to/upload')).process()
> return dict(form=form)
>
> Upon upload, request.vars.myfile will be a cgi.FieldStorage object, and 
> the open file object will be in request.vars.myfile.file. Note, if the 
> encoding takes a while, you might want to pass it off to a task queue 
> rather than handle it in the controller.
>
> Anthony
>
> On Monday, June 4, 2012 4:23:55 AM UTC-4, Charles Tang wrote:
>>
>> I am using a sqlform to upload a video file and want to encoding the 
>> video file while uploading. But I noticed that the upload file is not saved 
>> to uploads directory utill it is completely uploaded. Is there a temporary 
>> file and how can I access it ?Thanks.
>>
>

Re: [web2py] Re: DAL list:integer and postgresql integer array type

2012-06-04 Thread Bruno Rocha
Cant we have a custom field for this?

Field.PostgresIntegerList("name")

http://zerp.ly/rochacbruno
Em 02/06/2012 00:26, "Massimo Di Pierro" 
escreveu:

> The search by content should be faster using native postgresql array type.
> Everything else should be the same. We could change it and should be easy.
> The problem is backward compatibility. I need to give some thought about
> this. Please open a ticket to google code.
>
> On Friday, 1 June 2012 16:49:39 UTC-5, Lewis wrote:
>>
>> By any chance is the DAL list:integer type implemented as a postgresql
>> array?   The web2py book would say no--the list:integer is a big text field
>> as '1 | 2 | 3', etc.
>>
>> Could it be implemented using postgresql's native array types in the DAL
>> driver for postgresql?  I'd assume that optimized db query code would be
>> rather faster than parsing a big text field in python code.
>>
>> How could I code a model with a FIELD function that referred to a
>> postgresql array field ('CREATE TABLE foo (favorites integer[], more
>> fields...);') that I created outside of the DAL?  I am thinking this is not
>> possible as the DAL types could not map to this postgresql type to express
>> queries and handle results.
>>
>> Assuming I end up using Field('favorites', 'list:integer') what are the
>> performance implications?
>>
>> My usage is that each user can have favorites, which will simply be the
>> numeric key of the favorite item.  A favorites table would have three
>> fields:  id (as key), user (refer to auth.user.id), favorites (a list or
>> array of integers).
>>
>> Thanks for any suggestions/comments.
>>
>> - Lewis
>>
>


[web2py] Re: what do you think about waitress webserver

2012-06-04 Thread Massimo Di Pierro
I still think rocket is the best (speed and design compromise) but I am not 
sure Tim is till maintaining it. If rocket is no longer maintained we 
should revert to cherrypy. It supports ssl and has proved its worth.


On Monday, 4 June 2012 18:17:57 UTC-5, pbreit wrote:
>
> Well that's a problem and supports my initial intuition. I'm not sure how 
> it can be considered "production-ready" without SSL.
>
>
> On Monday, June 4, 2012 1:21:10 PM UTC-7, Anthony wrote:
>>
>> No SSL, though.
>>
>> On Monday, June 4, 2012 4:12:16 PM UTC-4, pbreit wrote:
>>>
>>> Ordinarily I would not think much of it but it actually looks 
>>> interesting considering it is pure Python, supposedly production ready and 
>>> "very acceptable performance".
>>>
>>>
>>> On Monday, June 4, 2012 7:03:11 AM UTC-7, Vasile Ermicioi wrote:

 hi, 
 what do you think about waitress webserver?

 http://docs.pylonsproject.org/projects/waitress/en/latest/ 




[web2py] Re: Error when inserting SQLCustomType

2012-06-04 Thread Massimo Di Pierro
This is not allowed

Field('text', type=utext, default=""),

'text' cannot be a field name.

On Monday, 4 June 2012 16:54:46 UTC-5, Alexander Shashkevych wrote:
>
>
> Hi,
>
>  I got strange error when tried to use SQLCustomType. I'm trying to create 
> custom type which will handle unicode<->utf8 conversions. Since DB stores 
> in utf8, but my app uses unicode, so I tried to create custom type which 
> handles such conversions. Here is my code:
>
> db = DAL("sqlite:tmp/base.sqlite")
>
> utext = SQLCustomType(
> type="text",
> native="text",
> encoder=(lambda x: x.encode("utf-8")),
> decoder=(lambda x: x.decode("utf-8"))
> )
>
> db.define_table('posts',
> Field('title', type=utext, default=""),
> Field('text', type=utext, default=""),
> Field('html', type=utext, default=""))
>
> Now I'm doing insert into this table:
>
> id = db.posts.insert(title=u"Один", text=u"Два", html=u"Три")
>
> This leads to following error:
>
>   File "/Users/stunpix/Projects/app/logic/posts.py", line 28, in save
> id = db.posts.insert(title=u"Один", text=u"Два", html=u"Три")
>   File "/Users/stunpix/Projects/app/contrib/web2py/dal.py", line 6829, in 
> insert
> return self._db._adapter.insert(self,self._listify(fields))
>   File "/Users/stunpix/Projects/app/contrib/web2py/dal.py", line 928, in 
> insert
> raise e
> OperationalError: no such column: Два
>
> I did something wrong? Why value of "text" field was interpreted as 
> field's name?
>


[web2py] Re: DAL list:integer and postgresql integer array type

2012-06-04 Thread Lewis
Done. Thanks. 


Re: [web2py] Re: Trouble migrating databases

2012-06-04 Thread Ovidio Marinho
Waiting for news about the problem.



       Ovidio Marinho Falcao Neto
                Web Developer
             ovidio...@gmail.com
          ovidiomari...@itjp.net.br
                 ITJP - itjp.net.br
               83   8826 9088 - Oi
               83   9334 0266 - Claro
                        Brasil



2012/6/3 Massimo Di Pierro :
> Can you privately email me the model and the data you are trying import? I
> guess some recent patch must have broken the import.
>
>
> On Sunday, 3 June 2012 11:42:56 UTC-5, david.waldrop wrote:
>>
>> Massimo,  I am basically using the examples right form the book.  I am
>> deleting the local SQLlite database and the tables (now that I have a handle
>> on the migration stuff) and would like to copy the current postgress
>> production database to the local sqlite version.  I tried at 1st with
>> meeting monkey and noted the relationships between records in different
>> tables is not preserved. I also trued with COPSIS and have a similar
>> situation.  Does Import/Export know how to maintain relationships across
>> tables using the original primary and foreign keys?
>>
>>
>>
>> Code from book I am using ->
>>
>>
>>
>> def dumpdb():
>>
>>
>> #download(db.export_to_csv_file(open('c:/meetingmonkey_back_up.csv','w')))
>>
>>     import StringIO
>>
>>     s = StringIO.StringIO()
>>
>>     db.export_to_csv_file(s)
>>
>>     response.headers['Content-Type'] = 'text/csv'
>>
>>     return s.getvalue()
>>
>>
>>
>>
>>
>> def loaddb():
>>
>>     form = FORM(INPUT(_type='file', _name='data'), INPUT(_type='submit'))
>>
>>     if form.process(session=None).accepted:
>>
>>     db.import_from_csv_file(form.vars.data.file,unique=False)
>>
>>     # for every table
>>
>>     #for table in db.tables:
>>
>>     #    # for every uuid, delete all but the latest
>>
>>     #    items = db(db[table]).select(db[table].id,
>>
>>     #   db[table].uuid,
>>
>>     #   orderby=db[table].modified_on,
>>
>>     #   groupby=db[table].uuid)
>>
>>     #    for item in items:
>>
>>     #    db((db[table].uuid==item.uuid)&\
>>
>>     #   (db[table].id!=item.id)).delete()
>>
>>     return dict(form=form)
>>
>>
>>
>> From: web2py@googlegroups.com [mailto:web2py@googlegroups.com] On Behalf
>> Of Massimo Di Pierro
>> Sent: Sunday, June 03, 2012 12:11 PM
>> To: web2py@googlegroups.com
>> Subject: [web2py] Re: Trouble migrating databases
>>
>>
>>
>> Hello David,
>>
>>
>>
>> glad to know this was resolved. I was looking into it on my side and I do
>> not know what may have caused it. My guess is that you had migrations off,
>> you upgraded and auth needed to add some fields but migrations where off.
>> What happened after that I do not know.
>>
>>
>>
>> About export/import. Are you doing it for one table at the time or for all
>> tables are once? Can you show us some code?
>>
>>
>>
>> Massimo
>>
>> On Sunday, 3 June 2012 09:45:00 UTC-5, david.waldrop wrote:
>>
>> Some minor breakthru.  I have fixed "most" (that I know of)  of the
>> migration errors - Manually.
>>
>> I was successful at using the DAL option fake_migrate_all = True and
>> migrate_enabled = True which created some of the *.Table files - (but not
>> all, also this did not seem to do anything to help except for refresh the
>> SQL.LOG)
>>
>> I then compared the structure in the SQL.LOG file to each table and added
>> some missing fields directly to the sqllite database using a slqlite editor.
>>
>> I am back to where I need to be on the migration, but have no real idea
>> what went wrong or if it will happen again. Needless to say this should be
>> less complex and more transparent - even better if it "JUST WORKS, ALL THE
>> TIME"
>>
>>
>>
>> One open question remains about Export_to_CSV,and import_from_CSV screwing
>> up the relationships between records.any insight would be much
>> appreciated
>>
>>
>>
>>


[web2py] SQLFORM for keyed table

2012-06-04 Thread obad hemaily

Can I insert data with SQLFORM at keyed table 
the table in postgresql db
the table created with web2py


[web2py] SQLFORM for keyed tables

2012-06-04 Thread obad hemaily
I work with postgresql database.

I have a keyed table, how can I insert at table with SQLFORM




[web2py] Error when inserting SQLCustomType

2012-06-04 Thread Alexander Shashkevych

Hi,

 I got strange error when tried to use SQLCustomType. I'm trying to create 
custom type which will handle unicode<->utf8 conversions. Since DB stores 
in utf8, but my app uses unicode, so I tried to create custom type which 
handles such conversions. Here is my code:

db = DAL("sqlite:tmp/base.sqlite")

utext = SQLCustomType(
type="text",
native="text",
encoder=(lambda x: x.encode("utf-8")),
decoder=(lambda x: x.decode("utf-8"))
)

db.define_table('posts',
Field('title', type=utext, default=""),
Field('text', type=utext, default=""),
Field('html', type=utext, default=""))

Now I'm doing insert into this table:

id = db.posts.insert(title=u"Один", text=u"Два", html=u"Три")

This leads to following error:

  File "/Users/stunpix/Projects/app/logic/posts.py", line 28, in save
id = db.posts.insert(title=u"Один", text=u"Два", html=u"Три")
  File "/Users/stunpix/Projects/app/contrib/web2py/dal.py", line 6829, in 
insert
return self._db._adapter.insert(self,self._listify(fields))
  File "/Users/stunpix/Projects/app/contrib/web2py/dal.py", line 928, in 
insert
raise e
OperationalError: no such column: Два

I did something wrong? Why value of "text" field was interpreted as field's 
name?


[web2py] Re: what do you think about waitress webserver

2012-06-04 Thread pbreit
Well that's a problem and supports my initial intuition. I'm not sure how 
it can be considered "production-ready" without SSL.


On Monday, June 4, 2012 1:21:10 PM UTC-7, Anthony wrote:
>
> No SSL, though.
>
> On Monday, June 4, 2012 4:12:16 PM UTC-4, pbreit wrote:
>>
>> Ordinarily I would not think much of it but it actually looks interesting 
>> considering it is pure Python, supposedly production ready and "very 
>> acceptable performance".
>>
>>
>> On Monday, June 4, 2012 7:03:11 AM UTC-7, Vasile Ermicioi wrote:
>>>
>>> hi, 
>>> what do you think about waitress webserver?
>>>
>>> http://docs.pylonsproject.org/projects/waitress/en/latest/ 
>>>
>>>
>>>

[web2py] Re: HTML in context_dict for sending mails

2012-06-04 Thread howesc
are you sending the string as the HTML part of the email:

send(to=customer.email,
 subject="Plain text subject",
 message=(text_message, html_message)


both my messages are from response.render (and neither sent through XML()).

cfh


On Monday, June 4, 2012 7:52:07 AM UTC-7, Sushant Taneja wrote:
>
> Hi All,
>
> I have a string var containing some HTML code
>
> links = "user_a"
> I am passing this variable to response.render function as: 
>
> context_dict = dict(links=links)
> message = response.render("invite_friend.html",context_dict)
>
> # Send mail code below
>
> In invite_friend.html I have the code:
>
> 
> Hello there, 
> 
> {{=links}}
> 
> 
>
> When the mail is sent, the email message is rendered as below:
>
> Hello there, 
> user_a
>
> instead of
>
> Hello there,
>
>- user_a 
>
>
> How to render the above mail properly ?? I am working on GAE and 
> mail.settings.server is set to 'gae'
>
>

Re: [web2py] MailCaptcha

2012-06-04 Thread szimszon
There is now a honeypot address handling to put sender directly in to 
blacklist.


   1. somebody send you an email from someb...@domain.com
   2. postfix ask MailCaptcha what to do
   - if the recipient address is not in the protected list do nothing 
  special
  - else if the sender is in the blacklist reject the message with 5xx 
  code
  - else if the recipient address is a honeypot address put the sender 
  in the blacklist and reject the message with 5xx code
  - else if the sender is in the whitelist do nothing special
  - else if the sender is in the waiting queue the message get a 
  temporary rejection with 4xx code
  - else if the sender is not in queue then
 - put the sender address in the waiting queue
 - send a mail to the sender address with the web url where the 
 sender can solve the captcha and so the sender address is going to the 
 whitelist
 - optionally send a mail to mail system admin to notify about a 
 new sender address in the waiting queue so admin can enable the sender 
 address by hand
  3. the sender have to go to the web url and solve the captcha
   4. sender address is going to the whitelist
   5. the next time the sender's mail system (the system that hold the 
   sender's mail) try to deliver the e-mail after temporary failure can 
   deliver the message without problem
   
 


[web2py] Re: I have trouble with the new scheduler and mysql: NotSupportedError

2012-06-04 Thread szimszon
Thank you!

2012. június 4., hétfő 22:00:54 UTC+2 időpontban Niphlod a következőt írta:
>
> patched and ready for new testing..
> Thank you for your patience szimszon 
>
> Niphlod
>


[web2py] Re: Forms in multiple windows

2012-06-04 Thread Massimo Di Pierro
Yes, this may work.


On Monday, 4 June 2012 15:36:34 UTC-5, Anthony wrote:
>
> Massimo pointed out a flaw in my solution in that it would create an
>> ever-growing number of session variables and would be vulnerable to a DoS
>> attack.
>>
>
> Maybe by default it could cycle through a small number of formnames (e.g., 
> _formname = _formname + '_1', etc.). So, for any given base _formname, 
> there could be up to, say, 5 distinct formnames in the session, which would 
> allow the user to open a handful of browser windows and be able to submit 
> from any of them.
>
> Anthony
>


[web2py] Re: Connecting to Firebird

2012-06-04 Thread Massimo Di Pierro
Sorry I misunderstood. My guess is that you have different python version. 
make sure you run web2py from source and you use the python version where 
you installed  kinterbasdb.

On Monday, 4 June 2012 15:27:29 UTC-5, pjag wrote:
>
> Massimo,
>
> Thanks for the reply  I've already installed kinterbasdb, as I mentioned 
> in my original message.  I can access Firebird with kinterbasdb in a simple 
> Python script.  However, web2py doesn't see it.  Correct me if I'm wrong, 
> because I've barely scratched the surface with the web2py documentation, 
> but isn't Python 2.5 built into web2py?  If so, might that be my problem? 
>  I've installed the kinterbasdb package in my Python 2.7 install, but not 
> web2py?  I'm confused, since the web2py docs say there's built-in DB 
> support for multiple databases, including Firebird.  I was hoping Firebird 
> access in web2py would be "baked in", and not give me the problem I'm 
> experiencing.
>
>
> On Monday, June 4, 2012 3:51:59 PM UTC-4, Massimo Di Pierro wrote:
>>
>> You need to install this driver before you can use firebird from python:
>>
>> http://kinterbasdb.sourceforge.net/
>>
>> On Monday, 4 June 2012 12:45:06 UTC-5, pjag wrote:
>>>
>>> Greetings,
>>>
>>> Getting up to speed on web2py, and am trying to use Firebird as my DB. 
>>>  When I start my web2py app, I get the following error message:
>>>
>>>  Failure to connect, tried 5 times: 
>>> Traceback (most recent call last): File "gluon/dal.py", line 5955, in 
>>> __init__ File "gluon/dal.py", line 2449, in __init__ NameError: global name 
>>> 'kinterbasdb' is not defined
>>>
>>> Here's my connection code in db.py:
>>>
>>>  db = 
>>> DAL('firebird://sysdba:masterkey@localhost:3050/C:\\web2py\\applications\\myapp\\myappdb.fdb')
>>>
>>> I'm using Python 2.7.3 x64 (Win7), web2py 1.99.7, Firebird 2.5.1 x64.  I 
>>> installed kinterbasdb 3.3 manually (doesn't it get installed with web2py?), 
>>> but still have the same error.
>>>
>>> Help please!
>>>
>>>
>>>

[web2py] Re: Forms in multiple windows

2012-06-04 Thread Anthony

>
> Massimo pointed out a flaw in my solution in that it would create an
> ever-growing number of session variables and would be vulnerable to a DoS
> attack.
>

Maybe by default it could cycle through a small number of formnames (e.g., 
_formname = _formname + '_1', etc.). So, for any given base _formname, 
there could be up to, say, 5 distinct formnames in the session, which would 
allow the user to open a handful of browser windows and be able to submit 
from any of them.

Anthony


[web2py] Re: Connecting to Firebird

2012-06-04 Thread pjag
Massimo,

Thanks for the reply  I've already installed kinterbasdb, as I mentioned in 
my original message.  I can access Firebird with kinterbasdb in a simple 
Python script.  However, web2py doesn't see it.  Correct me if I'm wrong, 
because I've barely scratched the surface with the web2py documentation, 
but isn't Python 2.5 built into web2py?  If so, might that be my problem? 
 I've installed the kinterbasdb package in my Python 2.7 install, but not 
web2py?  I'm confused, since the web2py docs say there's built-in DB 
support for multiple databases, including Firebird.  I was hoping Firebird 
access in web2py would be "baked in", and not give me the problem I'm 
experiencing.


On Monday, June 4, 2012 3:51:59 PM UTC-4, Massimo Di Pierro wrote:
>
> You need to install this driver before you can use firebird from python:
>
> http://kinterbasdb.sourceforge.net/
>
> On Monday, 4 June 2012 12:45:06 UTC-5, pjag wrote:
>>
>> Greetings,
>>
>> Getting up to speed on web2py, and am trying to use Firebird as my DB. 
>>  When I start my web2py app, I get the following error message:
>>
>>  Failure to connect, tried 5 times: 
>> Traceback (most recent call last): File "gluon/dal.py", line 5955, in 
>> __init__ File "gluon/dal.py", line 2449, in __init__ NameError: global name 
>> 'kinterbasdb' is not defined
>>
>> Here's my connection code in db.py:
>>
>>  db = 
>> DAL('firebird://sysdba:masterkey@localhost:3050/C:\\web2py\\applications\\myapp\\myappdb.fdb')
>>
>> I'm using Python 2.7.3 x64 (Win7), web2py 1.99.7, Firebird 2.5.1 x64.  I 
>> installed kinterbasdb 3.3 manually (doesn't it get installed with web2py?), 
>> but still have the same error.
>>
>> Help please!
>>
>>
>>

[web2py] Re: Sending Emails to all my users in one time

2012-06-04 Thread Anthony

>
> emails = db(db.auth_user.id>0).select(db.auth_user.email).as_list()
>

.as_list() gives you a list of dictionaries. Instead, maybe:

emails = [r.email for r in db().select(db.auth_user.email)]

Anthony


[web2py] Re: what do you think about waitress webserver

2012-06-04 Thread Anthony
No SSL, though.

On Monday, June 4, 2012 4:12:16 PM UTC-4, pbreit wrote:
>
> Ordinarily I would not think much of it but it actually looks interesting 
> considering it is pure Python, supposedly production ready and "very 
> acceptable performance".
>
>
> On Monday, June 4, 2012 7:03:11 AM UTC-7, Vasile Ermicioi wrote:
>>
>> hi, 
>> what do you think about waitress webserver?
>>
>> http://docs.pylonsproject.org/projects/waitress/en/latest/ 
>>
>>
>>

[web2py] Re: Using components via LOAD with conditional models is not working

2012-06-04 Thread Anthony

>
> Aw crap. And I thought I had tried that. 
>
> setting ajax=True does indeed work... I'm guessing that it's because it 
> creates a separate request whereas load without ajax uses the current value 
> of request.controller to decide which models to execute.
>

You're on the right track, but that's not quite the problem. LOAD without 
Ajax does use the proper controller -- the problem is that it does not 
re-execute the models. Instead, it simply executes the LOAD controller 
using the current model environment (with modified request and response 
objects) -- see 
http://code.google.com/p/web2py/source/browse/gluon/compileapp.py#203.

We've talked about having non-Ajax components re-execute the models (which 
would obviously be necessary to handle conditional models properly), but I 
think Massimo is not too happy with non-Ajax components anyway (it gets 
pretty complicated figuring out all the subtleties to implement them 
properly), so the recommendation is to just use Ajax components.

Anthony 


[web2py] Re: what do you think about waitress webserver

2012-06-04 Thread pbreit
Ordinarily I would not think much of it but it actually looks interesting 
considering it is pure Python, supposedly production ready and "very 
acceptable performance".


On Monday, June 4, 2012 7:03:11 AM UTC-7, Vasile Ermicioi wrote:
>
> hi, 
> what do you think about waitress webserver?
>
> http://docs.pylonsproject.org/projects/waitress/en/latest/ 
>
>
>

[web2py] Re: Sending Emails to all my users in one time

2012-06-04 Thread pbreit
Maybe:

emails = db(db.auth_user.id>0).select(db.auth_user.email).as_list()
mail.send(bcc=emails, subject='Subject', message='Message.')


On Monday, June 4, 2012 8:03:58 AM UTC-7, Hassan Alnatour wrote:
>
> Dear ALL , 
>
> How can i send all the users i have in my auth_users  an email at once ?\
>
> regards,
>


[web2py] Re: Using components via LOAD with conditional models is not working

2012-06-04 Thread pbreit
Some have gone so far to say "premature optimization is the root of all 
evil". I'm not quite in that camp but I do believe optimizations can and 
should generally wait. And for exact the reason exhibited here: they can 
make simple things complicated and hard to troubleshoot/fix.

I think the "load all models on every request" issue is a little overblown. 
I think you need 50+ tables before it becomes perceptible to end-users.


On Monday, June 4, 2012 12:23:59 PM UTC-7, anonymouse wrote:
>
> Aw crap. And I thought I had tried that. 
>
> setting ajax=True does indeed work... I'm guessing that it's because it 
> creates a separate request whereas load without ajax uses the current value 
> of request.controller to decide which models to execute.
>
> Anyway, problem solved. Thanks pbreit!
>
> Also, why, if I may ask, do you advise against conditional models or 
> 'premature optimization' as you put it? I guess there's the argument "if it 
> ain't broke, don't fix it". 
>
> The thing is I do some database queries within the conditional models file 
> (I omitted this in my example) which I don't think should run on every page 
> load, especially since this particular database is accessed by several 
> applications. Perhaps its still premature (the db traffic is low for now... 
> but that db is brand new and apps haven't been modified to use it as 
> opposed to LDAP). 
>
> On Monday, 4 June 2012 14:13:24 UTC-5, pbreit wrote:
>>
>> Hmmm...I would have expected a LOAD(...ajax=True) to trigger conditional 
>> models properly.
>>
>> Not the answer you're looking for but I very strongly advise against 
>> premature optimization (ie, conditional models).
>>
>>
>> On Monday, June 4, 2012 12:01:17 PM UTC-7, anonymouse wrote:
>>>
>>> Hi all,
>>>
>>> I'm having an issue trying to load a component that relies on 
>>> conditionally loaded models.
>>>
>>> It appears that either the conditional model file is not 
>>> executed/evaluated using the LOAD function.
>>>
>>> The following files are relevant to this issue:
>>>
>>> models/people/personnel.py
>>> controllers/people.py
>>> controllers/contact.py
>>> views/contact/index.html
>>> views/people/index.html
>>>
>>>
>>> The quick solution would clearly be to take the conditional model out of 
>>> "people" so that it is available to the "contact" controller, but I was 
>>> wondering if there were any another solutions which allow the "people" 
>>> model file to still be executed conditionally. 
>>>
>>> Perhaps I would be better off putting the model in modules and having 
>>> the model/personnel.py file import the table definition from modules, and 
>>> add another import statement to the "contact" controller and any other 
>>> controllers outside of people that use personnel data (though at present, 
>>> contact is the ONLY one)?
>>>
>>> I would think that LOAD would execute the conditional model but perhaps 
>>> there is a good reason it does not? I could just be using components/LOAD 
>>> completely wrong, but if not then maybe this is a good candidate for a 
>>> feature request? 
>>>
>>> If anyone can shed some light on this issue, please, shed away! 
>>>
>>> Below are the parts my app that are relevant: 
>>>
>>> ### Models: models/people/personnel.py
>>> db.define_table('people',
>>>  Field(...) # Defines name, position, user-id -- this is NOT meant for 
>>> any sort of access control, just a list of people in our institution
>>>  ...
>>> )
>>>
>>>
>>> ### I have two controllers:
>>> # controller - people.py
>>> def index():
>>>   if request.args(0):
>>>  people = db(db.people.positition == request.args(0)).select()
>>>   else:
>>>  people = db(db.people).select()
>>>   return dict(people=people)
>>>
>>> # contact.py
>>> def index():
>>> ... build contact form, do form validation, etc ...
>>> return dict(form=form) 
>>>
>>> # and my contact view 
>>> # views/contact/index.html contains this LOAD statement:
>>> {{ = LOAD('people','index',args=['faculty']) }}
>>>
>>> When I attempt to view the page /app/contact/index
>>>
>>> I get the error:
>>>   KeyError: people
>>>
>>> The error is of course generated in the 2nd line of the people.py index 
>>> function.
>>>
>>> When I attempt to view /app/people/index everything works perfectly. 
>>>
>>> Can I use LOAD with conditional models?
>>>
>>

Re: [web2py] Re: Web2py execution blocking

2012-06-04 Thread Jan Rozhon
Yea, it is sqlite db. May it cause the trouble? Thanks Jan.

Dne pondělí, 4. června 2012 21:53:20 UTC+2 mcm napsal(a):
>
> @Jan 
>
> are you using sqlite? 
>
> mic 
>
>
> 2012/6/4 Massimo Di Pierro : 
> > I do not know what may be causing it, except that: 
> > 
> > - one ajax/json call is better than many 
> > - each call will lock the session for the use which means they are not 
> > executed concurrently, they are queued, unless you 
> > session._unlock(response). 
> > 
> > 
> > 
> > On Monday, 4 June 2012 11:02:23 UTC-5, Jan Rozhon wrote: 
> >> 
> >> Hi Massimo, 
> >> 
> >> thank you for your answer. Unfortunately, it didnt help. One thing I 
> >> didn't mention and might be causing this trouble is, that I ask for 
> several 
> >> json values provided by similar controllers as I posted in my first 
> post. 
> >> Can the multitude ofjson requests cause this weird behaviour? In other 
> >> words, is it better to provide several small json streams or one large? 
> >> 
> >> Thanks in advance, Jan 
> >> 
> >> Dne pondělí, 4. června 2012 17:38:41 UTC+2 Massimo Di Pierro napsal(a): 
> >>> 
> >>> Try replace output=rows with output=rows.as_list() 
> >>> Perhaps the rows are not json serializable. 
> >>> 
> >>> On Monday, 4 June 2012 02:20:39 UTC-5, Jan Rozhon wrote: 
>  
>  Hi group, I have encountered a problem when I try to call a 
> controller 
>  which should return a JSON array of values from database. However in 
> abou 1 
>  of 5 cases this call stucks in "loading" phase (chrome animation in 
> tab) and 
>  no response is received. Data is in database, every other controller 
> is 
>  working fine, cpu utilization is pretty low so is the memory and 
> there are 
>  only about 1 rows in DB. Could you please give me some hints? 
>  
>  Thanks, Jan 
>  
>  PS. The controller looks like this: 
>  
>  def dberrorsselect(): 
>  """Performs sql query to get the errors in the form of list of 
> dicts 
>  such as {field_name:value}. This is then transformed to json dict for 
>  transfer.""" 
>  if session.tb_id: 
>  
>  
> max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
>  
>
>  if max_id != None: 
>  selector_id=int(max_id)-5 
>  else: 
>  selector_id=0 
>  rows=tb((tb.errors.test_id==session.tb_id)&(tb.errors.id > 
>  selector_id)).select(tb.errors.ts, tb.errors.msg_short, 
> tb.errors.msg_long) 
>  output=rows 
>  else: 
>  output=[] 
>  return dict(output=output) 
>  
>  
> > 
>


Re: [web2py] Re: best practices for displaying a a subset of a tables columns?

2012-06-04 Thread Richard Vézina
Yes it works, but I think lambda: has_membership is much better approach as
pointed by Anthony as more fast since the lambda is only hit when you
really want to access the records...

Richard

On Mon, Jun 4, 2012 at 4:00 PM, pbreit  wrote:

> I might not quite understand the question but wouldn't readable/writable
> work?
>
>
> On Monday, June 4, 2012 5:56:40 AM UTC-7, bob wrote:
>>
>>
>> In the old days I would just create a database view on a subset of a
>> table that I wanted to allow other developers to access (assuming read
>> only),  however I'm not sure if that's the best thing to do with web2py.
>>
>> I have a table that has:
>>
>> last_name
>> first_name
>> etc
>> including some 'internal' columns that I don't want to expose on any form
>> or service.
>>
>> Any thoughts on the best way to implement this?
>>
>> I'm thinking:
>>
>> a:   database view (postgresql in this case),  issues being no 'id' in
>> the view and I'm not sure how best to maintain that.
>>
>> b:   a new .py that takes the full record and returns the subset.
>> upside - it would be a single point of maintenance,  question is where
>> would this live  (in the models, it's not a controller so it doesn't really
>> fit there)?
>>
>> c:  ??
>>
>> thanks for any suggestions,
>> bobm
>>
>>


[web2py] Re: Web2py execution blocking

2012-06-04 Thread Jan Rozhon
Ok, I have redesigned the page so that there is only one json call every 5 
seconds instead of 3. It looks better, 4 from 4 trials were ok . Previously 
I have never achieved 3 consecutive successful trials, so there is an 
improvement,  but I am not certain that the problem is really gone. I will 
do some more testing a write to the thread.
Again, thank you Massimo.

Dne pondělí, 4. června 2012 21:50:20 UTC+2 Massimo Di Pierro napsal(a):
>
> I do not know what may be causing it, except that:
>
> - one ajax/json call is better than many
> - each call will lock the session for the use which means they are not 
> executed concurrently, they are queued, unless you 
> session._unlock(response).
>
>
>
> On Monday, 4 June 2012 11:02:23 UTC-5, Jan Rozhon wrote:
>>
>> Hi Massimo,
>>
>> thank you for your answer. Unfortunately, it didnt help. One thing I 
>> didn't mention and might be causing this trouble is, that I ask for several 
>> json values provided by similar controllers as I posted in my first post. 
>> Can the multitude ofjson requests cause this weird behaviour? In other 
>> words, is it better to provide several small json streams or one large?
>>
>> Thanks in advance, Jan
>>
>> Dne pondělí, 4. června 2012 17:38:41 UTC+2 Massimo Di Pierro napsal(a):
>>>
>>> Try replace output=rows with output=rows.as_list()
>>> Perhaps the rows are not json serializable.
>>>
>>> On Monday, 4 June 2012 02:20:39 UTC-5, Jan Rozhon wrote:

 Hi group, I have encountered a problem when I try to call a controller 
 which should return a JSON array of values from database. However in abou 
 1 
 of 5 cases this call stucks in "loading" phase (chrome animation in tab) 
 and no response is received. Data is in database, every other controller 
 is 
 working fine, cpu utilization is pretty low so is the memory and there are 
 only about 1 rows in DB. Could you please give me some hints?

 Thanks, Jan

 PS. The controller looks like this:

 def dberrorsselect():
 """Performs sql query to get the errors in the form of list of 
 dicts such as {field_name:value}. This is then transformed to json dict 
 for 
 transfer."""
 if session.tb_id:
 
 max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
 if max_id != None:
 selector_id=int(max_id)-5
 else:
 selector_id=0
 rows=tb((tb.errors.test_id==session.tb_id)&(tb.errors.id > 
 selector_id)).select(tb.errors.ts, tb.errors.msg_short, tb.errors.msg_long)
 output=rows
 else:
 output=[] 
 return dict(output=output)




[web2py] Re: I have trouble with the new scheduler and mysql: NotSupportedError

2012-06-04 Thread Niphlod
patched and ready for new testing..
Thank you for your patience szimszon 

Niphlod


[web2py] Re: best practices for displaying a a subset of a tables columns?

2012-06-04 Thread pbreit
I might not quite understand the question but wouldn't readable/writable 
work?


On Monday, June 4, 2012 5:56:40 AM UTC-7, bob wrote:
>
>
> In the old days I would just create a database view on a subset of a table 
> that I wanted to allow other developers to access (assuming read only),  
> however I'm not sure if that's the best thing to do with web2py.
>
> I have a table that has:
>
> last_name
> first_name
> etc
> including some 'internal' columns that I don't want to expose on any form 
> or service.
>
> Any thoughts on the best way to implement this?
>
> I'm thinking:
>
> a:   database view (postgresql in this case),  issues being no 'id' in the 
> view and I'm not sure how best to maintain that.
>
> b:   a new .py that takes the full record and returns the subset.   upside 
> - it would be a single point of maintenance,  question is where would this 
> live  (in the models, it's not a controller so it doesn't really fit there)?
>
> c:  ??
>
> thanks for any suggestions,
> bobm
>
>

[web2py] Re: For all users using web2py editor on Firefox: solution to the "blurry" or "ghosty" text

2012-06-04 Thread Anthony
There's a new editor in trunk -- not sure if it's in stable yet. Perhaps 
the new editor won't have this problem in Firefox.

Anthony

On Monday, June 4, 2012 3:36:55 PM UTC-4, sesenmaister wrote:
>
>  When using the web2py editor on firefox, text gets 1 pixel fatter, and 
> makes the sensation of being blurry. I've got friends that seem comfortable 
> with this little effect. But it disturbed me a lot, and therefore I went to 
> Chrome, where the text appears just how it must. And I was some upset, 
> because of that. 
>
>  
>
> Taking a look to the css in Firebug, appears a class .hidden, with opacity 
> set to 0.2.
>
>  
>
> For the sake of hell thanks to the Greasemonkey plugin for firefox, that 
> permits using scripts things as the CSS for modifying web surfing.
>
>  
>
> Install plugin, and create a new user script:
>
>  
>
> Name: whatever_name
>
> Namespace:  whatever_unique_name
>
> Description: blablabla
>
>  
>
> here goes in wich webs we want the script to be running, so: 
>
> Includes:  http*/admin/default/edit/*
>
>  
>
> And then, add the magic words to the generated new script:
>
> document.getElementById('textarea').style.opacity = "0";
>
>  
>
>  
>
> I was very upset. I like firefox, and I hate been forced to change to 
> another browser. I seeked a lot and anything I found helped me. So I hope 
> this to be so helpful for others as it has been to me.
>
>  
>
> jsesen
>


Re: [web2py] Re: Web2py execution blocking

2012-06-04 Thread Michele Comitini
@Jan

are you using sqlite?

mic


2012/6/4 Massimo Di Pierro :
> I do not know what may be causing it, except that:
>
> - one ajax/json call is better than many
> - each call will lock the session for the use which means they are not
> executed concurrently, they are queued, unless you
> session._unlock(response).
>
>
>
> On Monday, 4 June 2012 11:02:23 UTC-5, Jan Rozhon wrote:
>>
>> Hi Massimo,
>>
>> thank you for your answer. Unfortunately, it didnt help. One thing I
>> didn't mention and might be causing this trouble is, that I ask for several
>> json values provided by similar controllers as I posted in my first post.
>> Can the multitude ofjson requests cause this weird behaviour? In other
>> words, is it better to provide several small json streams or one large?
>>
>> Thanks in advance, Jan
>>
>> Dne pondělí, 4. června 2012 17:38:41 UTC+2 Massimo Di Pierro napsal(a):
>>>
>>> Try replace output=rows with output=rows.as_list()
>>> Perhaps the rows are not json serializable.
>>>
>>> On Monday, 4 June 2012 02:20:39 UTC-5, Jan Rozhon wrote:

 Hi group, I have encountered a problem when I try to call a controller
 which should return a JSON array of values from database. However in abou 1
 of 5 cases this call stucks in "loading" phase (chrome animation in tab) 
 and
 no response is received. Data is in database, every other controller is
 working fine, cpu utilization is pretty low so is the memory and there are
 only about 1 rows in DB. Could you please give me some hints?

 Thanks, Jan

 PS. The controller looks like this:

 def dberrorsselect():
     """Performs sql query to get the errors in the form of list of dicts
 such as {field_name:value}. This is then transformed to json dict for
 transfer."""
     if session.tb_id:

 max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
         if max_id != None:
             selector_id=int(max_id)-5
         else:
             selector_id=0
         rows=tb((tb.errors.test_id==session.tb_id)&(tb.errors.id >
 selector_id)).select(tb.errors.ts, tb.errors.msg_short, tb.errors.msg_long)
         output=rows
     else:
         output=[]
     return dict(output=output)


>


[web2py] Re: Connecting to Firebird

2012-06-04 Thread Massimo Di Pierro
You need to install this driver before you can use firebird from python:

http://kinterbasdb.sourceforge.net/

On Monday, 4 June 2012 12:45:06 UTC-5, pjag wrote:
>
> Greetings,
>
> Getting up to speed on web2py, and am trying to use Firebird as my DB. 
>  When I start my web2py app, I get the following error message:
>
>  Failure to connect, tried 5 times: 
> Traceback (most recent call last): File "gluon/dal.py", line 5955, in 
> __init__ File "gluon/dal.py", line 2449, in __init__ NameError: global name 
> 'kinterbasdb' is not defined
>
> Here's my connection code in db.py:
>
>  db = 
> DAL('firebird://sysdba:masterkey@localhost:3050/C:\\web2py\\applications\\myapp\\myappdb.fdb')
>
> I'm using Python 2.7.3 x64 (Win7), web2py 1.99.7, Firebird 2.5.1 x64.  I 
> installed kinterbasdb 3.3 manually (doesn't it get installed with web2py?), 
> but still have the same error.
>
> Help please!
>
>
>

[web2py] Re: Web2py execution blocking

2012-06-04 Thread Massimo Di Pierro
I do not know what may be causing it, except that:

- one ajax/json call is better than many
- each call will lock the session for the use which means they are not 
executed concurrently, they are queued, unless you 
session._unlock(response).



On Monday, 4 June 2012 11:02:23 UTC-5, Jan Rozhon wrote:
>
> Hi Massimo,
>
> thank you for your answer. Unfortunately, it didnt help. One thing I 
> didn't mention and might be causing this trouble is, that I ask for several 
> json values provided by similar controllers as I posted in my first post. 
> Can the multitude ofjson requests cause this weird behaviour? In other 
> words, is it better to provide several small json streams or one large?
>
> Thanks in advance, Jan
>
> Dne pondělí, 4. června 2012 17:38:41 UTC+2 Massimo Di Pierro napsal(a):
>>
>> Try replace output=rows with output=rows.as_list()
>> Perhaps the rows are not json serializable.
>>
>> On Monday, 4 June 2012 02:20:39 UTC-5, Jan Rozhon wrote:
>>>
>>> Hi group, I have encountered a problem when I try to call a controller 
>>> which should return a JSON array of values from database. However in abou 1 
>>> of 5 cases this call stucks in "loading" phase (chrome animation in tab) 
>>> and no response is received. Data is in database, every other controller is 
>>> working fine, cpu utilization is pretty low so is the memory and there are 
>>> only about 1 rows in DB. Could you please give me some hints?
>>>
>>> Thanks, Jan
>>>
>>> PS. The controller looks like this:
>>>
>>> def dberrorsselect():
>>> """Performs sql query to get the errors in the form of list of dicts 
>>> such as {field_name:value}. This is then transformed to json dict for 
>>> transfer."""
>>> if session.tb_id:
>>> 
>>> max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
>>> if max_id != None:
>>> selector_id=int(max_id)-5
>>> else:
>>> selector_id=0
>>> rows=tb((tb.errors.test_id==session.tb_id)&(tb.errors.id > 
>>> selector_id)).select(tb.errors.ts, tb.errors.msg_short, tb.errors.msg_long)
>>> output=rows
>>> else:
>>> output=[] 
>>> return dict(output=output)
>>>
>>>
>>>

[web2py] For all users using web2py editor on Firefox: solution to the "blurry" or "ghosty" text

2012-06-04 Thread sesenmaister
 

 When using the web2py editor on firefox, text gets 1 pixel fatter, and 
makes the sensation of being blurry. I've got friends that seem comfortable 
with this little effect. But it disturbed me a lot, and therefore I went to 
Chrome, where the text appears just how it must. And I was some upset, 
because of that. 

 

Taking a look to the css in Firebug, appears a class .hidden, with opacity 
set to 0.2.

 

For the sake of hell thanks to the Greasemonkey plugin for firefox, that 
permits using scripts things as the CSS for modifying web surfing.

 

Install plugin, and create a new user script:

 

Name: whatever_name

Namespace:  whatever_unique_name

Description: blablabla

 

here goes in wich webs we want the script to be running, so: 

Includes:  http*/admin/default/edit/*

 

And then, add the magic words to the generated new script:

document.getElementById('textarea').style.opacity = "0";

 

 

I was very upset. I like firefox, and I hate been forced to change to 
another browser. I seeked a lot and anything I found helped me. So I hope 
this to be so helpful for others as it has been to me.

 

jsesen


[web2py] Forms in multiple windows

2012-06-04 Thread Jim Karsten
Could we get a discussion going about web2py handling forms in multiple 
windows? A form may not submit as expected if a second window or tab is 
opened with the same form. Here are steps to reproduce the issue.

1. Create a page with a form. The form can be created by Crud or SQLFORM.
2. Open the page in a window. Open the page in a second window.
3. Submit the form in the second window. This works fine.
4. Go back to the first window. Submit the form. The input is not saved.

I produced a ticket for this problem (Issue 825 
http://code.google.com/p/web2py/issues/detail?id=825) with a suggestion for 
a solution based on the discussion in this thread: 
https://groups.google.com/d/topic/web2py/X-GGxuvea-g/discussion

Massimo pointed out a flaw in my solution in that it would create an
ever-growing number of session variables and would be vulnerable to a DoS
attack.

While maybe not a common problem, opening a page in a second window does 
not seem to be something all that unusual. Should web2py forms be expected 
to handle this? 


[web2py] For all users using web2py editor on Firefox: solution to the "blurry" or "ghosty" text

2012-06-04 Thread sesenmaister
 When using the web2py editor on firefox, text gets 1 pixel fatter, and 
makes the sensation of being blurry. I've got friends that seem comfortable 
with this little effect. But it disturbed me a lot, and therefore I went to 
Chrome, where the text appears just how it must. And I was some upset, 
because of that. 

Taking a look to the css in Firebug, appears a class .hidden, with opacity 
set to 0.2.

For the sake of hell thanks to the *Greasemonkey plugin for firefox*, that 
permits using scripts things as the CSS for modifying web surfing.

Install plugin, and create a new user script:

*Name*: whatever_name
*Namespace*:  whatever_unique_name
*Description*: blablabla

here goes in wich webs we want the script to be running, so: 
*Includes*:  http*/admin/default/edit/*

And then, add the magic words to the generated new script:
document.getElementById('textarea').style.opacity = "0";


I was very upset. I like firefox, and I hate been forced to change to 
another browser. I seeked a lot and anything I found helped me. So I hope 
this to be so helpful for others as it has been to me.

jsesen






[web2py] Re: Using components via LOAD with conditional models is not working

2012-06-04 Thread anonymouse
Aw crap. And I thought I had tried that. 

setting ajax=True does indeed work... I'm guessing that it's because it 
creates a separate request whereas load without ajax uses the current value 
of request.controller to decide which models to execute.

Anyway, problem solved. Thanks pbreit!

Also, why, if I may ask, do you advise against conditional models or 
'premature optimization' as you put it? I guess there's the argument "if it 
ain't broke, don't fix it". 

The thing is I do some database queries within the conditional models file 
(I omitted this in my example) which I don't think should run on every page 
load, especially since this particular database is accessed by several 
applications. Perhaps its still premature (the db traffic is low for now... 
but that db is brand new and apps haven't been modified to use it as 
opposed to LDAP). 

On Monday, 4 June 2012 14:13:24 UTC-5, pbreit wrote:
>
> Hmmm...I would have expected a LOAD(...ajax=True) to trigger conditional 
> models properly.
>
> Not the answer you're looking for but I very strongly advise against 
> premature optimization (ie, conditional models).
>
>
> On Monday, June 4, 2012 12:01:17 PM UTC-7, anonymouse wrote:
>>
>> Hi all,
>>
>> I'm having an issue trying to load a component that relies on 
>> conditionally loaded models.
>>
>> It appears that either the conditional model file is not 
>> executed/evaluated using the LOAD function.
>>
>> The following files are relevant to this issue:
>>
>> models/people/personnel.py
>> controllers/people.py
>> controllers/contact.py
>> views/contact/index.html
>> views/people/index.html
>>
>>
>> The quick solution would clearly be to take the conditional model out of 
>> "people" so that it is available to the "contact" controller, but I was 
>> wondering if there were any another solutions which allow the "people" 
>> model file to still be executed conditionally. 
>>
>> Perhaps I would be better off putting the model in modules and having the 
>> model/personnel.py file import the table definition from modules, and add 
>> another import statement to the "contact" controller and any other 
>> controllers outside of people that use personnel data (though at present, 
>> contact is the ONLY one)?
>>
>> I would think that LOAD would execute the conditional model but perhaps 
>> there is a good reason it does not? I could just be using components/LOAD 
>> completely wrong, but if not then maybe this is a good candidate for a 
>> feature request? 
>>
>> If anyone can shed some light on this issue, please, shed away! 
>>
>> Below are the parts my app that are relevant: 
>>
>> ### Models: models/people/personnel.py
>> db.define_table('people',
>>  Field(...) # Defines name, position, user-id -- this is NOT meant for 
>> any sort of access control, just a list of people in our institution
>>  ...
>> )
>>
>>
>> ### I have two controllers:
>> # controller - people.py
>> def index():
>>   if request.args(0):
>>  people = db(db.people.positition == request.args(0)).select()
>>   else:
>>  people = db(db.people).select()
>>   return dict(people=people)
>>
>> # contact.py
>> def index():
>> ... build contact form, do form validation, etc ...
>> return dict(form=form) 
>>
>> # and my contact view 
>> # views/contact/index.html contains this LOAD statement:
>> {{ = LOAD('people','index',args=['faculty']) }}
>>
>> When I attempt to view the page /app/contact/index
>>
>> I get the error:
>>   KeyError: people
>>
>> The error is of course generated in the 2nd line of the people.py index 
>> function.
>>
>> When I attempt to view /app/people/index everything works perfectly. 
>>
>> Can I use LOAD with conditional models?
>>
>

[web2py] Re: Using components via LOAD with conditional models is not working

2012-06-04 Thread pbreit
Hmmm...I would have expected a LOAD(...ajax=True) to trigger conditional 
models properly.

Not the answer you're looking for but I very strongly advise against 
premature optimization (ie, conditional models).


On Monday, June 4, 2012 12:01:17 PM UTC-7, anonymouse wrote:
>
> Hi all,
>
> I'm having an issue trying to load a component that relies on 
> conditionally loaded models.
>
> It appears that either the conditional model file is not 
> executed/evaluated using the LOAD function.
>
> The following files are relevant to this issue:
>
> models/people/personnel.py
> controllers/people.py
> controllers/contact.py
> views/contact/index.html
> views/people/index.html
>
>
> The quick solution would clearly be to take the conditional model out of 
> "people" so that it is available to the "contact" controller, but I was 
> wondering if there were any another solutions which allow the "people" 
> model file to still be executed conditionally. 
>
> Perhaps I would be better off putting the model in modules and having the 
> model/personnel.py file import the table definition from modules, and add 
> another import statement to the "contact" controller and any other 
> controllers outside of people that use personnel data (though at present, 
> contact is the ONLY one)?
>
> I would think that LOAD would execute the conditional model but perhaps 
> there is a good reason it does not? I could just be using components/LOAD 
> completely wrong, but if not then maybe this is a good candidate for a 
> feature request? 
>
> If anyone can shed some light on this issue, please, shed away! 
>
> Below are the parts my app that are relevant: 
>
> ### Models: models/people/personnel.py
> db.define_table('people',
>  Field(...) # Defines name, position, user-id -- this is NOT meant for any 
> sort of access control, just a list of people in our institution
>  ...
> )
>
>
> ### I have two controllers:
> # controller - people.py
> def index():
>   if request.args(0):
>  people = db(db.people.positition == request.args(0)).select()
>   else:
>  people = db(db.people).select()
>   return dict(people=people)
>
> # contact.py
> def index():
> ... build contact form, do form validation, etc ...
> return dict(form=form) 
>
> # and my contact view 
> # views/contact/index.html contains this LOAD statement:
> {{ = LOAD('people','index',args=['faculty']) }}
>
> When I attempt to view the page /app/contact/index
>
> I get the error:
>   KeyError: people
>
> The error is of course generated in the 2nd line of the people.py index 
> function.
>
> When I attempt to view /app/people/index everything works perfectly. 
>
> Can I use LOAD with conditional models?
>


[web2py] Using components via LOAD with conditional models is not working

2012-06-04 Thread anonymouse
Hi all,

I'm having an issue trying to load a component that relies on conditionally 
loaded models.

It appears that either the conditional model file is not executed/evaluated 
using the LOAD function.

The following files are relevant to this issue:

models/people/personnel.py
controllers/people.py
controllers/contact.py
views/contact/index.html
views/people/index.html


The quick solution would clearly be to take the conditional model out of 
"people" so that it is available to the "contact" controller, but I was 
wondering if there were any another solutions which allow the "people" 
model file to still be executed conditionally. 

Perhaps I would be better off putting the model in modules and having the 
model/personnel.py file import the table definition from modules, and add 
another import statement to the "contact" controller and any other 
controllers outside of people that use personnel data (though at present, 
contact is the ONLY one)?

I would think that LOAD would execute the conditional model but perhaps 
there is a good reason it does not? I could just be using components/LOAD 
completely wrong, but if not then maybe this is a good candidate for a 
feature request? 

If anyone can shed some light on this issue, please, shed away! 

Below are the parts my app that are relevant: 

### Models: models/people/personnel.py
db.define_table('people',
 Field(...) # Defines name, position, user-id -- this is NOT meant for any 
sort of access control, just a list of people in our institution
 ...
)


### I have two controllers:
# controller - people.py
def index():
  if request.args(0):
 people = db(db.people.positition == request.args(0)).select()
  else:
 people = db(db.people).select()
  return dict(people=people)

# contact.py
def index():
... build contact form, do form validation, etc ...
return dict(form=form) 

# and my contact view 
# views/contact/index.html contains this LOAD statement:
{{ = LOAD('people','index',args=['faculty']) }}

When I attempt to view the page /app/contact/index

I get the error:
  KeyError: people

The error is of course generated in the 2nd line of the people.py index 
function.

When I attempt to view /app/people/index everything works perfectly. 

Can I use LOAD with conditional models?


[web2py] Connecting to Firebird

2012-06-04 Thread pjag
Greetings,

Getting up to speed on web2py, and am trying to use Firebird as my DB. 
 When I start my web2py app, I get the following error message:

 Failure to connect, tried 5 times: 
Traceback (most recent call last): File "gluon/dal.py", line 5955, in 
__init__ File "gluon/dal.py", line 2449, in __init__ NameError: global name 
'kinterbasdb' is not defined

Here's my connection code in db.py:

 db = 
DAL('firebird://sysdba:masterkey@localhost:3050/C:\\web2py\\applications\\myapp\\myappdb.fdb')

I'm using Python 2.7.3 x64 (Win7), web2py 1.99.7, Firebird 2.5.1 x64.  I 
installed kinterbasdb 3.3 manually (doesn't it get installed with web2py?), 
but still have the same error.

Help please!




[web2py] Re: I have trouble with the new scheduler and mysql: NotSupportedError

2012-06-04 Thread szimszon
already there... http://code.google.com/p/web2py/issues/detail?id=833

2012. június 4., hétfő 17:39:52 UTC+2 időpontban Massimo Di Pierro a 
következőt írta:
>
> Thank you. Please upload the patch in a google code issue. Less changes of 
> me forgetting or doing a mistake. ;-)
>
> On Monday, 4 June 2012 04:00:05 UTC-5, szimszon wrote:
>>
>> Prev. patch wasn't good, here it is:
>>
>> --- scheduler.py.old2012-06-02 14:44:26.0 +0200
>> +++ scheduler.py2012-06-04 10:53:59.013899780 +0200
>> @@ -417,13 +417,13 @@
>>  return None
>>  grabbed = db(ts.assigned_worker_name==self.worker_name)\
>>  (ts.status==ASSIGNED)
>> -task_id = grabbed._select(ts.id, limitby=(0,1), orderby=ts.
>> next_run_time)
>> -updated = db(
>> -ts.id.belongs(task_id)
>> -).update(status=RUNNING,last_run_time=now) #reduces 
>> collisions?
>> -#noone will touch my task!
>> -db.commit()
>> -if updated:
>> +task_row = grabbed.select(ts.id, limitby=(0,1), orderby=ts.
>> next_run_time).first()
>> +if task_row:
>> +updated = db(
>> +ts.id==task_row.id
>> +).update(status=RUNNING,last_run_time=now) #reduces 
>> collisions?
>> +#noone will touch my task!
>> +db.commit()
>>  logging.debug('   work to do %s' % updated)
>>  task = db(ts.assigned_worker_name==self.worker_name)\
>>  (ts.status==RUNNING).select().first()
>>
>>
>>
>>
>>
>> 2012. június 4., hétfő 9:47:29 UTC+2 időpontban szimszon a következőt 
>> írta:
>>>
>>> http://code.google.com/p/web2py/issues/detail?id=833
>>>
>>> After upgrading to Version 2.0.0 (2012-06-02 16:44:25) dev I got this if I 
>>> start scheduler:
>>>
>>> Currently running 1 scheduler processes
>>> Processes started
>>> 2012-06-04 09:40:47,874 - root - DEBUG - defining tables (migrate=True)
>>> 2012-06-04 09:40:47,880 - root - DEBUG - thread building own DAL object
>>> 2012-06-04 09:40:47,880 - root - DEBUG - looping...
>>> 2012-06-04 09:40:47,883 - root - DEBUG - defining tables (migrate=False)
>>> 2012-06-04 09:40:47,886 - root - DEBUG - recording heartbeat
>>> 2012-06-04 09:40:47,887 - root - DEBUG - freeing workers that have not 
>>> sent heartbeat
>>> 2012-06-04 09:40:47,889 - root - INFO - TICKER: I'm a ticker 
>>> (info-szimszon#709cdf44-805a-41a5-b197-8aa124acf311)
>>> Traceback (most recent call last):
>>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/shell.py", 
>>> line 219, in run
>>> exec(python_code, _env)
>>>   File "", line 1, in 
>>>   File 
>>> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", line 
>>> 398, in loop
>>> MetaScheduler.loop(self)
>>>   File 
>>> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", line 
>>> 279, in loop
>>> task = self.pop_task()
>>>   File 
>>> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", line 
>>> 423, in pop_task
>>> ).update(status=RUNNING,last_run_time=now) #reduces collisions?
>>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", 
>>> line 8147, in update
>>> if any(f(self,update_fields) for f in table._before_update): return 0
>>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", 
>>> line 8147, in 
>>> if any(f(self,update_fields) for f in table._before_update): return 0
>>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", 
>>> line 7051, in 
>>> archive_record(qset,fs,at,cn))
>>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", 
>>> line 7450, in archive_record
>>> for row in qset.select():
>>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", 
>>> line 8130, in select
>>> return adapter.select(self.query,fields,attributes)
>>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", 
>>> line 1400, in select
>>> rows = response(sql)
>>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", 
>>> line 1390, in response
>>> self.execute(sql)
>>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", 
>>> line 1479, in execute
>>> return self.log_execute(*a, **b)
>>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", 
>>> line 1473, in log_execute
>>> ret = self.cursor.execute(*a, **b)
>>>   File 
>>> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/contrib/pymysql/cursors.py",
>>>  line 108, in execute
>>> self.errorhandler(self, exc, value)
>>>   File 
>>> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/contrib/pymysql/connections.py",
>>>  line 184, in defaulterrorhandler
>>> raise errorclass, errorvalue
>>> NotSupportedError: (1235, u"This version of MySQL doesn't yet support 
>>> 'LIMIT & IN/ALL/ANY/SOME subquery'")
>>>
>>>
>>>

Re: [web2py] best practices for displaying a a subset of a tables columns?

2012-06-04 Thread Richard Vézina
Johann answer here:
https://groups.google.com/forum/?fromgroups#!topic/web2py/0VpTEoZ1tkc

Anthony almost at the end of this thread :
https://groups.google.com/forum/?fromgroups#!topic/web2py/b5VgstnvY3Y


For the postgres views, you can define them as they were tables and set a
restricted access permission on them with RBAC built-in web2py, so, for
view you could have read and select of a record the other CRUD permissions
will not be available to all user, since you can't create new record for a
view, update or delete them. You will need that your view contain at least
a fake ID unique field to make it works with web2py.

About views I don't know if it best practice, but it works quite well for
me. An other solution, is to define you views into web2py as set : your_set
= db(db.table.field == something_that_filter)

And then use the set in select when you are ready :

your_set.select(db.table.ALL) # for example if you want all the column
your_set.select(db.table.f1, db.table.f2, etc.) # if you want only
particular columns


Hopes it help.

Richard

On Mon, Jun 4, 2012 at 8:56 AM, bob  wrote:

>
> In the old days I would just create a database view on a subset of a table
> that I wanted to allow other developers to access (assuming read only),
> however I'm not sure if that's the best thing to do with web2py.
>
> I have a table that has:
>
> last_name
> first_name
> etc
> including some 'internal' columns that I don't want to expose on any form
> or service.
>
> Any thoughts on the best way to implement this?
>
> I'm thinking:
>
> a:   database view (postgresql in this case),  issues being no 'id' in the
> view and I'm not sure how best to maintain that.
>
> b:   a new .py that takes the full record and returns the subset.   upside
> - it would be a single point of maintenance,  question is where would this
> live  (in the models, it's not a controller so it doesn't really fit there)?
>
> c:  ??
>
> thanks for any suggestions,
> bobm
>
>


[web2py] Re: Web2py execution blocking

2012-06-04 Thread Jan Rozhon
Hi Massimo,

thank you for your answer. Unfortunately, it didnt help. One thing I didn't 
mention and might be causing this trouble is, that I ask for several json 
values provided by similar controllers as I posted in my first post. Can 
the multitude ofjson requests cause this weird behaviour? In other words, 
is it better to provide several small json streams or one large?

Thanks in advance, Jan

Dne pondělí, 4. června 2012 17:38:41 UTC+2 Massimo Di Pierro napsal(a):
>
> Try replace output=rows with output=rows.as_list()
> Perhaps the rows are not json serializable.
>
> On Monday, 4 June 2012 02:20:39 UTC-5, Jan Rozhon wrote:
>>
>> Hi group, I have encountered a problem when I try to call a controller 
>> which should return a JSON array of values from database. However in abou 1 
>> of 5 cases this call stucks in "loading" phase (chrome animation in tab) 
>> and no response is received. Data is in database, every other controller is 
>> working fine, cpu utilization is pretty low so is the memory and there are 
>> only about 1 rows in DB. Could you please give me some hints?
>>
>> Thanks, Jan
>>
>> PS. The controller looks like this:
>>
>> def dberrorsselect():
>> """Performs sql query to get the errors in the form of list of dicts 
>> such as {field_name:value}. This is then transformed to json dict for 
>> transfer."""
>> if session.tb_id:
>> 
>> max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
>> if max_id != None:
>> selector_id=int(max_id)-5
>> else:
>> selector_id=0
>> rows=tb((tb.errors.test_id==session.tb_id)&(tb.errors.id > 
>> selector_id)).select(tb.errors.ts, tb.errors.msg_short, tb.errors.msg_long)
>> output=rows
>> else:
>> output=[] 
>> return dict(output=output)
>>
>>
>>

[web2py] Re: I have trouble with the new scheduler and mysql: NotSupportedError

2012-06-04 Thread Massimo Di Pierro
Thank you. Please upload the patch in a google code issue. Less changes of 
me forgetting or doing a mistake. ;-)

On Monday, 4 June 2012 04:00:05 UTC-5, szimszon wrote:
>
> Prev. patch wasn't good, here it is:
>
> --- scheduler.py.old2012-06-02 14:44:26.0 +0200
> +++ scheduler.py2012-06-04 10:53:59.013899780 +0200
> @@ -417,13 +417,13 @@
>  return None
>  grabbed = db(ts.assigned_worker_name==self.worker_name)\
>  (ts.status==ASSIGNED)
> -task_id = grabbed._select(ts.id, limitby=(0,1), orderby=ts.
> next_run_time)
> -updated = db(
> -ts.id.belongs(task_id)
> -).update(status=RUNNING,last_run_time=now) #reduces 
> collisions?
> -#noone will touch my task!
> -db.commit()
> -if updated:
> +task_row = grabbed.select(ts.id, limitby=(0,1), orderby=ts.
> next_run_time).first()
> +if task_row:
> +updated = db(
> +ts.id==task_row.id
> +).update(status=RUNNING,last_run_time=now) #reduces 
> collisions?
> +#noone will touch my task!
> +db.commit()
>  logging.debug('   work to do %s' % updated)
>  task = db(ts.assigned_worker_name==self.worker_name)\
>  (ts.status==RUNNING).select().first()
>
>
>
>
>
> 2012. június 4., hétfő 9:47:29 UTC+2 időpontban szimszon a következőt írta:
>>
>> http://code.google.com/p/web2py/issues/detail?id=833
>>
>> After upgrading to Version 2.0.0 (2012-06-02 16:44:25) dev I got this if I 
>> start scheduler:
>>
>> Currently running 1 scheduler processes
>> Processes started
>> 2012-06-04 09:40:47,874 - root - DEBUG - defining tables (migrate=True)
>> 2012-06-04 09:40:47,880 - root - DEBUG - thread building own DAL object
>> 2012-06-04 09:40:47,880 - root - DEBUG - looping...
>> 2012-06-04 09:40:47,883 - root - DEBUG - defining tables (migrate=False)
>> 2012-06-04 09:40:47,886 - root - DEBUG - recording heartbeat
>> 2012-06-04 09:40:47,887 - root - DEBUG - freeing workers that have not 
>> sent heartbeat
>> 2012-06-04 09:40:47,889 - root - INFO - TICKER: I'm a ticker 
>> (info-szimszon#709cdf44-805a-41a5-b197-8aa124acf311)
>> Traceback (most recent call last):
>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/shell.py", 
>> line 219, in run
>> exec(python_code, _env)
>>   File "", line 1, in 
>>   File 
>> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", line 
>> 398, in loop
>> MetaScheduler.loop(self)
>>   File 
>> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", line 
>> 279, in loop
>> task = self.pop_task()
>>   File 
>> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", line 
>> 423, in pop_task
>> ).update(status=RUNNING,last_run_time=now) #reduces collisions?
>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
>> 8147, in update
>> if any(f(self,update_fields) for f in table._before_update): return 0
>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
>> 8147, in 
>> if any(f(self,update_fields) for f in table._before_update): return 0
>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
>> 7051, in 
>> archive_record(qset,fs,at,cn))
>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
>> 7450, in archive_record
>> for row in qset.select():
>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
>> 8130, in select
>> return adapter.select(self.query,fields,attributes)
>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
>> 1400, in select
>> rows = response(sql)
>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
>> 1390, in response
>> self.execute(sql)
>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
>> 1479, in execute
>> return self.log_execute(*a, **b)
>>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
>> 1473, in log_execute
>> ret = self.cursor.execute(*a, **b)
>>   File 
>> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/contrib/pymysql/cursors.py",
>>  line 108, in execute
>> self.errorhandler(self, exc, value)
>>   File 
>> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/contrib/pymysql/connections.py",
>>  line 184, in defaulterrorhandler
>> raise errorclass, errorvalue
>> NotSupportedError: (1235, u"This version of MySQL doesn't yet support 'LIMIT 
>> & IN/ALL/ANY/SOME subquery'")
>>
>>
>>

[web2py] Re: Web2py execution blocking

2012-06-04 Thread Massimo Di Pierro
Try replace output=rows with output=rows.as_list()
Perhaps the rows are not json serializable.

On Monday, 4 June 2012 02:20:39 UTC-5, Jan Rozhon wrote:
>
> Hi group, I have encountered a problem when I try to call a controller 
> which should return a JSON array of values from database. However in abou 1 
> of 5 cases this call stucks in "loading" phase (chrome animation in tab) 
> and no response is received. Data is in database, every other controller is 
> working fine, cpu utilization is pretty low so is the memory and there are 
> only about 1 rows in DB. Could you please give me some hints?
>
> Thanks, Jan
>
> PS. The controller looks like this:
>
> def dberrorsselect():
> """Performs sql query to get the errors in the form of list of dicts 
> such as {field_name:value}. This is then transformed to json dict for 
> transfer."""
> if session.tb_id:
> 
> max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
> if max_id != None:
> selector_id=int(max_id)-5
> else:
> selector_id=0
> rows=tb((tb.errors.test_id==session.tb_id)&(tb.errors.id > 
> selector_id)).select(tb.errors.ts, tb.errors.msg_short, tb.errors.msg_long)
> output=rows
> else:
> output=[] 
> return dict(output=output)
>
>
>

[web2py] Re: access an uploaded but not stored file?

2012-06-04 Thread Massimo Di Pierro
The file is in request.vars.file_field.file which is a read-only stream. 
You can shutil.copyfile it to a temporary folder.

On Friday, 14 January 2011 18:56:41 UTC-6, Thomas Dall'Agnese wrote:
>
> Dear community, 
>
> I have a form with an upload field that I use to upload a text file, 
> parse information from this file and store this information into the 
> database, but not the file itself. 
>
> The form is for example defined by: 
> form = FORM(INPUT(_name='file_field', _type = 'file', requires = 
> IS_NOT_EMPTY()), 
>   INPUT(_type='submit')) 
>
> I can access the file content with request.vars.file_field.file.read() 
> but this function does not detect the file encoding and open all my 
> file as utf-8. 
> So instead I would like to use codecs.open(xxx, "r", charset) to 
> define the charset (utf-8, iso-8859-1, ...). 
> However, as I don't store the file, I can't find the file in the 
> uploads/ directory. 
> How can I find the temporary file path if there is any? 
>
> Or do you have any suggestion to read the uploaded file with the right 
> encoding (without chardet)? 
>
> Best regards, 
>
> $p00ky



[web2py] Re: HTML in context_dict for sending mails

2012-06-04 Thread Anthony
By default, the template engine escapes everything -- to avoid that, do:

links = XML("user_a")

See http://web2py.com/books/default/chapter/29/5#XML.

Anthony

On Monday, June 4, 2012 10:52:07 AM UTC-4, Sushant Taneja wrote:
>
> Hi All,
>
> I have a string var containing some HTML code
>
> links = "user_a"
> I am passing this variable to response.render function as: 
>
> context_dict = dict(links=links)
> message = response.render("invite_friend.html",context_dict)
>
> # Send mail code below
>
> In invite_friend.html I have the code:
>
> 
> Hello there, 
> 
> {{=links}}
> 
> 
>
> When the mail is sent, the email message is rendered as below:
>
> Hello there, 
> user_a
>
> instead of
>
> Hello there,
>
>- user_a 
>
>
> How to render the above mail properly ?? I am working on GAE and 
> mail.settings.server is set to 'gae'
>
>

[web2py] Sending Emails to all my users in one time

2012-06-04 Thread Hassan Alnatour
Dear ALL , 

How can i send all the users i have in my auth_users  an email at once ?\

regards,


[web2py] Re: How to access temporary uploaded files and its filename?

2012-06-04 Thread Anthony

>
> 2.Is it possible to get the uploaded video filename like 
> tablename.video.9f23071fdb975edd.34383034303039322e663476.f4v in the 
> uploads directory when the upload form is just submitted but not accepted?
>

 No, the filename is determined at the time that the file is saved.

Anthony


[web2py] Re: How to access temporary uploaded file?

2012-06-04 Thread Anthony
I'm not sure how you might be able to process the file *while* it is 
uploading (i.e., process the bytes as they are received by the server), but 
if you can wait until the file is fully uploaded, you can access the 
uploaded file as a Python cgi.FieldStorage object:

def upload():
if request.vars.myfile:
video = encode_video(request.vars.myfile.file)
[do something with video]
form = SQLFORM.factory(Field('myfile', 'upload', uploadfolder=
'/path/to/upload')).process()
return dict(form=form)

Upon upload, request.vars.myfile will be a cgi.FieldStorage object, and the 
open file object will be in request.vars.myfile.file. Note, if the encoding 
takes a while, you might want to pass it off to a task queue rather than 
handle it in the controller.

Anthony

On Monday, June 4, 2012 4:23:55 AM UTC-4, Charles Tang wrote:
>
> I am using a sqlform to upload a video file and want to encoding the video 
> file while uploading. But I noticed that the upload file is not saved to 
> uploads directory utill it is completely uploaded. Is there a temporary 
> file and how can I access it ?Thanks.
>


[web2py] what do you think about waitress webserver

2012-06-04 Thread Vasile Ermicioi
hi, 
what do you think about waitress webserver?

http://docs.pylonsproject.org/projects/waitress/en/latest/ 




[web2py] Re: poweredby broken?

2012-06-04 Thread Anthony
Yes, it does appear to be broken. Massimo?

On Monday, June 4, 2012 7:37:20 AM UTC-4, stefaan wrote:
>
> Ticket issued: 
> poweredby/xxx.xxx.xx.x.2012-06-04.12-35-07.80f9cfdf-c405-4c8e-8229-3dca140cade2
>
>

Re: [web2py] not enough arguments for format string

2012-06-04 Thread Martin Weissenboeck
Try:

*return XML("$('%s').click(function(){$('html, body,
%s').animate({scrollTop:
$(document).height()}, %s); return false;});" %
(**button_id,div_id,speed
)*

Regards, Martin


2012/6/4 Hassan Alnatour 

> Dear ALL ,
>
>  I created a function to get a div and a button and a speed and then using
> jquery scroll down to that div , now the function looks like this  :
>
> *def scrolldown(button_id,div_id,speed):
> '''
> Scroll down to the end of any div using a button and a speed
> '''
> return XML("$('%s').click(function(){$('html, body, 
> %s').animate({scrollTop:
> $(document).height()}, %s); return false;});" %
> button_id,div_id,speed
>
>
> *
>  i used that function in the view like this  :
>
> *{{=scrolldown('#s','.rounded','6')}}
>
>
>
> *
>   But i keep getting an Error which is : *not enough arguments for format
> string  !! *Why *??
>
> (not enough arguments for format string)
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
> exec ccode in environment
>   File "C:\web2py\applications\i3zif\views\arabic/usercontest.html", line
> 192, in 
>   File "C:/web2py/applications/i3zif/models/scrolldown.py", line 6, in
> scrolldown
> return XML("$('%s').click(function(){$('html, body,
> %s').animate({scrollTop: $(document).height()}, %s); return
> false;});" % button_id,div_id,speed)
> TypeError: not enough arguments for format string
>
> *
>
>
>


[web2py] best practices for displaying a a subset of a tables columns?

2012-06-04 Thread bob

In the old days I would just create a database view on a subset of a table 
that I wanted to allow other developers to access (assuming read only),  
however I'm not sure if that's the best thing to do with web2py.

I have a table that has:

last_name
first_name
etc
including some 'internal' columns that I don't want to expose on any form 
or service.

Any thoughts on the best way to implement this?

I'm thinking:

a:   database view (postgresql in this case),  issues being no 'id' in the 
view and I'm not sure how best to maintain that.

b:   a new .py that takes the full record and returns the subset.   upside 
- it would be a single point of maintenance,  question is where would this 
live  (in the models, it's not a controller so it doesn't really fit there)?

c:  ??

thanks for any suggestions,
bobm



Re: [web2py] poweredby broken?

2012-06-04 Thread Alec Taylor
Maybe show us the output?

On Mon, Jun 4, 2012 at 9:37 PM, stefaan  wrote:
> Ticket
> issued: poweredby/xxx.xxx.xx.x.2012-06-04.12-35-07.80f9cfdf-c405-4c8e-8229-3dca140cade2
>


[web2py] not enough arguments for format string

2012-06-04 Thread Hassan Alnatour
Dear ALL , 

 I created a function to get a div and a button and a speed and then using 
jquery scroll down to that div , now the function looks like this  : 

*def scrolldown(button_id,div_id,speed):
'''
Scroll down to the end of any div using a button and a speed
'''
return XML("$('%s').click(function(){$('html, body, 
%s').animate({scrollTop: 
$(document).height()}, %s); return false;});" % 
button_id,div_id,speed


*
 i used that function in the view like this  :

*{{=scrolldown('#s','.rounded','6')}}



*
  But i keep getting an Error which is : *not enough arguments for format 
string  !! *Why *??

(not enough arguments for format string)

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 204, in restricted
exec ccode in environment
  File "C:\web2py\applications\i3zif\views\arabic/usercontest.html", line 
192, in 
  File "C:/web2py/applications/i3zif/models/scrolldown.py", line 6, in 
scrolldown
return XML("$('%s').click(function(){$('html, body, 
%s').animate({scrollTop: $(document).height()}, %s); return 
false;});" % button_id,div_id,speed)
TypeError: not enough arguments for format string

*

*
*



[web2py] poweredby broken?

2012-06-04 Thread stefaan
Ticket issued: 
poweredby/xxx.xxx.xx.x.2012-06-04.12-35-07.80f9cfdf-c405-4c8e-8229-3dca140cade2



[web2py] How to access temporary uploaded files and its filename?

2012-06-04 Thread Charles Tang
I want to encoding  video files while uploading. The webpage should display 
the uploading process and encoding process. I use this snippet of 
codeto 
display the uploading progress and it works. But I found the video file 
would not appear in the uploads directory until the video is completely 
uploaded.So these are my questions:
1. If there is a temporary file? Where is it and how to access it? 
2.Is it possible to get the uploaded video filename like 
tablename.video.9f23071fdb975edd.34383034303039322e663476.f4v in the 
uploads directory when the upload form is just submitted but not accepted? 
I noticed that the form db is updated utill the uploading is complete.
Thanks.




[web2py] How to access temporary uploaded file?

2012-06-04 Thread Charles Tang
I am using a sqlform to upload a video file and want to encoding the video 
file while uploading. But I noticed that the upload file is not saved to 
uploads directory utill it is completely uploaded. Is there a temporary 
file and how can I access it ?Thanks.


[web2py] Re: access an uploaded but not stored file?

2012-06-04 Thread Charles Tang
I have the same problem. How did you sovle it?

On Saturday, January 15, 2011 8:56:41 AM UTC+8, Thomas Dall'Agnese wrote:
>
> Dear community, 
>
> I have a form with an upload field that I use to upload a text file, 
> parse information from this file and store this information into the 
> database, but not the file itself. 
>
> The form is for example defined by: 
> form = FORM(INPUT(_name='file_field', _type = 'file', requires = 
> IS_NOT_EMPTY()), 
>   INPUT(_type='submit')) 
>
> I can access the file content with request.vars.file_field.file.read() 
> but this function does not detect the file encoding and open all my 
> file as utf-8. 
> So instead I would like to use codecs.open(xxx, "r", charset) to 
> define the charset (utf-8, iso-8859-1, ...). 
> However, as I don't store the file, I can't find the file in the 
> uploads/ directory. 
> How can I find the temporary file path if there is any? 
>
> Or do you have any suggestion to read the uploaded file with the right 
> encoding (without chardet)? 
>
> Best regards, 
>
> $p00ky



[web2py] Re: [web2py:8670] Re: Video Upload: Validate as video file, convert to flv, 'best practice' method?

2012-06-04 Thread Charles Tang
The temporary uploaded video file does not appear in uploads directory 
until the video is completely uploaded. So is it possible to access the 
temporary video file when the file is being uploading ?Thanks!

On Friday, August 29, 2008 9:12:35 PM UTC+8, Massimo Di Pierro wrote:
>
> follow-up
>
>  convert.py 
> import os, stat, time, logging
> while True:
>  files=[(os.stat(file)[stat.ST_CTIME],file) for file in os.listdir 
> (request.folder,'uploads') if file[:16]=='mytable.original']
>  files.sort()
>  if files:
>   file=files[-1]
>   original, converted=file,file.replace 
> ('.original.','.converted.')+'.flv'
>   try:
>  os.system('ffmpeg %s %s' % (original,converted))
>  db(db.mytable.original=original).update 
> (original='',converted=converted)
>  db.commit()
>   except:
>  os.unlink(original)
>  db(db.mytable.original=original).update(original='')
>  db.commit()
>  logging.error('unable to convert')
>  else: time.sleep(5)
> - end file
>
> and run it in background with
>
>  nohup python web2py.py -S yourapp -R convert.py &
>
> Massimo
>
> On Aug 29, 2008, at 7:53 AM, Massimo Di Pierro wrote:
>
> >
> > Dear Mike,
> >
> > the conversion may take time and the server may kill the thread
> > before the conversion is done. By looking at youtube and how other
> > sites handle this, here is my suggestion. have two 'upload' fields:
> > original, converted. Default converted to ''. Write a batch web2py
> > script that runs in backrgound, looks for uploads/
> > yourtable.original.xxx.* files, sorts them by creating time,
> > converts each of them into uploads/yourtable.converted.xxx.flv
> > then updates the corresponding records by setting original to '' and
> > converted to 'yourtable.converted.xxx.flv'.
> >
> > Your interface can use ajax callbacks to query the database and check
> > is the record is completed by looking at the value of
> > yourtable.converted.
> >
> > Hope this helps.
> >
> > Massimo
> >
> > On Aug 29, 2008, at 5:52 AM, MikeHamer wrote:
> >
> >>
> >> Hey all,
> >> I'm an experienced low level (C/C++/ASM) programmer with very little
> >> experience in web programming and web frameworks, so please excuse my
> >> naivety.
> >>
> >> I've been working on a proof-of-concept site, testing out various
> >> frameworks and confirming that my idea is feasible. One of the
> >> features I am working on is video upload+playback.
> >>
> >> I've been quite impressed with web2py's upload streaming and  
> >> automatic
> >> renaming of uploaded files (among other features this has eased my
> >> entry into web-frameworks and web-programming). I would now like to
> >> extend (or enhance) this functionality and are looking for some
> >> suggestions as to the 'best practice' method of achieving this:
> >>
> >> Currently I have a video model:
> >> videos:
> >> id (auto)
> >> title (string)
> >> videofile (upload)
> >>
> >> My goal is to:
> >> 1) Upload a video file (I would like to continue using SQLFORM if
> >> possible as this construct is fast and provides a whole load of
> >> functionality that I would prefer not to reimplement)
> >>
> >> 2) Validate that the uploaded file is a video file (read the metadata
> >> of the file object)
> >>
> >> 3) If the file is a video file
> >> call ffmpeg (or equiv) to convert the file into a .flv
> >> file with set dimensions
> >> 3.1) else
> >> return an error to the user
> >>
> >> 4) Record the new .flv file path into the videos.videofile (later to
> >> be played by the embedded flv player)
> >>
> >>
> >>
> >> My initial reaction was to use a custom validator (similar to CRYPT)
> >> to handle passing ffmpeg the input file and returning the
> >> cooresponding (ConvertedFilename.flv , None) tuple from the  
> >> vaildator.
> >> However consulting other validators that are designed to handle
> >> uploads (such as IS_LENGTH), it appears that the file is passed into
> >> the validator as a cgi.FieldStorage  (  if
> >> isinstance(value,cgi.FieldStorage)  ).
> >>
> >> ffmpeg only works with files (not binary data containers), so on that
> >> note I am stumped. It would be possible to write the  
> >> cgi.fieldstore to
> >> disk, then process it that way, however that would subvert web2py
> >> functionality rather than extending it.
> >>
> >>
> >>
> >> Any guidance would be appreciated,
> >> Mike
> >>
> >>>
> >
> >
> > >
>
>

Re: [web2py] Django CRM + Commerce

2012-06-04 Thread Khalil KHAMLICHI
We would like to see such projects for web2py too :)

On Sun, Jun 3, 2012 at 7:37 PM, pbreit  wrote:

> Good model. Mezzanine + Cartridge:
> https://groups.google.com/forum/?fromgroups#!topic/django-users/5_VcKbID514
>


[web2py] Re: I have trouble with the new scheduler and mysql: NotSupportedError

2012-06-04 Thread szimszon
Prev. patch wasn't good, here it is:

--- scheduler.py.old2012-06-02 14:44:26.0 +0200
+++ scheduler.py2012-06-04 10:53:59.013899780 +0200
@@ -417,13 +417,13 @@
 return None
 grabbed = db(ts.assigned_worker_name==self.worker_name)\
 (ts.status==ASSIGNED)
-task_id = grabbed._select(ts.id, limitby=(0,1), orderby=ts.
next_run_time)
-updated = db(
-ts.id.belongs(task_id)
-).update(status=RUNNING,last_run_time=now) #reduces collisions?
-#noone will touch my task!
-db.commit()
-if updated:
+task_row = grabbed.select(ts.id, limitby=(0,1), orderby=ts.
next_run_time).first()
+if task_row:
+updated = db(
+ts.id==task_row.id
+).update(status=RUNNING,last_run_time=now) #reduces 
collisions?
+#noone will touch my task!
+db.commit()
 logging.debug('   work to do %s' % updated)
 task = db(ts.assigned_worker_name==self.worker_name)\
 (ts.status==RUNNING).select().first()





2012. június 4., hétfő 9:47:29 UTC+2 időpontban szimszon a következőt írta:
>
> http://code.google.com/p/web2py/issues/detail?id=833
>
> After upgrading to Version 2.0.0 (2012-06-02 16:44:25) dev I got this if I 
> start scheduler:
>
> Currently running 1 scheduler processes
> Processes started
> 2012-06-04 09:40:47,874 - root - DEBUG - defining tables (migrate=True)
> 2012-06-04 09:40:47,880 - root - DEBUG - thread building own DAL object
> 2012-06-04 09:40:47,880 - root - DEBUG - looping...
> 2012-06-04 09:40:47,883 - root - DEBUG - defining tables (migrate=False)
> 2012-06-04 09:40:47,886 - root - DEBUG - recording heartbeat
> 2012-06-04 09:40:47,887 - root - DEBUG - freeing workers that have not 
> sent heartbeat
> 2012-06-04 09:40:47,889 - root - INFO - TICKER: I'm a ticker 
> (info-szimszon#709cdf44-805a-41a5-b197-8aa124acf311)
> Traceback (most recent call last):
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/shell.py", 
> line 219, in run
> exec(python_code, _env)
>   File "", line 1, in 
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", 
> line 398, in loop
> MetaScheduler.loop(self)
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", 
> line 279, in loop
> task = self.pop_task()
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", 
> line 423, in pop_task
> ).update(status=RUNNING,last_run_time=now) #reduces collisions?
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 8147, in update
> if any(f(self,update_fields) for f in table._before_update): return 0
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 8147, in 
> if any(f(self,update_fields) for f in table._before_update): return 0
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 7051, in 
> archive_record(qset,fs,at,cn))
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 7450, in archive_record
> for row in qset.select():
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 8130, in select
> return adapter.select(self.query,fields,attributes)
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 1400, in select
> rows = response(sql)
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 1390, in response
> self.execute(sql)
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 1479, in execute
> return self.log_execute(*a, **b)
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 1473, in log_execute
> ret = self.cursor.execute(*a, **b)
>   File 
> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/contrib/pymysql/cursors.py",
>  line 108, in execute
> self.errorhandler(self, exc, value)
>   File 
> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/contrib/pymysql/connections.py",
>  line 184, in defaulterrorhandler
> raise errorclass, errorvalue
> NotSupportedError: (1235, u"This version of MySQL doesn't yet support 'LIMIT 
> & IN/ALL/ANY/SOME subquery'")
>
>
>

[web2py] Re: I have trouble with the new scheduler and mysql: NotSupportedError

2012-06-04 Thread szimszon
Here is a quick patch need testing:

--- scheduler.py.old2012-06-02 14:44:26.0 +0200
+++ scheduler.py2012-06-04 10:46:35.557913663 +0200
@@ -417,13 +417,13 @@
 return None
 grabbed = db(ts.assigned_worker_name==self.worker_name)\
 (ts.status==ASSIGNED)
-task_id = grabbed._select(ts.id, limitby=(0,1), 
orderby=ts.next_run_time)
-updated = db(
-ts.id.belongs(task_id)
-).update(status=RUNNING,last_run_time=now) #reduces collisions?
-#noone will touch my task!
-db.commit()
-if updated:
+task_row = grabbed.select(ts.id, limitby=(0,1), 
orderby=ts.next_run_time).first()
+if task_row:
+updated = db(
+ts.id.belongs(task_row.id)
+).update(status=RUNNING,last_run_time=now) #reduces collisions?
+#noone will touch my task!
+db.commit()
 logging.debug('   work to do %s' % updated)
 task = db(ts.assigned_worker_name==self.worker_name)\
 (ts.status==RUNNING).select().first()






2012. június 4., hétfő 9:47:29 UTC+2 időpontban szimszon a következőt írta:
>
> http://code.google.com/p/web2py/issues/detail?id=833
>
> After upgrading to Version 2.0.0 (2012-06-02 16:44:25) dev I got this if I 
> start scheduler:
>
> Currently running 1 scheduler processes
> Processes started
> 2012-06-04 09:40:47,874 - root - DEBUG - defining tables (migrate=True)
> 2012-06-04 09:40:47,880 - root - DEBUG - thread building own DAL object
> 2012-06-04 09:40:47,880 - root - DEBUG - looping...
> 2012-06-04 09:40:47,883 - root - DEBUG - defining tables (migrate=False)
> 2012-06-04 09:40:47,886 - root - DEBUG - recording heartbeat
> 2012-06-04 09:40:47,887 - root - DEBUG - freeing workers that have not 
> sent heartbeat
> 2012-06-04 09:40:47,889 - root - INFO - TICKER: I'm a ticker 
> (info-szimszon#709cdf44-805a-41a5-b197-8aa124acf311)
> Traceback (most recent call last):
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/shell.py", 
> line 219, in run
> exec(python_code, _env)
>   File "", line 1, in 
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", 
> line 398, in loop
> MetaScheduler.loop(self)
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", 
> line 279, in loop
> task = self.pop_task()
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", 
> line 423, in pop_task
> ).update(status=RUNNING,last_run_time=now) #reduces collisions?
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 8147, in update
> if any(f(self,update_fields) for f in table._before_update): return 0
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 8147, in 
> if any(f(self,update_fields) for f in table._before_update): return 0
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 7051, in 
> archive_record(qset,fs,at,cn))
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 7450, in archive_record
> for row in qset.select():
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 8130, in select
> return adapter.select(self.query,fields,attributes)
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 1400, in select
> rows = response(sql)
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 1390, in response
> self.execute(sql)
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 1479, in execute
> return self.log_execute(*a, **b)
>   File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
> 1473, in log_execute
> ret = self.cursor.execute(*a, **b)
>   File 
> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/contrib/pymysql/cursors.py",
>  line 108, in execute
> self.errorhandler(self, exc, value)
>   File 
> "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/contrib/pymysql/connections.py",
>  line 184, in defaulterrorhandler
> raise errorclass, errorvalue
> NotSupportedError: (1235, u"This version of MySQL doesn't yet support 'LIMIT 
> & IN/ALL/ANY/SOME subquery'")
>
>
>

Re: [web2py] Re: Removing a row from a list

2012-06-04 Thread Johann Spies
On 1 June 2012 19:01, Anthony  wrote:

> You might consider building the links in the grid using the A() helper --
> if you specify the cid argument, it will trap the link and load it as a
> component:
>
> A('Remove', _href=URL('default', 'grid.load', args=['delete', item.uuid]),cid
> =request.cid)
>
>
>
Many thanks for this.  I have seen the 'cid' option in the book previously
but did not think about the possibility to use it here maybe because I do
not understand enough yet of the usage of AJAX. But I am learning ... :)

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


[web2py] Re: Web2py execution blocking

2012-06-04 Thread Jan Rozhon
Update, I have added several comments to this controller to see, where it 
gets block, the funny thing is that nothing really happens in those weird 
cases meaning that the controller is not executed at all, until I kill some 
spawned processes run by subprocess module, after that it appears, that all 
the request that came in the time period when controller was malfunctioning 
are handled at once (all comments appeared repeatedly). Maybe some problem 
with process spawning?

Thanks, Jan 

Dne pondělí, 4. června 2012 9:20:39 UTC+2 Jan Rozhon napsal(a):
>
> Hi group, I have encountered a problem when I try to call a controller 
> which should return a JSON array of values from database. However in abou 1 
> of 5 cases this call stucks in "loading" phase (chrome animation in tab) 
> and no response is received. Data is in database, every other controller is 
> working fine, cpu utilization is pretty low so is the memory and there are 
> only about 1 rows in DB. Could you please give me some hints?
>
> Thanks, Jan
>
> PS. The controller looks like this:
>
> def dberrorsselect():
> """Performs sql query to get the errors in the form of list of dicts 
> such as {field_name:value}. This is then transformed to json dict for 
> transfer."""
> if session.tb_id:
> 
> max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
> if max_id != None:
> selector_id=int(max_id)-5
> else:
> selector_id=0
> rows=tb((tb.errors.test_id==session.tb_id)&(tb.errors.id > 
> selector_id)).select(tb.errors.ts, tb.errors.msg_short, tb.errors.msg_long)
> output=rows
> else:
> output=[] 
> return dict(output=output)
>
>
>

[web2py] I have trouble with the new scheduler and mysql: NotSupportedError

2012-06-04 Thread szimszon
http://code.google.com/p/web2py/issues/detail?id=833

After upgrading to Version 2.0.0 (2012-06-02 16:44:25) dev I got this if I 
start scheduler:

Currently running 1 scheduler processes
Processes started
2012-06-04 09:40:47,874 - root - DEBUG - defining tables (migrate=True)
2012-06-04 09:40:47,880 - root - DEBUG - thread building own DAL object
2012-06-04 09:40:47,880 - root - DEBUG - looping...
2012-06-04 09:40:47,883 - root - DEBUG - defining tables (migrate=False)
2012-06-04 09:40:47,886 - root - DEBUG - recording heartbeat
2012-06-04 09:40:47,887 - root - DEBUG - freeing workers that have not sent 
heartbeat
2012-06-04 09:40:47,889 - root - INFO - TICKER: I'm a ticker 
(info-szimszon#709cdf44-805a-41a5-b197-8aa124acf311)
Traceback (most recent call last):
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/shell.py", line 
219, in run
exec(python_code, _env)
  File "", line 1, in 
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", 
line 398, in loop
MetaScheduler.loop(self)
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", 
line 279, in loop
task = self.pop_task()
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/scheduler.py", 
line 423, in pop_task
).update(status=RUNNING,last_run_time=now) #reduces collisions?
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
8147, in update
if any(f(self,update_fields) for f in table._before_update): return 0
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
8147, in 
if any(f(self,update_fields) for f in table._before_update): return 0
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
7051, in 
archive_record(qset,fs,at,cn))
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
7450, in archive_record
for row in qset.select():
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
8130, in select
return adapter.select(self.query,fields,attributes)
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
1400, in select
rows = response(sql)
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
1390, in response
self.execute(sql)
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
1479, in execute
return self.log_execute(*a, **b)
  File "/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/dal.py", line 
1473, in log_execute
ret = self.cursor.execute(*a, **b)
  File 
"/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/contrib/pymysql/cursors.py",
 line 108, in execute
self.errorhandler(self, exc, value)
  File 
"/home/PRIMERATE.LAN/gyszabolcs/fejlesztes/web2py/gluon/contrib/pymysql/connections.py",
 line 184, in defaulterrorhandler
raise errorclass, errorvalue
NotSupportedError: (1235, u"This version of MySQL doesn't yet support 'LIMIT & 
IN/ALL/ANY/SOME subquery'")




Re: [web2py] query from sql to code in web2py

2012-06-04 Thread Johann Spies
On 2 June 2012 16:36, Annet  wrote:

> I have the following where close in a query:
>
> WHERE nodeid=283 and ((dayid=6 and starttime>'11:00:00')or(dayid>6));
>
> In Postgresql this query outputs the right data.
>
> I translated this query into the following code in a function:
>
> rows=db((db.Timetable.nodeID==session.id
> )&(((db.Timetable.dayID==6)&(db.Timetable.startTime>'11:00:00'))or(db.Timetable.dayID>6))).select()
>
> In web2py this code results in an empty rows object. What's the correct
> syntax for this query?
>
>
Are you sure session.id == 283 in this case?

Hint:  Do a db._lastsql after your second query and compare the generated
SQL to your original SQL.

Also:  WHERE nodeid =  283 and dayid >= 6 and starttime > '11:00:00'
should give you the same result and the qauery is a bit shorter.

Regards.

Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


Re: [web2py] Re: Decoupling web2py templates

2012-06-04 Thread Alec Taylor
Excellent, I think this is exactly what I've been searching for =D

On Monday, June 4, 2012 5:16:26 PM UTC+10, Massimo Di Pierro wrote:
>
> You can do
>
> from gluon.template import render
>
> The render function is documented here: 
> https://github.com/web2py/web2py/blob/master/gluon/template.py#L837
>
> You can also use response.render(view,vars) instead of 
> render(filename=view,context=vars)
>
> On Sunday, 3 June 2012 23:10:33 UTC-5, Alec Taylor wrote:
>>
>> I'm intrigued... you've piqued my interest. 
>>
>> Can you show me an example with a few more lines so I can see where 
>> you were going with this? 
>>
>> Thanks 
>>
>> On Mon, Jun 4, 2012 at 1:34 PM, Massimo Di Pierro 
>>  wrote: 
>> > If I understand your question. You can do 
>> > 
>> > return response.render(view, context=dict()) 
>> > 
>> > 
>> > On Sunday, 3 June 2012 21:57:59 UTC-5, Alec Taylor wrote: 
>> >> 
>> >> Would it be possible to decouple web2py templates to use REST 
>> >> (HTTP)[XML, CSV, JSON] or RPC (XML, JSON)? 
>> >> 
>> >> The primary advantages I see for this is in the simplification for the 
>> >> creation of: 
>> >> - Mobile apps (using PhoneGap) 
>> >> - Easy JavaScript widget extrapolation (Facebook/DISQUS/Twitter style) 
>> >> 
>> >> Please tell me if it's possible to decouple the templates, and if so, 
>> how. 
>> >> 
>> >> Thanks for all information, 
>> >> 
>> >> Alec Taylor 
>> >> 
>> >> PS: If it's not possible with web2py templates, is there a different 
>> >> Python template library which makes this possible? 
>>
>

[web2py] Web2py execution blocking

2012-06-04 Thread Jan Rozhon
Hi group, I have encountered a problem when I try to call a controller 
which should return a JSON array of values from database. However in abou 1 
of 5 cases this call stucks in "loading" phase (chrome animation in tab) 
and no response is received. Data is in database, every other controller is 
working fine, cpu utilization is pretty low so is the memory and there are 
only about 1 rows in DB. Could you please give me some hints?

Thanks, Jan

PS. The controller looks like this:

def dberrorsselect():
"""Performs sql query to get the errors in the form of list of dicts 
such as {field_name:value}. This is then transformed to json dict for 
transfer."""
if session.tb_id:

max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
if max_id != None:
selector_id=int(max_id)-5
else:
selector_id=0
rows=tb((tb.errors.test_id==session.tb_id)&(tb.errors.id > 
selector_id)).select(tb.errors.ts, tb.errors.msg_short, tb.errors.msg_long)
output=rows
else:
output=[] 
return dict(output=output)




[web2py] Re: w2p_tvseries: a new web2py app

2012-06-04 Thread Alec Taylor


Thanks, I remember a friend wanting something like this for his anime a while 
back, I'll refer him to this :)

Also especially like how neat you've made your forms, example from 
controllers/manage.py:
form = SQLFORM.factory(
Field('paths', default=vars['paths'], requires=IS_IN_SET(all_folders)),
Field('seasonnumber', default=vars['seasonnumber'], 
requires=IS_IN_SET(set([row.seasons_settings.seasonnumber for row in 
folders]))),
Field('series_name', default=vars['series_name'], 
requires=IS_IN_SET(dict([(row.series.id, row.series.name) for row in 
folders]))),
Field('date_from', 'datetime', default=vars['date_from']),
Field('date_to', 'datetime', default=vars['date_to']),
buttons=[
BUTTON(w2p_icon('filter', variant='white'), "Filter Results", 
_class="btn btn-primary"),
A(w2p_icon('reset', variant='white'), "Reset Filters", 
_class="btn btn-info",
  _href=URL('bit', vars={}))
],
_method = 'GET',
_enctype = 'application/x-www-form-urlencoded'
)


=D

On Monday, June 4, 2012 9:04:11 AM UTC+10, Niphlod wrote:
>
> hey, I finally managed to push my app to github, with some sweat involved
>
> I haven't packaged an app and released to the public before, let's hope 
> nobody has problems installing it :P
>
> Let's cut to the chase, w2p_tvseries, as the name may suggest, is an app 
> to organize tv shows on the disk.
>
> It uses web2py, obviously, and as you'll read on github, I had a precise 
> agenda for it:
> - use as much web2py codebase as possible
> - use extensively the scheduler
> - test if Twitter Bootstrap (as opposed to jquery-ui that I used for all 
> my previous projects) is "enough" for all the functionality required
> - use AJAX wherever is possible: async stuff will take place probably in 
> places where it was not necessary, but I decided to give it a shot whenever 
> (and wherever) possible
> - make it a multi-platform app
> - combine some useful piece of scripts lying around my machine
> - play and test the requests (https://github.com/kennethreitz/requests) 
> library for all the HTTP communications
>
>
> Some goodies:
> - twitter bootstrap form serialization
> - integration with jquery fullcalendar (someone asked a while ago about 
> the implementation)
> - play with webservices, namely tvdb.com and opensubtitles.org
> - pagescraping of italiansubs.net
> - async task scheduling with task reporting
> - internal documentation written in MARKMIN
> - a nasty multiform page, on this group is quite a recurring question 
> (check series_settings() in controllers/manage.py)
>
> I'm happy with some pieces of implementations, let's say the 80% of it 
> modules singletons maybe account for a 10% I'm not happy about, and the 
> last 10% is some pieces of code repeated.
> This app 1 month ago looked like a puzzle (trying to piece together 
> scripts ranging from 2 years ago to now ). It's in alpha stage, things 
> can go wrong but nothing irreversible will be done ;-)
>
> Please, web2py developers, feel free to install, review, propose patches 
> and features, etc.
>
>

Re: [web2py] Re: Decoupling web2py templates

2012-06-04 Thread Massimo Di Pierro
You can do

from gluon.template import render

The render function is documented 
here: https://github.com/web2py/web2py/blob/master/gluon/template.py#L837

You can also use response.render(view,vars) instead of 
render(filename=view,context=vars)

On Sunday, 3 June 2012 23:10:33 UTC-5, Alec Taylor wrote:
>
> I'm intrigued... you've piqued my interest. 
>
> Can you show me an example with a few more lines so I can see where 
> you were going with this? 
>
> Thanks 
>
> On Mon, Jun 4, 2012 at 1:34 PM, Massimo Di Pierro 
>  wrote: 
> > If I understand your question. You can do 
> > 
> > return response.render(view, context=dict()) 
> > 
> > 
> > On Sunday, 3 June 2012 21:57:59 UTC-5, Alec Taylor wrote: 
> >> 
> >> Would it be possible to decouple web2py templates to use REST 
> >> (HTTP)[XML, CSV, JSON] or RPC (XML, JSON)? 
> >> 
> >> The primary advantages I see for this is in the simplification for the 
> >> creation of: 
> >> - Mobile apps (using PhoneGap) 
> >> - Easy JavaScript widget extrapolation (Facebook/DISQUS/Twitter style) 
> >> 
> >> Please tell me if it's possible to decouple the templates, and if so, 
> how. 
> >> 
> >> Thanks for all information, 
> >> 
> >> Alec Taylor 
> >> 
> >> PS: If it's not possible with web2py templates, is there a different 
> >> Python template library which makes this possible? 
>


Re: [web2py] Re: w2p_tvseries: a new web2py app

2012-06-04 Thread Jason (spot) Brower
Intense man.  Never needed a tool like that, but I know many that would
find it very useful!

On Mon, Jun 4, 2012 at 6:33 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> :-)
>
>
> On Sunday, 3 June 2012 21:14:10 UTC-5, Niphlod wrote:
>>
>> whoa, you're right 
>> did I mention I'm not a web designer and that there are a few corners
>> where I could use some help with javascript ? If someone is interested
>> please let me know.
>>
>>
>> Il giorno lunedì 4 giugno 2012 02:26:56 UTC+2, Massimo Di Pierro ha
>> scritto:
>>>
>>> No screenshots? :-(
>>>
>>> On Sunday, 3 June 2012 18:05:22 UTC-5, Niphlod wrote:

 yes, you're right, where is the github url ??

 https://github.com/niphlod/**w2p_tvseries