Re: [web2py] Happy new year

2012-01-02 Thread Martín Mulone
late but happy new year!

2012/1/1 Massimo Di Pierro massimo.dipie...@gmail.com

 Happy new year everybody!




-- 
 http://martin.tecnodoc.com.ar


[web2py] Re: EMails and PGP

2012-01-02 Thread szimszon
Can't say for sure but here are some links:

http://sourceforge.net/projects/pyme/files/pyme/pyme-0.8.1/
http://sourceforge.net/projects/pyme/files/pyme/pyme-0.8.1/pygpgme-0.8.1.win32.exe/download
http://pyme.sourceforge.net/


[web2py] Re: Happy new year

2012-01-02 Thread guruyaya
Sahna Tova Umetuka!

On Jan 2, 12:01 pm, Martín Mulone mulone.mar...@gmail.com wrote:
 late but happy new year!

 2012/1/1 Massimo Di Pierro massimo.dipie...@gmail.com

  Happy new year everybody!

 --
  http://martin.tecnodoc.com.ar


[web2py] Re: Happy new year

2012-01-02 Thread Rahul
Nutan Nav-varsha che sarvanna Abhinandan!



On Jan 2, 4:27 pm, guruyaya guruy...@gmail.com wrote:
 Sahna Tova Umetuka!

 On Jan 2, 12:01 pm, Martín Mulone mulone.mar...@gmail.com wrote:







  late but happy new year!

  2012/1/1 Massimo Di Pierro massimo.dipie...@gmail.com

   Happy new year everybody!

  --
   http://martin.tecnodoc.com.ar


Re: [web2py] Re: Happy new year

2012-01-02 Thread Albert Abril
M'encanta aquesta comunitat.
Feliç any 2012 a tot el món!

2012/1/2 Rahul rahul.dhak...@gmail.com

 Nutan Nav-varsha che sarvanna Abhinandan!



 On Jan 2, 4:27 pm, guruyaya guruy...@gmail.com wrote:
  Sahna Tova Umetuka!
 
  On Jan 2, 12:01 pm, Martín Mulone mulone.mar...@gmail.com wrote:
 
 
 
 
 
 
 
   late but happy new year!
 
   2012/1/1 Massimo Di Pierro massimo.dipie...@gmail.com
 
Happy new year everybody!
 
   --
http://martin.tecnodoc.com.ar



[web2py] Re: MARKMIN clarification

2012-01-02 Thread lyn2py
I double-checked... there are no extra spaces after the dashes.

I tried on a new post, this is the produced HTML:
div class=postphere's some blockquote:
blockquote class=this is a message
for first para/ppthis is a message
for second para/ppthis is a message
for third para/blockquote
here's some blockquote:
--
this is a message
for first para/ppthis is a message
for second para/ppthis is a message
for third para
--/p/div

Thanks!



On Jan 2, 1:01 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 This could be a bug. It is possible you have extra spaces after some
 of the ?

 On Jan 1, 5:59 pm, lyn2py lyn...@gmail.com wrote:







  MARKMIN blockquote: I can't have 2 blockquotes in a single message?

  This is the text I used, and only the one on top was generated as a
  blockquote. The one below was like the rest of the body.

  here's some blockquote:
  --
  this is a message
  for first para

  this is a message
  for second para

  this is a message
  for third para
  --

  here's a second blockquote (not rendered properly):
  --
  this is a message
  for first para

  this is a message
  for second para

  this is a message
  for third para
  --

  If I add more blockquotes, the last one always doesn't render
  properly.

  Is this a bug?

  On Dec 31 2011, 12:22 am, Massimo Di Pierro

  massimo.dipie...@gmail.com wrote:
   Two new lines in markmin translate into an end of paragraph in html, a
   single new line is interpreted as a continuation of the same
   paragraph.

   On Dec 30, 1:51 am, lyn2py lyn...@gmail.com wrote:

Does MARKMIN have issues with processing newlines?
Because I can't use formatting here, everything looks like the same
text, but in MARKMIN the formatting is ok, only the newlines is not
ok.

(1) I noticed that newlines don't convert to br in MARKMIN, which is
strange.

Example:
I write this
in two lines

MARKMIN processes it as: I write thisin two lines

But 2 newlines automatically converts to a paragraph (which is
correct).

(2) Also, when using verbatim ``

Example:
``I write this``

``in two paragraphs``

MARKMIN: I write thisin two paragraphs

(3) Using a mix of verbatim/italics/bold

Example:
``an edit as usual``

``another``

''one or the other''
**could be bolded**

MARKMIN:
an edit as usualanother

one or the other could be bolded

Notice the inconsistency in processing newlines (and spaces).
Is this correct behavior of MARKMIN?


Re: [web2py] Re: utf-8 and pyfpdf

2012-01-02 Thread José Luis Redrejo Rodríguez
Hi Martin, I'm using this in the controller, without any problem:


# coding: utf8
...
from gluon.contrib.pyfpdf.pdflabels import PDFLabel

import sys
reload(sys)
sys.setdefaultencoding( latin-1 )
...
def label_parejas():
 ...
            text=%s\n%s\n%s %s\n%s % (nombre_ella.decode('UTF-8'), ...)
            pdf.add_label(text)
    response.headers['Content-Type'] = 'application/pdf'
    return pdf.output(dest='S')


It works for me with any kind of symbol, including spanish ñ.

Regards


2012/1/1 Martin Weissenboeck mweis...@gmail.com:
 Now I have found that I have to convert the string:

 txt = 'äöü ß ÄÖÜ'
 txt = txt.decode('utf-8').encode('latin-1','replace')


 This new string will be written correctly into the pdf-file.Is there a
 better way?
 No chance for the Euro-currency-symbol '€'

 Maybe there will be a full unicode characterset for pyfpdf in the future.


 2012/1/1 Martin Weissenboeck mweis...@gmail.com

 Another question about pyfpdf:

 Is there any chance to get some more utf-8-characters?
 (I have asked this some months ago).

 It seems, that pyfpdf only supports the basic ascii character set and no
 latin-1-characters.
 I want to use äöü ß ÄÖÜ €...and so on.

 Regards, Martin




Re: [web2py] Re: Happy new year

2012-01-02 Thread Randolph Chaves
Feliz Año Nuevo (from Melo, Uruguay)

On Mon, Jan 2, 2012 at 9:47 AM, Albert Abril albert.ab...@gmail.com wrote:

 M'encanta aquesta comunitat.
 Feliç any 2012 a tot el món!

 2012/1/2 Rahul rahul.dhak...@gmail.com

 Nutan Nav-varsha che sarvanna Abhinandan!



 On Jan 2, 4:27 pm, guruyaya guruy...@gmail.com wrote:
  Sahna Tova Umetuka!
 
  On Jan 2, 12:01 pm, Martín Mulone mulone.mar...@gmail.com wrote:
 
 
 
 
 
 
 
   late but happy new year!
 
   2012/1/1 Massimo Di Pierro massimo.dipie...@gmail.com
 
Happy new year everybody!
 
   --
http://martin.tecnodoc.com.ar





-- 

  *´¨)
 ¸.•´ ¸.•*´¨)  ¸.•*¨) ¸.•*¨)
 (¸.•´ *+Randolph Chaves http://goo.gl/2dobB*  (¸.•
  (¸.•`(¸.•`


[web2py] Re: MARKMIN clarification

2012-01-02 Thread Massimo Di Pierro
I agree with you something is wrong... and needs fixing.

On Jan 2, 7:26 am, lyn2py lyn...@gmail.com wrote:
 I double-checked... there are no extra spaces after the dashes.

 I tried on a new post, this is the produced HTML:
 div class=postphere's some blockquote:
 blockquote class=this is a message
 for first para/ppthis is a message
 for second para/ppthis is a message
 for third para/blockquote
 here's some blockquote:
 --
 this is a message
 for first para/ppthis is a message
 for second para/ppthis is a message
 for third para
 --/p/div

 Thanks!

 On Jan 2, 1:01 pm, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  This could be a bug. It is possible you have extra spaces after some
  of the ?

  On Jan 1, 5:59 pm, lyn2py lyn...@gmail.com wrote:

   MARKMIN blockquote: I can't have 2 blockquotes in a single message?

   This is the text I used, and only the one on top was generated as a
   blockquote. The one below was like the rest of the body.

   here's some blockquote:
   --
   this is a message
   for first para

   this is a message
   for second para

   this is a message
   for third para
   --

   here's a second blockquote (not rendered properly):
   --
   this is a message
   for first para

   this is a message
   for second para

   this is a message
   for third para
   --

   If I add more blockquotes, the last one always doesn't render
   properly.

   Is this a bug?

   On Dec 31 2011, 12:22 am, Massimo Di Pierro

   massimo.dipie...@gmail.com wrote:
Two new lines in markmin translate into an end of paragraph in html, a
single new line is interpreted as a continuation of the same
paragraph.

On Dec 30, 1:51 am, lyn2py lyn...@gmail.com wrote:

 Does MARKMIN have issues with processing newlines?
 Because I can't use formatting here, everything looks like the same
 text, but in MARKMIN the formatting is ok, only the newlines is not
 ok.

 (1) I noticed that newlines don't convert to br in MARKMIN, which is
 strange.

 Example:
 I write this
 in two lines

 MARKMIN processes it as: I write thisin two lines

 But 2 newlines automatically converts to a paragraph (which is
 correct).

 (2) Also, when using verbatim ``

 Example:
 ``I write this``

 ``in two paragraphs``

 MARKMIN: I write thisin two paragraphs

 (3) Using a mix of verbatim/italics/bold

 Example:
 ``an edit as usual``

 ``another``

 ''one or the other''
 **could be bolded**

 MARKMIN:
 an edit as usualanother

 one or the other could be bolded

 Notice the inconsistency in processing newlines (and spaces).
 Is this correct behavior of MARKMIN?


Re: [web2py] Re: web2py with twitter bootstrap - very clean interface ...

2012-01-02 Thread Vikas Singhal
Any news on integrating it in web2py?


[web2py] Re: Cannot get janrain to work

2012-01-02 Thread jc
Thank you so much. It was driving me mad. Now it works.


Re: [web2py] Re: web2py with twitter bootstrap - very clean interface ...

2012-01-02 Thread Bruno Rocha
On Mon, Jan 2, 2012 at 11:25 AM, Vikas Singhal
vikas.program...@gmail.comwrote:

 Any news on integrating it in web2py?


I am waiting the final 2.0 version to update it

-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: redirecting python console output to web browser page

2012-01-02 Thread Ross Peoples
Yes, you can, though it's much more difficult to stream it live to a web 
page. You would need to use JavaScript (comet or polling) to get the output 
as it is generated and display it in the browser. There are many ways to do 
this, but it's not the simplest thing in the world.

Off the top of my head, I can think of a few different ways to implement 
this (though each has pros and cons):

- Simplest: load a page as usual with an iframe tag that runs the command 
and streams the output as it happens
- Better: Start the process and just AJAX calls to grab latest output and 
display
- Best/Hardest: Use comet (AJAX push) to push output to the web page

Using iframe is sometimes frowned upon as it's seen as the easy way out 
of doing complicated tasks. Using JavaScript offers some extra flexibility 
on how the output is displayed in the browser (and could even allow the 
user to interact).


[web2py] Procedurally add images?

2012-01-02 Thread vapirix
I know I can step through my database and add url paths to all of my
database entries, but is there a way to have web2py process every
image as an upload (since it's an upload field), and properly store in
the uploads folder for sake of consistency? It would be a lot better
than a year from now figuring out which images are being used from a
folder and which ones the client has uploaded themselves. I'm pre-
populating their database with the content we do have, and the client
is going to finish it off later. Simple one, Thanks, guys. =)


[web2py] Re: Architecture question: can I use Web2py template engine to generate emails?

2012-01-02 Thread Peter O
I am glad that I found this answer, after printing all the intermediary 
variables for a couple of hours.

Is this considered a Gotcha, or better be documented if it is the design? :)



[web2py] Print a page, best practice?

2012-01-02 Thread Falk
Hi,

I'm pretty new to web2py, I picked it beq I needed to get something up 
running pretty fast. 
And it seemed really nice with a good balance with framework and freedom :)
I have searched the groups and not really come up with anything that seems 
to fit.

I'm creating a simple ticketsystem to a wifi guest solution.
The thing I'm stuck with now is how to best print the tickets.

If there is any best practices with this?

Today I have my vars and send it with a redirect(URL('single_add'))
Here I use the simplest possible:
---
{{extend 'layout.html'}}
ul
lib{{=T(Name)}}:/b {{=session.vars.firstname}} 
{{=session.vars.lastname}}/li
lib{{=T(Username)}}:/b {{=session.username}} /li
lib{{=T(Password)}}: /b {{=session.value}}/li
lib{{=T(Use until)}}: /b {{=session.remove_on}}/li
/ul
a href=# onclick=window.print(); return false;Print/a  
---
The only use for this page is to print out the vars, there is no need to 
even show it on the screen.
It would be nice for the users if they not needed to press the print link.

I looked in to create a pdf and print it out, but it seems overkill for 
this little app?

Humm, perhaps this isn't making any sense to you :)

But if you have any suggestions or ideas, pls fire away.

--
Regards Falk


[web2py] Re: Procedurally add images?

2012-01-02 Thread Massimo Di Pierro
Given

db.define_table('image',Field('file','upload'))

You can do:

import glob
for filename in glob.glob('*.png'):
db.image.insert(file=db.image.file.store(open(filename,'rb')))




On Jan 2, 10:55 am, vapirix vapi...@gmail.com wrote:
 I know I can step through my database and add url paths to all of my
 database entries, but is there a way to have web2py process every
 image as an upload (since it's an upload field), and properly store in
 the uploads folder for sake of consistency? It would be a lot better
 than a year from now figuring out which images are being used from a
 folder and which ones the client has uploaded themselves. I'm pre-
 populating their database with the content we do have, and the client
 is going to finish it off later. Simple one, Thanks, guys. =)


[web2py] Re: Procedurally add images?

2012-01-02 Thread vapirix
Beautiful. Thanks, Massimo. Once again proving why this is the best
framework to get things accomplished with. =)

On Jan 2, 11:25 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Given

 db.define_table('image',Field('file','upload'))

 You can do:

 import glob
 for filename in glob.glob('*.png'):
     db.image.insert(file=db.image.file.store(open(filename,'rb')))

 On Jan 2, 10:55 am, vapirix vapi...@gmail.com wrote:







  I know I can step through my database and add url paths to all of my
  database entries, but is there a way to have web2py process every
  image as an upload (since it's an upload field), and properly store in
  the uploads folder for sake of consistency? It would be a lot better
  than a year from now figuring out which images are being used from a
  folder and which ones the client has uploaded themselves. I'm pre-
  populating their database with the content we do have, and the client
  is going to finish it off later. Simple one, Thanks, guys. =)


[web2py] Re: Print a page, best practice?

2012-01-02 Thread Anthony
Something like this using CSS media queries might 
help: http://blog.lysender.com/2009/01/printing-a-page-without-showing-it/

Anthony

On Monday, January 2, 2012 12:02:23 PM UTC-5, Falk wrote:

 Hi,

 I'm pretty new to web2py, I picked it beq I needed to get something up 
 running pretty fast. 
 And it seemed really nice with a good balance with framework and freedom :)
 I have searched the groups and not really come up with anything that seems 
 to fit.

 I'm creating a simple ticketsystem to a wifi guest solution.
 The thing I'm stuck with now is how to best print the tickets.

 If there is any best practices with this?

 Today I have my vars and send it with a redirect(URL('single_add'))
 Here I use the simplest possible:
 ---
 {{extend 'layout.html'}}
 ul
 lib{{=T(Name)}}:/b {{=session.vars.firstname}} 
 {{=session.vars.lastname}}/li
 lib{{=T(Username)}}:/b {{=session.username}} /li
 lib{{=T(Password)}}: /b {{=session.value}}/li
 lib{{=T(Use until)}}: /b {{=session.remove_on}}/li
 /ul
 a href=# onclick=window.print(); return false;Print/a  
 ---
 The only use for this page is to print out the vars, there is no need to 
 even show it on the screen.
 It would be nice for the users if they not needed to press the print link.

 I looked in to create a pdf and print it out, but it seems overkill for 
 this little app?

 Humm, perhaps this isn't making any sense to you :)

 But if you have any suggestions or ideas, pls fire away.

 --
 Regards Falk



[web2py] How can I reduce shell memory usage?

2012-01-02 Thread Michael Ellis
I have an application that  uses multiple instances of web2py shells for
long running data acquisition and analysis.

Having multiple independent processes is working really, really well but
I'd like to reduce the total memory footprint in each of them.   I'm not
finding much in the way of really good memory profiling tools and wanted to
check with the group wisdom here to see if anyone has already looked into
reducing memory in shell processes.

Below are some numbers from running a stripped out script in OS X (where I
do most of my test and development work).  In the first case, I run it
outside web2py and see that the memory footprint is a little over 4Mb.
Running the same script with web2py -S -N -M -R  shows a footprint of 25Mb.
 The target environment is Linux.  The memory use there is smaller by about
1/3 but the ratio is the same.

I make use of the objgraph module (
http://mg.pov.lt/objgraph/objgraph.html) when I interrupt the process
show the most common object types is memory
just before the script exits.  The number that really stands out is the
count of functions.  Without web2py there are 987,  with web2py 5647!!.  I
kinda suspect I don't need all of them for the scripts I'm running, :-) ,
so my first thought is what can I get rid of at start up and how do I make
python release the memory?

The only part of web2py used by the shells is the application model, the
basic db instance methods  (insert, update, select, etc.) and the DAL()
method to create a new db instance in forked children.

Any help or suggestions appreciated.
Thanks,
Mike

--
WITHOUT WEB2PY
michael-elliss-macbook:web2py mellis$ python ~/bin/memcheck.py
Memory usage: current = 4.3 MB, initial = 4.3 MB
Memory usage: current = 4.3 MB, initial = 4.3 MB
Memory usage: current = 4.3 MB, initial = 4.3 MB
^C
wrapper_descriptor 1080
*function   987*
builtin_function_or_method 661
tuple  552
method_descriptor  422
dict   415
weakref284
member_descriptor  204
list   157
getset_descriptor  141

--
WITH WEB2PY
michael-elliss-macbook:web2py mellis$ python web2py.py -S welcome -N -M -R
 ~/bin/memcheck.py
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.97.1 (2011-06-26 19:25:44)
Database drivers available: SQLite3, pymysql
Memory usage: current = 25.1 MB, initial = 25.1 MB
Memory usage: current = 25.1 MB, initial = 25.1 MB
Memory usage: current = 25.1 MB, initial = 25.1 MB
^C
*function   5647*
tuple  1663
dict   1483
wrapper_descriptor 1245
weakref1025
method_descriptor  938
builtin_function_or_method 875
list   834
type   604
getset_descriptor  495

--
HERE'S THE SCRIPT


Web2py shell app for investigating memory use
Author: Michael Ellis

import signal
DEBUGGER_INTERRUPT = False
def debug_me(signum, frame):

This signal handler provides a mechanism for remote debugging on demand.
To activate it, look up the PID for this process, and then use
'kill -SIGUSR1 PID'
to stop the process.  Then start winpdb (or rpdb2), set the password
and attach.

global DEBUGGER_INTERRUPT
try:
import rpdb2
rpdb2.start_embedded_debugger(passwd)
DEBUGGER_INTERRUPT = True
except ImportError:
print Ignoring SIGUSR1. rpdb2 is not installed.


signal.signal(signal.SIGUSR1, debug_me)


import sys
import time
import datetime
import resource
from traceback import format_exc
import gc


def get_real_mem_mb():

Return current real memory use of calling process in MB.
Useful for tracking slow memory leaks.  See man getrusage
for details of system call.

if sys.platform.startswith('darwin'):
divisor = 1024. * 1024## OS X reports bytes
elif sys.platform.startswith('linux'):
divisor = 1024.   ## Linux reports kbytes
else:
msg = Don't know what to do for platform %s. Please add a clause
to handle it.\
  % sys.platform
raise ValueError(msg)

mem = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
return mem / divisor

class MemoryLeak(Exception):
Raised by MemoryUseTrackerinstances. Behaves like a generic
exception. 
pass

class MemoryUseTracker(object):
 Tracks memory use by current process 
def __init__(self, updateseconds = 60, leakalarm = 5.0):

If the check() method is called less than updateseconds
after the last call, no check is performed.  The leakalarm
argument specifies the factor by which memory use may increase
before a MemoryLeak 

[web2py] Re: How can I reduce shell memory usage?

2012-01-02 Thread Ross Peoples
Mike,

I haven't done any profiling on it, but I've had a lot of success using the 
multiprocessing library, importing the DAL, and using it directly without 
using the rest of the web2py environment. I usually accomplish this by 
creating a module (not model) and spinning off the other processes from the 
module, as the module will stay running after the initial request finishes.

Ross


[web2py] Reading lines from uploaded SQLFORM.factory file

2012-01-02 Thread Jim Steil

Hi

I have an upload field defined in a SQLFORM.factory form as follows:

def wasptime():
from reports.payroll import wasptime
response.title = 'WASPTime Payroll Import Conversion'
form = SQLFORM.factory(
Field('importFile', 'upload', label='WASPTime File',
  uploadfolder='c:/deleteme/payroll/test'),
Field('processDate', 'date', required=True,
  requires=IS_DATE('%m/%d/%Y'),
  label='Process Date'))

if form.process().accepted:
importFile = request.vars.importFile.file
processDate = request.vars.processDate
wasptime.payrollImport(processDate, importFile, 'testfile.csv')

return dict(form=form)

in my wasptime.payrollImport method I am trying to read through the 
lines in the uploaded file using:


def payrollImport(dateWorked, f, outputFile):
for line in f.readlines():
...processing takes place here for each line in the file

but, I'm not getting any lines to print.  Can't seem to find the right 
way to handle this.


In addition, why do I need to specify an uploadfolder in the 'upload' 
field definition in SQLFORM.factory?


Thanks

-Jim




[web2py] Re: How can I reduce shell memory usage?

2012-01-02 Thread Michael Ellis
Thanks Ross,  that sounds like a good approach.  I do something
analogous in my app.   All my scripts live in the app/modules/
directory.  My app is a remote monitoring system running on a Foxconn
NetTop under Linux Mint 10.   There is a web2py http interface used
for installation and configuration, but it's not used in day-to-day
operation.
The long-running scripts are children of a master script similar to
the one I appended to my post except that it has additional code to
fork  the various child processes which, conveniently, inherit the
web2py environment including the model.  The child processes write
incoming data to the sqlitedb, read from it to compute averaged data
that gets sent a server in the cloud,  monitor for anomalous
conditions and send email alerts, etc.  The master script does little
more than launch the children, monitor them, and relaunch any that
crash.
What arguments do you use in your calls to DAL() to read in your
model? I just pass 'storage.sqlite' and DAL() knows which app/database
directory to use since the app name is passed in the web2py -S
invocation.  Do you have to do anything special when importing dal to
make it work without the web2py shell?
Cheers,Mike

On Jan 2, 1:32 pm, Ross Peoples ross.peop...@gmail.com wrote:
 Mike,

 I haven't done any profiling on it, but I've had a lot of success using the
 multiprocessing library, importing the DAL, and using it directly without
 using the rest of the web2py environment. I usually accomplish this by
 creating a module (not model) and spinning off the other processes from the
 module, as the module will stay running after the initial request finishes.

 Ross


[web2py] Re: redirecting python console output to web browser page

2012-01-02 Thread Paolo Caruccio
There is another HTML5 technology to push stream from server to client : 
EventSource aka Sent-Server Events (http://dev.w3.org/html5/eventsource/). 
Its behaviour is like ajax long polling.
I'm - just now - experimenting a simple mechanism to send to clients a 
message when the database changes.
Pros : The implementation is enough simple.
Cons : IE9 doesn't support EventSource.





[web2py] Re: How can I reduce shell memory usage?

2012-01-02 Thread Michael Ellis
Found some advice from Massimo in another thread.

After adding

try:
_junk = db
except NameError:
_w2pdir = /Users/mellis/web2py/
sys.path.append(_w2pdir)
from gluon import DAL
db = DAL(sqlite://storage.sqlite,
  folder = _w2pdir + applications/welcome/databases,
  auto_import = True)

to my test script, running it without web2py gets the memory footprint
down from 25 Mb to 13Mb.  That's definitely an improvement.  Anyone
know how to shave it further? It still seems a little high for what
it's doing.



On Jan 2, 3:01 pm, Michael Ellis michael.f.el...@gmail.com wrote:
 Thanks Ross,  that sounds like a good approach.  I do something
 analogous in my app.   All my scripts live in the app/modules/
 directory.  My app is a remote monitoring system running on a Foxconn
 NetTop under Linux Mint 10.   There is a web2py http interface used
 for installation and configuration, but it's not used in day-to-day
 operation.
 The long-running scripts are children of a master script similar to
 the one I appended to my post except that it has additional code to
 fork  the various child processes which, conveniently, inherit the
 web2py environment including the model.  The child processes write
 incoming data to the sqlitedb, read from it to compute averaged data
 that gets sent a server in the cloud,  monitor for anomalous
 conditions and send email alerts, etc.  The master script does little
 more than launch the children, monitor them, and relaunch any that
 crash.
 What arguments do you use in your calls to DAL() to read in your
 model? I just pass 'storage.sqlite' and DAL() knows which app/database
 directory to use since the app name is passed in the web2py -S
 invocation.  Do you have to do anything special when importing dal to
 make it work without the web2py shell?
 Cheers,Mike

 On Jan 2, 1:32 pm, Ross Peoples ross.peop...@gmail.com wrote:







  Mike,

  I haven't done any profiling on it, but I've had a lot of success using the
  multiprocessing library, importing the DAL, and using it directly without
  using the rest of the web2py environment. I usually accomplish this by
  creating a module (not model) and spinning off the other processes from the
  module, as the module will stay running after the initial request finishes.

  Ross


Re: [web2py] Reading lines from uploaded SQLFORM.factory file

2012-01-02 Thread Jim Steil

found the solution.

in the code below, change line

importfile = request.vars.importFile.file

to

importfile = request.vars.importFile.value

Still don't know why I need the uploadfolder, but this solved my main issue.

-Jim


On 1/2/2012 12:39 PM, Jim Steil wrote:

Hi

I have an upload field defined in a SQLFORM.factory form as follows:

def wasptime():
from reports.payroll import wasptime
response.title = 'WASPTime Payroll Import Conversion'
form = SQLFORM.factory(
Field('importFile', 'upload', label='WASPTime File',
  uploadfolder='c:/deleteme/payroll/test'),
Field('processDate', 'date', required=True,
  requires=IS_DATE('%m/%d/%Y'),
  label='Process Date'))

if form.process().accepted:
importFile = request.vars.importFile.file
processDate = request.vars.processDate
wasptime.payrollImport(processDate, importFile, 'testfile.csv')

return dict(form=form)

in my wasptime.payrollImport method I am trying to read through the 
lines in the uploaded file using:


def payrollImport(dateWorked, f, outputFile):
for line in f.readlines():
...processing takes place here for each line in the file

but, I'm not getting any lines to print.  Can't seem to find the right 
way to handle this.


In addition, why do I need to specify an uploadfolder in the 'upload' 
field definition in SQLFORM.factory?


Thanks

-Jim




[web2py] Web2Py Blob Upload/Download Samples for GAE?

2012-01-02 Thread Gerard
Hi everyone, I've written python code running in appengine using their
webapp framework.  I'm trying to figure out how to upload blobs.  Does
anyone know of a tutorial or sample online of a web2py controller that
uploads a blob?  Thanks.


[web2py] Re: Web2Py Blob Upload/Download Samples for GAE?

2012-01-02 Thread Alan Etkin
There is an example of file upload with blob in the book:

13.4.5 Uploading files in database

This thread is about GAE file threshold
http://groups.google.com/group/web2py/browse_thread/thread/3f941a16d512d3e/08e3f88869e122ee?lnk=gstq=gae+uploads#08e3f88869e122ee

For download of files there is also information in the book:

4.8 response

On 2 ene, 18:23, Gerard gerardc...@gmail.com wrote:
 Hi everyone, I've written python code running in appengine using their
 webapp framework.  I'm trying to figure out how to upload blobs.  Does
 anyone know of a tutorial or sample online of a web2py controller that
 uploads a blob?  Thanks.


[web2py] Re: Reading lines from uploaded SQLFORM.factory file

2012-01-02 Thread Alan Etkin
Uploadfolder sets a custom folder instead of app/uploads. The function
parameters are available at API docs:

http://web2py.com/examples/static/epydoc/web2py.gluon.dal.Field-class.html

On 2 ene, 18:34, Jim Steil j...@qlf.com wrote:
 found the solution.

 in the code below, change line

 importfile = request.vars.importFile.file

 to

 importfile = request.vars.importFile.value

 Still don't know why I need the uploadfolder, but this solved my main issue.

      -Jim

 On 1/2/2012 12:39 PM, Jim Steil wrote:

  Hi

  I have an upload field defined in a SQLFORM.factory form as follows:

  def wasptime():
      from reports.payroll import wasptime
      response.title = 'WASPTime Payroll Import Conversion'
      form = SQLFORM.factory(
              Field('importFile', 'upload', label='WASPTime File',
                    uploadfolder='c:/deleteme/payroll/test'),
              Field('processDate', 'date', required=True,
                    requires=IS_DATE('%m/%d/%Y'),
                    label='Process Date'))

      if form.process().accepted:
          importFile = request.vars.importFile.file
          processDate = request.vars.processDate
          wasptime.payrollImport(processDate, importFile, 'testfile.csv')

      return dict(form=form)

  in my wasptime.payrollImport method I am trying to read through the
  lines in the uploaded file using:

  def payrollImport(dateWorked, f, outputFile):
      for line in f.readlines():
          ...processing takes place here for each line in the file

  but, I'm not getting any lines to print.  Can't seem to find the right
  way to handle this.

  In addition, why do I need to specify an uploadfolder in the 'upload'
  field definition in SQLFORM.factory?

  Thanks

      -Jim




[web2py] processing user input

2012-01-02 Thread Adrian Edwards
Hello all,

I have a page where a user enters in some data, and then some
calculations need to occur before the data is put into the database.

Right now I have
   form = SQLFORM(db.entries, entry)
and whatever the user enters is successfully put into db.entries.
So now I want to do the calculations before populating the database,
but not sure how.

Any suggestions?

Thanks.
Adrian


[web2py] Re: processing user input

2012-01-02 Thread Adrian Edwards
to expand on this a bit, I tried to put the calculations before the
 if form.process().accepted:

but I haven't been able to figure out how to access the value entered
by the user.
So this may just be as simple as accessing something like
form.custom.widget.value


Adrian.

On Jan 2, 7:35 pm, Adrian Edwards aedward...@gmail.com wrote:
 Hello all,

 I have a page where a user enters in some data, and then some
 calculations need to occur before the data is put into the database.

 Right now I have
    form = SQLFORM(db.entries, entry)
 and whatever the user enters is successfully put into db.entries.
 So now I want to do the calculations before populating the database,
 but not sure how.

 Any suggestions?

 Thanks.
 Adrian


[web2py] csv conflict in model

2012-01-02 Thread Plumo
I get an error when trying to parse CSV data in my model:

for row in csv.reader(open(sample_file)):
AttributeError: 'function' object has no attribute 'reader'

It seems the problem is that appadmin.py has a csv() function that overrides 
the csv import in my model. I tried renaming this function and the error 
stopped.

So, should this function be renamed?

Richard



[web2py] Re: dropbox python api

2012-01-02 Thread Joseph Jude
To use this do you need APIs both from dropbox  janrain?

Thank you,
Joseph


[web2py] Re: processing user input

2012-01-02 Thread lyn2py
To access the form values, use:

if form.process().accepted:
value = form.vars.some_field

If you will be changing the values inserted, use:

if form.process(dbio=false).accepted:
form.vars.some_field = modify(form.vars.some_field)
#but you will need to insert data into the db yourself

Happy New Year! :)

On Jan 3, 8:39 am, Adrian Edwards aedward...@gmail.com wrote:
 to expand on this a bit, I tried to put the calculations before the
  if form.process().accepted:

 but I haven't been able to figure out how to access the value entered
 by the user.
 So this may just be as simple as accessing something like
 form.custom.widget.value

 Adrian.

 On Jan 2, 7:35 pm, Adrian Edwards aedward...@gmail.com wrote:







  Hello all,

  I have a page where a user enters in some data, and then some
  calculations need to occur before the data is put into the database.

  Right now I have
     form = SQLFORM(db.entries, entry)
  and whatever the user enters is successfully put into db.entries.
  So now I want to do the calculations before populating the database,
  but not sure how.

  Any suggestions?

  Thanks.
  Adrian


[web2py] Re: compute field error

2012-01-02 Thread Plumo
thanks - problem solved

[web2py] Re: csv conflict in model

2012-01-02 Thread Anthony
Hmm, maybe we shouldn't have a function with the same name as a Python 
standard lib module. For, now, you could also do:

import csv as stdlib_csv
stdlib_csv.reader(...)

or

from csv import reader
reader(...)

Anthony

On Monday, January 2, 2012 8:18:33 PM UTC-5, Plumo wrote:

 I get an error when trying to parse CSV data in my model:

 for row in csv.reader(open(sample_file)):
 AttributeError: 'function' object has no attribute 'reader'

 It seems the problem is that appadmin.py has a csv() function that overrides 
 the csv import in my model. I tried renaming this function and the error 
 stopped.

 So, should this function be renamed?

 Richard



[web2py] Re: processing user input

2012-01-02 Thread Anthony
You can use the 'onvalidation' 
callback: http://web2py.com/books/default/chapter/29/7#onvalidation

form.process(..., onvalidation=my_form_calculation)

You can also define a custom validator for the field to calculate and 
return the transformed value -- 
see http://web2py.com/books/default/chapter/29/7#Custom-validators.

Finally, if you want to do something with the submitted vars before 
validation, you can access the vars in request.vars.

Anthony

On Monday, January 2, 2012 7:39:46 PM UTC-5, Adrian Edwards wrote:

 to expand on this a bit, I tried to put the calculations before the 
  if form.process().accepted: 

 but I haven't been able to figure out how to access the value entered 
 by the user. 
 So this may just be as simple as accessing something like 
 form.custom.widget.value 


 Adrian. 

 On Jan 2, 7:35 pm, Adrian Edwards aedwa...@gmail.com wrote: 
  Hello all, 
  
  I have a page where a user enters in some data, and then some 
  calculations need to occur before the data is put into the database. 
  
  Right now I have 
 form = SQLFORM(db.entries, entry) 
  and whatever the user enters is successfully put into db.entries. 
  So now I want to do the calculations before populating the database, 
  but not sure how. 
  
  Any suggestions? 
  
  Thanks. 
  Adrian



[web2py] Re: Deployment problem on dotcloud with PostgreSQL

2012-01-02 Thread Jérôme Petazzoni
Hi Thomas,

web2py used to work fine on dotCloud. I remember writing the web2py 
tutorial 1 year ago :-)
The tutorial needs to be updated, since the CLI has evolved significantly 
since then.
Anyway! If I remember well, when trying some web2py apps, I had the 
following issues:
- a lot of apps define a user model (it seems to be implicit; maybe by 
enabling some kind of default auth model or session management? I'm pretty 
clueless about the root cause of the issue), which requires proper schema 
namespacing (i.e., the ORM should generate queries to public.user instead 
of just user, otherwise it hits the PostgreSQL user table)
- the ORM seems to sometimes generate invalid SQL—I have to dig my records, 
but it was something like missing or improper quoting.

If someone can point me to a best practice web2py app, I can do my best 
and update the dotCloud tutorial by using this app as an example.

Best regards  happy new year everyone!


[web2py] how to integrate web2py with existing static website

2012-01-02 Thread Plumo
hello,

I have an existing static website (generated by jekyll):

domain.com
domain.com/blog

and then I have some web2py apps served under sub-domains:

sales.domain.com
contact.domain.com

For various reasons I want the web2py apps served alongside the static part 
under sub-directories:

domain.com/sales
domain.com/contact

How would you suggest achieving this?
Currently both parts are served by nginx.

Richard


[web2py] Re: How can I reduce shell memory usage?

2012-01-02 Thread Massimo Di Pierro
I remind you

web2py/scripts/make_min_web2py.py

which makes web2py much smaller by eliminating rarely used module that
consume lots of space.
I am not sure about the impact on Ram but the impact on Disk space is
significative.

Massimo

On Jan 2, 3:04 pm, Michael Ellis michael.f.el...@gmail.com wrote:
 Found some advice from Massimo in another thread.

 After adding

 try:
     _junk = db
 except NameError:
     _w2pdir = /Users/mellis/web2py/
     sys.path.append(_w2pdir)
     from gluon import DAL
     db = DAL(sqlite://storage.sqlite,
               folder = _w2pdir + applications/welcome/databases,
               auto_import = True)

 to my test script, running it without web2py gets the memory footprint
 down from 25 Mb to 13Mb.  That's definitely an improvement.  Anyone
 know how to shave it further? It still seems a little high for what
 it's doing.

 On Jan 2, 3:01 pm, Michael Ellis michael.f.el...@gmail.com wrote:







  Thanks Ross,  that sounds like a good approach.  I do something
  analogous in my app.   All my scripts live in the app/modules/
  directory.  My app is a remote monitoring system running on a Foxconn
  NetTop under Linux Mint 10.   There is a web2py http interface used
  for installation and configuration, but it's not used in day-to-day
  operation.
  The long-running scripts are children of a master script similar to
  the one I appended to my post except that it has additional code to
  fork  the various child processes which, conveniently, inherit the
  web2py environment including the model.  The child processes write
  incoming data to the sqlitedb, read from it to compute averaged data
  that gets sent a server in the cloud,  monitor for anomalous
  conditions and send email alerts, etc.  The master script does little
  more than launch the children, monitor them, and relaunch any that
  crash.
  What arguments do you use in your calls to DAL() to read in your
  model? I just pass 'storage.sqlite' and DAL() knows which app/database
  directory to use since the app name is passed in the web2py -S
  invocation.  Do you have to do anything special when importing dal to
  make it work without the web2py shell?
  Cheers,Mike

  On Jan 2, 1:32 pm, Ross Peoples ross.peop...@gmail.com wrote:

   Mike,

   I haven't done any profiling on it, but I've had a lot of success using 
   the
   multiprocessing library, importing the DAL, and using it directly without
   using the rest of the web2py environment. I usually accomplish this by
   creating a module (not model) and spinning off the other processes from 
   the
   module, as the module will stay running after the initial request 
   finishes.

   Ross


[web2py] Re: dropbox python api

2012-01-02 Thread Massimo Di Pierro
Only dropbox

On Jan 2, 7:38 pm, Joseph Jude ceph...@gmail.com wrote:
 To use this do you need APIs both from dropbox  janrain?

 Thank you,
 Joseph


[web2py] How can I access HTTP Headers?

2012-01-02 Thread James M.
I need to get a request header that is being sent with an http post.
I thought I could access it with something like:
request.headers['HTTP_SOME_HEADER']
but it doesn't work... I looked at all request attributes and don't
see the headers.
Any idea how to get it?


[web2py] Re: How can I access HTTP Headers?

2012-01-02 Thread lyn2py
What headers are you specifically looking for that are not available?

Have you looked under request.env, e.g. request.env.http_referer (and
other headers like http_host, http_user_agent)?


On Jan 3, 12:31 pm, James M. sipajah...@gmail.com wrote:
 I need to get a request header that is being sent with an http post.
 I thought I could access it with something like:
 request.headers['HTTP_SOME_HEADER']
 but it doesn't work... I looked at all request attributes and don't
 see the headers.
 Any idea how to get it?


[web2py] Re: How can I access HTTP Headers?

2012-01-02 Thread Anthony
I think the 'Your-Header' header should be accessible via:

request.env.http_your_header

or

request.wsgi.environ.HTTP_YOUR_HEADER

Anthony

On Monday, January 2, 2012 11:31:49 PM UTC-5, James M. wrote:

 I need to get a request header that is being sent with an http post. 
 I thought I could access it with something like: 
 request.headers['HTTP_SOME_HEADER'] 
 but it doesn't work... I looked at all request attributes and don't 
 see the headers. 
 Any idea how to get it?



[web2py] Re: how to integrate web2py with existing static website

2012-01-02 Thread Massimo Di Pierro
You can do at the level of the web server. If you are using rocket
only...
create an app called dummy and put the static side under dummy/static

create a routes.py that says:

routes_in = [('.*:http://domain.com:GET /$anything','/dummy/static/
$anything')]

it will map any ($anything) GET request to http://domain.com to /dummy/
static/$anything
Notice that in this case you do not need routes_out because the URL
helper is never used.


On Jan 2, 9:35 pm, Plumo richar...@gmail.com wrote:
 hello,

 I have an existing static website (generated by jekyll):

 domain.com
 domain.com/blog

 and then I have some web2py apps served under sub-domains:

 sales.domain.com
 contact.domain.com

 For various reasons I want the web2py apps served alongside the static part
 under sub-directories:

 domain.com/sales
 domain.com/contact

 How would you suggest achieving this?
 Currently both parts are served by nginx.

 Richard


[web2py] Re: How can I access HTTP Headers?

2012-01-02 Thread James M.
I am using twilio.  When twilio posts to the url I supplied, they sign
the request with a customer HTTP header X-Twilio-Signature, which I
can use to validate that it is actually twilio making the request.

On Jan 2, 9:17 pm, lyn2py lyn...@gmail.com wrote:
 What headers are you specifically looking for that are not available?

 Have you looked under request.env, e.g. request.env.http_referer (and
 other headers like http_host, http_user_agent)?

 On Jan 3, 12:31 pm, James M. sipajah...@gmail.com wrote:







  I need to get a request header that is being sent with an http post.
  I thought I could access it with something like:
  request.headers['HTTP_SOME_HEADER']
  but it doesn't work... I looked at all request attributes and don't
  see the headers.
  Any idea how to get it?


[web2py] Re: How can I access HTTP Headers?

2012-01-02 Thread James M.
I looked into those two suggestions, the header doesn't seem to be
available.

I am starting to think that custom headers aren't passed to web2py...

On Jan 2, 9:26 pm, Anthony abasta...@gmail.com wrote:
 I think the 'Your-Header' header should be accessible via:

 request.env.http_your_header

 or

 request.wsgi.environ.HTTP_YOUR_HEADER

 Anthony







 On Monday, January 2, 2012 11:31:49 PM UTC-5, James M. wrote:

  I need to get a request header that is being sent with an http post.
  I thought I could access it with something like:
  request.headers['HTTP_SOME_HEADER']
  but it doesn't work... I looked at all request attributes and don't
  see the headers.
  Any idea how to get it?


[web2py] Re: Error creating tables on a MySQL database on DotCloud?

2012-01-02 Thread Thomas Dall'Agnese
Actually, I just tried on FluxFlex and it doesn't work neither!

I have the same error if I use the MySQL database (provided by FluxFlex) 
but it works using SQLite.

The project is open source, available here:
https://github.com/ThomasDalla/FansubCheck_web2py/tree/master/public_html/applications/fansubcheck

The error occurs on a different table though: mysql.balises_archive.

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.

Traceback (most recent call last):
  File /home/fansubcheck/public_html/gluon/restricted.py, line 204, in 
restricted
exec ccode in environment
  File 
/home/fansubcheck/public_html/applications/fansubcheck/models/db_wizard.py 
https://fansubcheck.fluxflex.com/admin/default/edit/fansubcheck/models/db_wizard.py,
 line 24, in module

db.define_table('balise_archive',db.balise,Field('current_record','reference 
balise',readable=False,writable=False))
  File /home/fansubcheck/public_html/gluon/dal.py, line 5097, in define_table
polymodel=polymodel)
  File /home/fansubcheck/public_html/gluon/dal.py, line 705, in create_table
self.create_sequence_and_triggers(query,table)
  File /home/fansubcheck/public_html/gluon/dal.py, line 1348, in 
create_sequence_and_triggers
self.execute(query)
  File /home/fansubcheck/public_html/gluon/dal.py, line 1359, in execute
return self.log_execute(*a, **b)
  File /home/fansubcheck/public_html/gluon/dal.py, line 1353, in log_execute
ret = self.cursor.execute(*a, **b)
  File /home/fansubcheck/public_html/gluon/contrib/pymysql/cursors.py, line 
108, in execute
self.errorhandler(self, exc, value)
  File /home/fansubcheck/public_html/gluon/contrib/pymysql/connections.py, 
line 184, in defaulterrorhandler
raise errorclass, errorvalue
InternalError: (1005, uCan't create table 'fansubcheck.balise_archive' (errno: 
150))


You can create a new web2py application and import my github project:
g...@github.com:ThomasDalla/FansubCheck_web2py.git
You should have the same error...

Any idea why this error occurs?