[web2py] slideshow widget plugin

2010-08-10 Thread Hans
I'm trying to use this widget on localhost on source version of web2py
1.82.1 but running into the error below. other widgets like jqgrid or
select are working fine.

how can I get slideshow working?

``
name: slideshow
table: coin
field: edge
transition: fade
width: 200
height: 200
``:widget

db.define_table('coin',
Field('country', db.country),
Field('national_side','upload'),
Field('common_side', 'upload'),
Field('edge', 'upload'),
Field('date_of_issue','date'),
Field('issue_volume','integer'),
Field('artist','string'),
Field('feature','string'),
Field('description','text'),
Field('approved_by', db.auth_user, default=None),
timestamp,
format=lambda row: '%s | %s | %s' %
(row.country.name,str(row.date_of_issue)[0:4],row.feature))

Traceback (most recent call last):
  File "C:\Dokumente und Einstellungen\Hans\Desktop\coins\server\web2py
\applications\coins/models/plugin_wiki.py", line 584, in render_widget
html = getattr(PluginWikiWidgets,name)(**args)
  File "C:\Dokumente und Einstellungen\Hans\Desktop\coins\server\web2py
\applications\coins/models/plugin_wiki.py", line 356, in slideshow
images =
[IMG(_src=URL(r=request,c='default',d='download',args=row[field])) for
row in rows]
  File "C:\Dokumente und Einstellungen\Hans\Desktop\coins\server\web2py
\gluon\html.py", line 224, in _URL
return URL(*args, **kwargs)
TypeError: URL() got an unexpected keyword argument 'd'


[web2py:23269] Re: web2py 1.63.4 is OUT

2009-06-04 Thread Hans

I just downloaded 1.63.5 from web2py.com and could not find release/
change notes for this version in the README file or here. Maybe it
should be version 1.63.4 ?

Keep up the great work!

Hans

On 4 Jun., 06:03, mdipierro  wrote:
> I just posted 1.63.4 because I patch in 1.63.3 had broken Python 2.4
> and it was an urgent matter.
> I think the problem is now fixed.
>
> Changelog:
> - fixed python 2.4
> - fixed problem with strange char encoding of absolute paths in sqlite
> on windows. Thanks Iceberg.
>
> Massimo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23288] global logging to file

2009-06-04 Thread Hans

I tried to define a global logging for a web2py app. The problem with
that is that if I place the following code in my default.py controller
or db.py model then in both cases its executed more than
once...resulting into having every log line written multiple times
into the log file.

either starting the default.py or db.py with those lines is yielding
the same result
import logging, logging.handlers

# Make a global logging object.
lox = logging.getLogger("log")
lox.setLevel(logging.DEBUG)

# This handler writes everything to a file.
h1 = logging.FileHandler("/var/log/myapp.log")
f = logging.Formatter("%(levelname)s %(asctime)s %(funcName)s %
(lineno)d %(message)s")
h1.setFormatter(f)
h1.setLevel(logging.DEBUG)
lox.addHandler(h1)

# This handler emails me anything that is an error or worse.
h2 = logging.handlers.SMTPHandler('localhost', 'l...@test.com',
['tobenotif...@test.com'], 'ERROR log')
h2.setLevel(logging.ERROR)
h2.setFormatter(f)
lox.addHandler(h2)

log usage example in controller...
def index():
log = logging.getLogger("log")
log.debug("starting...")
do something
log.debug("finishing...")
return()

log file looks like:
DEBUG 2009-06-04 20:27:45,617 index 1 starting...
DEBUG 2009-06-04 20:27:45,617 index 1 starting...
DEBUG 2009-06-04 20:27:45,617 index 1 starting...
DEBUG 2009-06-04 20:27:50,617 index 1 finishing...
DEBUG 2009-06-04 20:27:50,617 index 1 finishing...
DEBUG 2009-06-04 20:27:50,617 index 1 finishing...

how can I fix the 'multiple problem' ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23327] Re: global logging to file

2009-06-05 Thread Hans

yes confirmed, the controller is called multiple times. the reason I
found is that the redirect() statements I use cause this. every
redirect() seems to call the controller, not only the redirection
target function.

for example my index is mainly a redirect function, based on settings
its for instance doing
 redirect(URL(r=request,f='f1'))

then also in other functions I use redirects e.g. based on rights/
settings.

I'm using 1.63.5 on WinXP SP3.

Is there a better function than redirect() for avoiding to call the
general controller stuff multiple times?
Is redirect() supposed to also call the general controller stuff or
only directly the redirection target function ?

Thanks,
Hans
On Jun 4, 10:48 pm, mdipierro  wrote:
> Odd I think your controller is being called 3 times. Is that possible?
> I would add a print statement to check.
>
> On Jun 4, 2:29 pm, Hans 
> wrote:
>
> > I tried to define a global logging for a web2py app. The problem with
> > that is that if I place the following code in my default.py controller
> > or db.py model then in both cases its executed more than
> > once...resulting into having every log line written multiple times
> > into the log file.
>
> > either starting the default.py or db.py with those lines is yielding
> > the same result
> >     import logging, logging.handlers
>
> >     # Make a global logging object.
> >     lox = logging.getLogger("log")
> >     lox.setLevel(logging.DEBUG)
>
> >     # This handler writes everything to a file.
> >     h1 = logging.FileHandler("/var/log/myapp.log")
> >     f = logging.Formatter("%(levelname)s %(asctime)s %(funcName)s %
> > (lineno)d %(message)s")
> >     h1.setFormatter(f)
> >     h1.setLevel(logging.DEBUG)
> >     lox.addHandler(h1)
>
> >     # This handler emails me anything that is an error or worse.
> >     h2 = logging.handlers.SMTPHandler('localhost', '@test.com',
> > ['tobenotif...@test.com'], 'ERROR log')
> >     h2.setLevel(logging.ERROR)
> >     h2.setFormatter(f)
> >     lox.addHandler(h2)
>
> > log usage example in controller...
> >     def index():
> >         log = logging.getLogger("log")
> >         log.debug("starting...")
> >         do something
> >         log.debug("finishing...")
> >         return()
>
> > log file looks like:
> > DEBUG 2009-06-04 20:27:45,617 index 1 starting...
> > DEBUG 2009-06-04 20:27:45,617 index 1 starting...
> > DEBUG 2009-06-04 20:27:45,617 index 1 starting...
> > DEBUG 2009-06-04 20:27:50,617 index 1 finishing...
> > DEBUG 2009-06-04 20:27:50,617 index 1 finishing...
> > DEBUG 2009-06-04 20:27:50,617 index 1 finishing...
>
> > how can I fix the 'multiple problem' ?
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23333] Re: global logging to file

2009-06-05 Thread Hans

Correction: redirect() usage is NOT causing the problem. Every call of
a controller function also executes
1) general parts of the model (db.py)
2) general parts of the controller (default.py)
3) the requested function in controller

In my case every click to an menu function adds another multiple for
log entries.

Thinking about the response.menu example which gives you different
menu options depending on the user being logged in or not I'm
convinced that the general controller sections are executed before
each requested function. That's good for the dynamically changing menu
and other needs.

For a log file function which should be available for the entire
controller I need to make sure its executed only once. Is there a
simple way to do that or a different way to achieve a log file
function (similar like my example up in this thread) available for the
entire controller?

Thanks,
Hans
On Jun 5, 2:34 pm, Hans 
wrote:
> yes confirmed, the controller is called multiple times. the reason I
> found is that the redirect() statements I use cause this. every
> redirect() seems to call the controller, not only the redirection
> target function.
>
> for example my index is mainly a redirect function, based on settings
> its for instance doing
>  redirect(URL(r=request,f='f1'))
>
> then also in other functions I use redirects e.g. based on rights/
> settings.
>
> I'm using 1.63.5 on WinXP SP3.
>
> Is there a better function than redirect() for avoiding to call the
> general controller stuff multiple times?
> Is redirect() supposed to also call the general controller stuff or
> only directly the redirection target function ?
>
> Thanks,
> Hans
> On Jun 4, 10:48 pm, mdipierro  wrote:
>
> > Odd I think your controller is being called 3 times. Is that possible?
> > I would add a print statement to check.
>
> > On Jun 4, 2:29 pm, Hans 
> > wrote:
>
> > > I tried to define a global logging for a web2py app. The problem with
> > > that is that if I place the following code in my default.py controller
> > > or db.py model then in both cases its executed more than
> > > once...resulting into having every log line written multiple times
> > > into the log file.
>
> > > either starting the default.py or db.py with those lines is yielding
> > > the same result
> > >     import logging, logging.handlers
>
> > >     # Make a global logging object.
> > >     lox = logging.getLogger("log")
> > >     lox.setLevel(logging.DEBUG)
>
> > >     # This handler writes everything to a file.
> > >     h1 = logging.FileHandler("/var/log/myapp.log")
> > >     f = logging.Formatter("%(levelname)s %(asctime)s %(funcName)s %
> > > (lineno)d %(message)s")
> > >     h1.setFormatter(f)
> > >     h1.setLevel(logging.DEBUG)
> > >     lox.addHandler(h1)
>
> > >     # This handler emails me anything that is an error or worse.
> > >     h2 = logging.handlers.SMTPHandler('localhost', '@test.com',
> > > ['tobenotif...@test.com'], 'ERROR log')
> > >     h2.setLevel(logging.ERROR)
> > >     h2.setFormatter(f)
> > >     lox.addHandler(h2)
>
> > > log usage example in controller...
> > >     def index():
> > >         log = logging.getLogger("log")
> > >         log.debug("starting...")
> > >         do something
> > >         log.debug("finishing...")
> > >         return()
>
> > > log file looks like:
> > > DEBUG 2009-06-04 20:27:45,617 index 1 starting...
> > > DEBUG 2009-06-04 20:27:45,617 index 1 starting...
> > > DEBUG 2009-06-04 20:27:45,617 index 1 starting...
> > > DEBUG 2009-06-04 20:27:50,617 index 1 finishing...
> > > DEBUG 2009-06-04 20:27:50,617 index 1 finishing...
> > > DEBUG 2009-06-04 20:27:50,617 index 1 finishing...
>
> > > how can I fix the 'multiple problem' ?
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23379] Re: global logging to file

2009-06-05 Thread Hans

The problem I have with my code for generating log files that the part
of the code (see first posting in this thread) which is outside any
function in the controller (because it should be available for all
functions in this controller) is executed every time a function is
called. I have not found a way to execute it only once intitially and
prevent multiple executions. Hence it registeres log handlers every
time the controller is executed which causes every log line to be
written multiple times into the log file.

The following did not work:

try:
done_once
except:
place code to be executed only once here
global done_once
done_once=true

because the variable done_once is undefined each time the controller
is executed again.

How can a code in the controller be executed only once?
Also completely different approach suggestions are welcome!

Thanks,
Hans
On Jun 5, 4:36 pm, mdipierro  wrote:
> Sorry Hans, I still do not understand the problem.
>
> code outside function is executed when a function in the controller is
> called (whatever the function) code in the function is executed only
> when that function is called. A call to redirect causes the browser to
> make another request thus the controller is executed again.
>
> Massimo
>
> On Jun 5, 8:08 am, Hans 
> wrote:
>
> > Correction: redirect() usage is NOT causing the problem. Every call of
> > a controller function also executes
> > 1) general parts of the model (db.py)
> > 2) general parts of the controller (default.py)
> > 3) the requested function in controller
>
> > In my case every click to an menu function adds another multiple for
> > log entries.
>
> > Thinking about the response.menu example which gives you different
> > menu options depending on the user being logged in or not I'm
> > convinced that the general controller sections are executed before
> > each requested function. That's good for the dynamically changing menu
> > and other needs.
>
> > For a log file function which should be available for the entire
> > controller I need to make sure its executed only once. Is there a
> > simple way to do that or a different way to achieve a log file
> > function (similar like my example up in this thread) available for the
> > entire controller?
>
> > Thanks,
> > Hans
> > On Jun 5, 2:34 pm, Hans 
> > wrote:
>
> > > yes confirmed, the controller is called multiple times. the reason I
> > > found is that the redirect() statements I use cause this. every
> > > redirect() seems to call the controller, not only the redirection
> > > target function.
>
> > > for example my index is mainly a redirect function, based on settings
> > > its for instance doing
> > >  redirect(URL(r=request,f='f1'))
>
> > > then also in other functions I use redirects e.g. based on rights/
> > > settings.
>
> > > I'm using 1.63.5 on WinXP SP3.
>
> > > Is there a better function than redirect() for avoiding to call the
> > > general controller stuff multiple times?
> > > Is redirect() supposed to also call the general controller stuff or
> > > only directly the redirection target function ?
>
> > > Thanks,
> > > Hans
> > > On Jun 4, 10:48 pm, mdipierro  wrote:
>
> > > > Odd I think your controller is being called 3 times. Is that possible?
> > > > I would add a print statement to check.
>
> > > > On Jun 4, 2:29 pm, Hans 
> > > > wrote:
>
> > > > > I tried to define a global logging for a web2py app. The problem with
> > > > > that is that if I place the following code in my default.py controller
> > > > > or db.py model then in both cases its executed more than
> > > > > once...resulting into having every log line written multiple times
> > > > > into the log file.
>
> > > > > either starting the default.py or db.py with those lines is yielding
> > > > > the same result
> > > > >     import logging, logging.handlers
>
> > > > >     # Make a global logging object.
> > > > >     lox = logging.getLogger("log")
> > > > >     lox.setLevel(logging.DEBUG)
>
> > > > >     # This handler writes everything to a file.
> > > > >     h1 = logging.FileHandler("/var/log/myapp.log")
> > > > >     f = logging.Formatter("%(levelname)s %(asctime)s %(funcName)s %
> > > > > (lineno)d %(message)s")
> > > > >     h1.setFormatter(f)
> > > > >     h1.setLevel(

[web2py:23380] Re: global logging to file

2009-06-05 Thread Hans

The problem I have with my code for generating log files that the part
of the code (see first posting in this thread) which is outside any
function in the controller (because it should be available for all
functions in this controller) is executed every time a function is
called. I have not found a way to execute it only once intitially and
prevent multiple executions. Hence it registeres log handlers every
time the controller is executed which causes every log line to be
written multiple times into the log file.

The following did not work:

try:
done_once
except:
place code to be executed only once here
global done_once
done_once=true

because the variable done_once is undefined each time the controller
is executed again.

How can a code in the controller be executed only once?
Also completely different approach suggestions are welcome!

Thanks,
Hans
On Jun 5, 4:36 pm, mdipierro  wrote:
> Sorry Hans, I still do not understand the problem.
>
> code outside function is executed when a function in the controller is
> called (whatever the function) code in the function is executed only
> when that function is called. A call to redirect causes the browser to
> make another request thus the controller is executed again.
>
> Massimo
>
> On Jun 5, 8:08 am, Hans 
> wrote:
>
> > Correction: redirect() usage is NOT causing the problem. Every call of
> > a controller function also executes
> > 1) general parts of the model (db.py)
> > 2) general parts of the controller (default.py)
> > 3) the requested function in controller
>
> > In my case every click to an menu function adds another multiple for
> > log entries.
>
> > Thinking about the response.menu example which gives you different
> > menu options depending on the user being logged in or not I'm
> > convinced that the general controller sections are executed before
> > each requested function. That's good for the dynamically changing menu
> > and other needs.
>
> > For a log file function which should be available for the entire
> > controller I need to make sure its executed only once. Is there a
> > simple way to do that or a different way to achieve a log file
> > function (similar like my example up in this thread) available for the
> > entire controller?
>
> > Thanks,
> > Hans
> > On Jun 5, 2:34 pm, Hans 
> > wrote:
>
> > > yes confirmed, the controller is called multiple times. the reason I
> > > found is that the redirect() statements I use cause this. every
> > > redirect() seems to call the controller, not only the redirection
> > > target function.
>
> > > for example my index is mainly a redirect function, based on settings
> > > its for instance doing
> > >  redirect(URL(r=request,f='f1'))
>
> > > then also in other functions I use redirects e.g. based on rights/
> > > settings.
>
> > > I'm using 1.63.5 on WinXP SP3.
>
> > > Is there a better function than redirect() for avoiding to call the
> > > general controller stuff multiple times?
> > > Is redirect() supposed to also call the general controller stuff or
> > > only directly the redirection target function ?
>
> > > Thanks,
> > > Hans
> > > On Jun 4, 10:48 pm, mdipierro  wrote:
>
> > > > Odd I think your controller is being called 3 times. Is that possible?
> > > > I would add a print statement to check.
>
> > > > On Jun 4, 2:29 pm, Hans 
> > > > wrote:
>
> > > > > I tried to define a global logging for a web2py app. The problem with
> > > > > that is that if I place the following code in my default.py controller
> > > > > or db.py model then in both cases its executed more than
> > > > > once...resulting into having every log line written multiple times
> > > > > into the log file.
>
> > > > > either starting the default.py or db.py with those lines is yielding
> > > > > the same result
> > > > >     import logging, logging.handlers
>
> > > > >     # Make a global logging object.
> > > > >     lox = logging.getLogger("log")
> > > > >     lox.setLevel(logging.DEBUG)
>
> > > > >     # This handler writes everything to a file.
> > > > >     h1 = logging.FileHandler("/var/log/myapp.log")
> > > > >     f = logging.Formatter("%(levelname)s %(asctime)s %(funcName)s %
> > > > > (lineno)d %(message)s")
> > > > >     h1.setFormatter(f)
> > > > >     h1.setLevel(

[web2py:23582] Re: global logging to file

2009-06-08 Thread Hans

The log file initialization code must be executed once when the
application starts and should not be executed multiple times (e.g. not
once per user and not once per controller execution).

I'm not aware that in a session I can store a application-wide global
variable - independent of the user.

Can you provide a link or example code for execution only once per
application (e.g. initialization function) ?

On Jun 5, 10:19 pm, mdipierro  wrote:
> can you store it into a session?
>
> On Jun 5, 2:11 pm, Hans 
> wrote:
>
> > The problem I have with my code for generating log files that the part
> > of the code (see first posting in this thread) which is outside any
> > function in the controller (because it should be available for all
> > functions in this controller) is executed every time a function is
> > called. I have not found a way to execute it only once intitially and
> > prevent multiple executions. Hence it registeres log handlers every
> > time the controller is executed which causes every log line to be
> > written multiple times into the log file.
>
> > The following did not work:
>
> > try:
> >     done_once
> > except:
> >     place code to be executed only once here
> >     global done_once
> >     done_once=true
>
> > because the variable done_once is undefined each time the controller
> > is executed again.
>
> > How can a code in the controller be executed only once?
> > Also completely different approach suggestions are welcome!
>
> > Thanks,
> > Hans
> > On Jun 5, 4:36 pm, mdipierro  wrote:
>
> > > Sorry Hans, I still do not understand the problem.
>
> > > code outside function is executed when a function in the controller is
> > > called (whatever the function) code in the function is executed only
> > > when that function is called. A call to redirect causes the browser to
> > > make another request thus the controller is executed again.
>
> > > Massimo
>
> > > On Jun 5, 8:08 am, Hans 
> > > wrote:
>
> > > > Correction: redirect() usage is NOT causing the problem. Every call of
> > > > a controller function also executes
> > > > 1) general parts of the model (db.py)
> > > > 2) general parts of the controller (default.py)
> > > > 3) the requested function in controller
>
> > > > In my case every click to an menu function adds another multiple for
> > > > log entries.
>
> > > > Thinking about the response.menu example which gives you different
> > > > menu options depending on the user being logged in or not I'm
> > > > convinced that the general controller sections are executed before
> > > > each requested function. That's good for the dynamically changing menu
> > > > and other needs.
>
> > > > For a log file function which should be available for the entire
> > > > controller I need to make sure its executed only once. Is there a
> > > > simple way to do that or a different way to achieve a log file
> > > > function (similar like my example up in this thread) available for the
> > > > entire controller?
>
> > > > Thanks,
> > > > Hans
> > > > On Jun 5, 2:34 pm, Hans 
> > > > wrote:
>
> > > > > yes confirmed, the controller is called multiple times. the reason I
> > > > > found is that the redirect() statements I use cause this. every
> > > > > redirect() seems to call the controller, not only the redirection
> > > > > target function.
>
> > > > > for example my index is mainly a redirect function, based on settings
> > > > > its for instance doing
> > > > >  redirect(URL(r=request,f='f1'))
>
> > > > > then also in other functions I use redirects e.g. based on rights/
> > > > > settings.
>
> > > > > I'm using 1.63.5 on WinXP SP3.
>
> > > > > Is there a better function than redirect() for avoiding to call the
> > > > > general controller stuff multiple times?
> > > > > Is redirect() supposed to also call the general controller stuff or
> > > > > only directly the redirection target function ?
>
> > > > > Thanks,
> > > > > Hans
> > > > > On Jun 4, 10:48 pm, mdipierro  wrote:
>
> > > > > > Odd I think your controller is being called 3 times. Is that 
> > > > > > possible?
> > > > > > I would add a print statement to check.
>

[web2py:23684] Re: global logging to file

2009-06-09 Thread Hans

Sorry for being picky on this. I think the database is not a suitable
place either to store a 'application instance initialized flag'.
Reason:
1) the db can be used by more than one instance of the app
2) if the app stops execution without setting back the 'db record' to
'app not initialized' - like it happens when you remove the power -
then the application will not work any more because the code will
refer to objects which are not created yet because the one-time-
initialization per app was not executed.

I'm not aware how application wide vars in web2py cache are working,
but I assume it could be a viable option.

what do you think?

On Jun 8, 2:43 pm, mdipierro  wrote:
> You are right. Not in session. You can store an application wide var
> in cache but I would suggest using the db for this. Anyway, I will
> post an example.
>
> On Jun 8, 4:27 am, Hans 
> wrote:
>
> > The log file initialization code must be executed once when the
> > application starts and should not be executed multiple times (e.g. not
> > once per user and not once per controller execution).
>
> > I'm not aware that in a session I can store a application-wide global
> > variable - independent of the user.
>
> > Can you provide a link or example code for execution only once per
> > application (e.g. initialization function) ?
>
> > On Jun 5, 10:19 pm, mdipierro  wrote:
>
> > > can you store it into a session?
>
> > > On Jun 5, 2:11 pm, Hans 
> > > wrote:
>
> > > > The problem I have with my code for generating log files that the part
> > > > of the code (see first posting in this thread) which is outside any
> > > > function in the controller (because it should be available for all
> > > > functions in this controller) is executed every time a function is
> > > > called. I have not found a way to execute it only once intitially and
> > > > prevent multiple executions. Hence it registeres log handlers every
> > > > time the controller is executed which causes every log line to be
> > > > written multiple times into the log file.
>
> > > > The following did not work:
>
> > > > try:
> > > >     done_once
> > > > except:
> > > >     place code to be executed only once here
> > > >     global done_once
> > > >     done_once=true
>
> > > > because the variable done_once is undefined each time the controller
> > > > is executed again.
>
> > > > How can a code in the controller be executed only once?
> > > > Also completely different approach suggestions are welcome!
>
> > > > Thanks,
> > > > Hans
> > > > On Jun 5, 4:36 pm, mdipierro  wrote:
>
> > > > > Sorry Hans, I still do not understand the problem.
>
> > > > > code outside function is executed when a function in the controller is
> > > > > called (whatever the function) code in the function is executed only
> > > > > when that function is called. A call to redirect causes the browser to
> > > > > make another request thus the controller is executed again.
>
> > > > > Massimo
>
> > > > > On Jun 5, 8:08 am, Hans 
> > > > > wrote:
>
> > > > > > Correction: redirect() usage is NOT causing the problem. Every call 
> > > > > > of
> > > > > > a controller function also executes
> > > > > > 1) general parts of the model (db.py)
> > > > > > 2) general parts of the controller (default.py)
> > > > > > 3) the requested function in controller
>
> > > > > > In my case every click to an menu function adds another multiple for
> > > > > > log entries.
>
> > > > > > Thinking about the response.menu example which gives you different
> > > > > > menu options depending on the user being logged in or not I'm
> > > > > > convinced that the general controller sections are executed before
> > > > > > each requested function. That's good for the dynamically changing 
> > > > > > menu
> > > > > > and other needs.
>
> > > > > > For a log file function which should be available for the entire
> > > > > > controller I need to make sure its executed only once. Is there a
> > > > > > simple way to do that or a different way to achieve a log file
> > > > > > function (similar like my example up in this thread) available f

[web2py:23817] Re: global logging to file

2009-06-10 Thread Hans

WOW Iceberg! That should also work well for me. Thanks for sharing
your solution idea! I'm going to try it later today.
And I agree the 'uncomment me if you need app-logging' approach in
combination with the per-application-log-file seems also to me the
best (backward compatible, flexible).

Since I'm going to implement that for me anyway I'll send my code when
its finised...in case you want to improve it and/or Massimo wants to
incorporate it in future web2py versions.

On Jun 9, 9:02 pm, Iceberg  wrote:
> Mmm, even after this log.py goes into models/log.py, I think the line:
>   logging=cache.ram(...)
> should be replaced by:
>   import logging
>   # logging=cache.ram(...) # Uncomment me if you need app-logging
>
> Because:
> 1. My log.py will cause the an incremental system.log which will
> eventually cram up your disk, hence it is not good for production
> site, unless you use RotatingFileHandler instead.
> 2. On GAE, you can not write to disk anyway, unless you use
> SMTPHandler or HTTPHandler etc.
>
> You get the idea. //shrug
>
> On Jun10, 2:45am, Iceberg  wrote:
>
> > I am glad you like it. So every new app will have a models/log.py
> > soon?
>
> > BTW, I personally prefer this formatter, hope you do:
> >   "%(asctime)s %(levelname)s %(funcName)s():%(lineno)d %(message)s"
>
> > On Jun10, 2:22am, mdipierro  wrote:
>
> > > I think you nailed it! I would change the file name so that it resides
> > > inside the applicaitons folder:
>
> > > handler=logging.FileHandler(os.path.join(request.folder,"system.log"))
>
> > > we could also add a line in the admin to peek the log (like with
> > > sql.log).
>
> > > On Jun 9, 12:18 pm, Iceberg  wrote:
>
> > > > request.log(message) would be nice, but all the advantages of standard
> > > > logging are too good to let go. So I came up with this little trick.
>
> > > > Add following codes inside model/log.py:
>
> > > >   def _init_log():
> > > >     import logging
> > > >     logger=logging.getLogger(request.application)
> > > >     logger.setLevel(logging.DEBUG)
> > > >     handler=logging.FileHandler("%s.log"%request.application)
> > > >     handler.setLevel(logging.DEBUG)
> > > >     handler.setFormatter(logging.Formatter(
> > > >       "%(levelname)s %(asctime)s %(funcName)s %(lineno)d %(message)
> > > > s"))
> > > >     logger.addHandler(handler)
> > > >     return logger
> > > >   logging=cache.ram('once',lambda:_init_log(),time_expire=)
>
> > > > Then, in any of your controller, you can just do the usual:
> > > >   logging.warn('blah blah')
> > > > The only tricky point is you can not do this inside your controller:
> > > >   import logging
> > > > otherwise you lose the magic. ;-)
>
> > > > Besides, thanks for Hans for bringing up all the issue, which inspires
> > > > me to find the solution (at least for me) for this problem haunting me
> > > > for long time.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24229] Re: global logging to file

2009-06-15 Thread Hans

Log file usage in Web2py is now simpler than ever!
You want to monitor the activities of your cron-driven web2py
functions?

To use the per application log file with rotating file handler in
web2py you need to put log.py (below) into your models folder. The log
file itself is created in your_web2py_path/applications/
your_application/app.log

Writing into the log file from your controller works as follows:
def my_function():
logging.debug('my function abc is starting')
logging.error('huston we got a %s problem.' % 'major')
return ()

Viewing the log file through your application works as follows:
def show_log():
return get_log()

If required the GAE solution needs work.
A BIG thank you to Iceberg!
Feedback and usage is welcome ;-)

Hans



Here is the log.py model version I use to enable logging for web2py
apps.

import logging

def _init_log(level=logging.DEBUG,formatter="%(asctime)s %(levelname)s
%(funcName)s():%(lineno)d %(message)
s",filename='app.log',maxBytes=1024*1024,backupCount=2):
import os,logging.handlers
logger=logging.getLogger(request.application)
logger.setLevel(level)
if request.env.web2py_runtime_gae: # if running on Google App
Engine
handler=logging.handlers.HTTPHandler(request.env.http_host,URL
(r=request,f='log')) # assuming there is an optional log action
else:
handler=logging.handlers.RotatingFileHandler(os.path.join
(request.folder,filename),maxBytes=maxBytes,backupCount=backupCount)
handler.setLevel(level)
handler.setFormatter(logging.Formatter(formatter))
logger.addHandler(handler)
logger.debug("web2py application %s starting" %
request.application)
return logger

def get_log():
try:
f = open(logging.handlers[0].baseFilename, 'r')
c = f.readlines()
f.close()
return {'log':TABLE(*[TR(str(item)) for item in c])}
except:
return ()

logging=cache.ram('mylog',lambda:_init_log(),time_expire=)


On Jun 11, 10:20 am, Iceberg  wrote:
> Not at all.
>
> The cache.ram in log.py is to make sure the logger is inited only
> once, otherwise we will see more and more duplicate log appearing in
> the log file as Hans mentioned in his earlier posts. The only downside
> is that you need to restart web2py if you change (but usually you
> don't need to) log definition.
>
> As to the "OPTIONAL in controller" part, you can ignore it. They are
> just a rough demo and not necessary.
>
> On Jun11, 3:17am, mdipierro  wrote:
>
> > Why do you need to cache the logging module? Is this only for speed?
>
> > On Jun 10, 1:44 pm, Iceberg  wrote:
>
> > > After changing from FileHandler to RotatingFileHandler, now I think
> > > the per-app log can be turned on by default (otherwise new comers
> > > won't notice this good feature).
>
> > > The only thing I am still not sure is whether one can use logging and
> > > its FileHander (or RotatingFileHander) on GAE's readonly filesystem.
> > > Tests are welcome.
>
> > > Anyway, this is my latest code. Maybe it can help you.
>
> > >   import logging
> > >   def _init_log(level=logging.DEBUG):
> > >     import os,logging.handlers
> > >     logger=logging.getLogger(request.application)
> > >     logger.setLevel(level)
> > >     if request.env.web2py_runtime_gae: # if running on Google App
> > > Engine
> > >       handler=logging.handlers.HTTPHandler(
> > >         request.env.http_host,URL(r=request,f='log')) # assuming there
> > > is an optional log action
> > >     else:
> > >       handler=logging.handlers.RotatingFileHandler(
> > >         os.path.join
> > > (request.folder,'app.log'),maxBytes=1024*1024,backupCount=2)
> > >     handler.setLevel(level)
> > >     handler.setFormatter(logging.Formatter(
> > >       "%(asctime)s %(levelname)s %(funcName)s():%(lineno)d %(message)
> > > s"))
> > >     logger.addHandler(handler)
> > >     return logger
> > >   logging=cache.ram('mylog',lambda:_init_log(),time_expire=)
>
> > > OPTIONAL in controller:
>
> > > def log():
> > >   if request.vars: # append
> > >     history=cache.ram('log_in_cache',lambda:[],time_expire=)
> > >     history.append(request.vars)
> > >     cache.ram('log_in_cache',lambda h=history:h,time_expire=0)#set
> > >   else: # show
> > >     return {'':TABLE(*[TR(item) for item in
> > >       cache.ram('log_in_cache',lambda:None,time_expire=)])}
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24230] Re: global logging to file

2009-06-15 Thread Hans

Important note: do *not* 'import logging' in your controller if you
use log.py. its done for all your controllers already in the log.py
model and it would break the log.py magic.

On Jun 15, 7:46 pm, Hans 
wrote:
> Log file usage in Web2py is now simpler than ever!
> You want to monitor the activities of your cron-driven web2py
> functions?
>
> To use the per application log file with rotating file handler in
> web2py you need to put log.py (below) into your models folder. The log
> file itself is created in your_web2py_path/applications/
> your_application/app.log
>
> Writing into the log file from your controller works as follows:
> def my_function():
>     logging.debug('my function abc is starting')
>     logging.error('huston we got a %s problem.' % 'major')
>     return ()
>
> Viewing the log file through your application works as follows:
> def show_log():
>     return get_log()
>
> If required the GAE solution needs work.
> A BIG thank you to Iceberg!
> Feedback and usage is welcome ;-)
>
> Hans
>
> Here is the log.py model version I use to enable logging for web2py
> apps.
>
> import logging
>
> def _init_log(level=logging.DEBUG,formatter="%(asctime)s %(levelname)s
> %(funcName)s():%(lineno)d %(message)
> s",filename='app.log',maxBytes=1024*1024,backupCount=2):
>     import os,logging.handlers
>     logger=logging.getLogger(request.application)
>     logger.setLevel(level)
>     if request.env.web2py_runtime_gae: # if running on Google App
> Engine
>         handler=logging.handlers.HTTPHandler(request.env.http_host,URL
> (r=request,f='log')) # assuming there is an optional log action
>     else:
>         handler=logging.handlers.RotatingFileHandler(os.path.join
> (request.folder,filename),maxBytes=maxBytes,backupCount=backupCount)
>     handler.setLevel(level)
>     handler.setFormatter(logging.Formatter(formatter))
>     logger.addHandler(handler)
>     logger.debug("web2py application %s starting" %
> request.application)
>     return logger
>
> def get_log():
>     try:
>         f = open(logging.handlers[0].baseFilename, 'r')
>         c = f.readlines()
>         f.close()
>         return {'log':TABLE(*[TR(str(item)) for item in c])}
>     except:
>         return ()
>
> logging=cache.ram('mylog',lambda:_init_log(),time_expire=)
>
> On Jun 11, 10:20 am, Iceberg  wrote:
>
> > Not at all.
>
> > The cache.ram in log.py is to make sure the logger is inited only
> > once, otherwise we will see more and more duplicate log appearing in
> > the log file as Hans mentioned in his earlier posts. The only downside
> > is that you need to restart web2py if you change (but usually you
> > don't need to) log definition.
>
> > As to the "OPTIONAL in controller" part, you can ignore it. They are
> > just a rough demo and not necessary.
>
> > On Jun11, 3:17am, mdipierro  wrote:
>
> > > Why do you need to cache the logging module? Is this only for speed?
>
> > > On Jun 10, 1:44 pm, Iceberg  wrote:
>
> > > > After changing from FileHandler to RotatingFileHandler, now I think
> > > > the per-app log can be turned on by default (otherwise new comers
> > > > won't notice this good feature).
>
> > > > The only thing I am still not sure is whether one can use logging and
> > > > its FileHander (or RotatingFileHander) on GAE's readonly filesystem.
> > > > Tests are welcome.
>
> > > > Anyway, this is my latest code. Maybe it can help you.
>
> > > >   import logging
> > > >   def _init_log(level=logging.DEBUG):
> > > >     import os,logging.handlers
> > > >     logger=logging.getLogger(request.application)
> > > >     logger.setLevel(level)
> > > >     if request.env.web2py_runtime_gae: # if running on Google App
> > > > Engine
> > > >       handler=logging.handlers.HTTPHandler(
> > > >         request.env.http_host,URL(r=request,f='log')) # assuming there
> > > > is an optional log action
> > > >     else:
> > > >       handler=logging.handlers.RotatingFileHandler(
> > > >         os.path.join
> > > > (request.folder,'app.log'),maxBytes=1024*1024,backupCount=2)
> > > >     handler.setLevel(level)
> > > >     handler.setFormatter(logging.Formatter(
> > > >       "%(asctime)s %(levelname)s %(funcName)s():%(lineno)d %(message)
> > > > s"))
> > > >     logger

[web2py:24234] db.table.truncate() error if migrate=False

2009-06-15 Thread Hans

db.table.truncate() on a table with migrate=False produces a error. Is
that only allowed on table with migrate on?

Hans

Using web2py 1.64.1 with MySQL

Traceback (most recent call last):
  File "F:\Documents and Settings\Hans\Desktop\web2py\", line
1, in 
  File "F:\Documents and Settings\Hans\Desktop\web2py\gluon\sql.py",
line 1571, in truncate
if self._dbt:
  File "F:\Documents and Settings\Hans\Desktop\web2py\gluon\sql.py",
line 1209, in __getattr__
return dict.__getitem__(self,key)
KeyError: '_dbt'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24349] Re: global logging to file

2009-06-17 Thread Hans

I'm glad that its useful also to you Richard.

Massimo, maybe you want to check if you want it in one of the next
versions.

On Jun 17, 2:23 am, Richard  wrote:
> this looks useful - thanks!
>
> On Jun 16, 3:53 am, Hans 
> wrote:
>
> > Important note: do *not* 'import logging' in your controller if you
> > use log.py. its done for all your controllers already in the log.py
> > model and it would break the log.py magic.
>
> > On Jun 15, 7:46 pm, Hans 
> > wrote:
>
> > > Log file usage in Web2py is now simpler than ever!
> > > You want to monitor the activities of your cron-driven web2py
> > > functions?
>
> > > To use the per application log file with rotating file handler in
> > > web2py you need to put log.py (below) into your models folder. The log
> > > file itself is created in your_web2py_path/applications/
> > > your_application/app.log
>
> > > Writing into the log file from your controller works as follows:
> > > def my_function():
> > >     logging.debug('my function abc is starting')
> > >     logging.error('huston we got a %s problem.' % 'major')
> > >     return ()
>
> > > Viewing the log file through your application works as follows:
> > > def show_log():
> > >     return get_log()
>
> > > If required the GAE solution needs work.
> > > A BIG thank you to Iceberg!
> > > Feedback and usage is welcome ;-)
>
> > > Hans
>
> > > Here is the log.py model version I use to enable logging for web2py
> > > apps.
>
> > > import logging
>
> > > def _init_log(level=logging.DEBUG,formatter="%(asctime)s %(levelname)s
> > > %(funcName)s():%(lineno)d %(message)
> > > s",filename='app.log',maxBytes=1024*1024,backupCount=2):
> > >     import os,logging.handlers
> > >     logger=logging.getLogger(request.application)
> > >     logger.setLevel(level)
> > >     if request.env.web2py_runtime_gae: # if running on Google App
> > > Engine
> > >         handler=logging.handlers.HTTPHandler(request.env.http_host,URL
> > > (r=request,f='log')) # assuming there is an optional log action
> > >     else:
> > >         handler=logging.handlers.RotatingFileHandler(os.path.join
> > > (request.folder,filename),maxBytes=maxBytes,backupCount=backupCount)
> > >     handler.setLevel(level)
> > >     handler.setFormatter(logging.Formatter(formatter))
> > >     logger.addHandler(handler)
> > >     logger.debug("web2py application %s starting" %
> > > request.application)
> > >     return logger
>
> > > def get_log():
> > >     try:
> > >         f = open(logging.handlers[0].baseFilename, 'r')
> > >         c = f.readlines()
> > >         f.close()
> > >         return {'log':TABLE(*[TR(str(item)) for item in c])}
> > >     except:
> > >         return ()
>
> > > logging=cache.ram('mylog',lambda:_init_log(),time_expire=)
>
> > > On Jun 11, 10:20 am, Iceberg  wrote:
>
> > > > Not at all.
>
> > > > The cache.ram in log.py is to make sure the logger is inited only
> > > > once, otherwise we will see more and more duplicate log appearing in
> > > > the log file as Hans mentioned in his earlier posts. The only downside
> > > > is that you need to restart web2py if you change (but usually you
> > > > don't need to) log definition.
>
> > > > As to the "OPTIONAL in controller" part, you can ignore it. They are
> > > > just a rough demo and not necessary.
>
> > > > On Jun11, 3:17am, mdipierro  wrote:
>
> > > > > Why do you need to cache the logging module? Is this only for speed?
>
> > > > > On Jun 10, 1:44 pm, Iceberg  wrote:
>
> > > > > > After changing from FileHandler to RotatingFileHandler, now I think
> > > > > > the per-app log can be turned on by default (otherwise new comers
> > > > > > won't notice this good feature).
>
> > > > > > The only thing I am still not sure is whether one can use logging 
> > > > > > and
> > > > > > its FileHander (or RotatingFileHander) on GAE's readonly filesystem.
> > > > > > Tests are welcome.
>
> > > > > > Anyway, this is my latest code. Maybe it can help you.
>
> > > > > >   import logging
> > &

[web2py:24900] Re: sql IS_NOT_IN_DB()

2009-06-24 Thread Hans

Regarding Massimo's comment: because the last line sets 2 validators,
there is no automatic
dropbox.

As far as I'm aware IS_IN_DB can generate a drop-down, but
IS_NOT_IN_DB can't.
IMHO the combination of IS_IN_DB and IS_NOT_IN_DB should theoretically
be able to deliver a automatic drop-down. Basically the results list
of IS_IN_DB less IS_NOT_IN_DB entries. If I'm not wrong even complex
combinations like 2 IS_IN_DB and 3 IS_NOT_IN DB can be theoretically
resloved.

Thanks to Massimo I've got a workaround. The downsides are: its much
more complex code than it could be and due to that its more difficult
to maintain the code. See example below.

It would be great also for me if future wep2by versions do automatic
drop-down on combinations of IS_IN_DB and IS_NOT_IN_DB.

Hans

# vv the following construct replaces the broken dropdown
function of the 1st line of code following vv
#db.ipst.subsidary.requires=[IS_IN_DB(db,'subsidary.id','%(line)s %
(name)s'),IS_NOT_IN_DB(db
((db.ips.model_master==request.vars.model_master)&
(db.ips.month==request.vars.month)),db.ips.subsidary)]

class MY_ODD_VALIDATOR(IS_IN_DB):
def __init__(self,*a,**b): IS_IN_DB.__init__(self,*a,**b)
def __call__(self,value):
e=IS_IN_DB.__call__(self,value)
if e[1]: return e
e=IS_NOT_IN_DB(db
((db.ipst.model_master==request.vars.model_master)&
(db.ipst.year==request.vars.year)&(db.ipst.month==request.vars.month)&
(db.ipst.id!=request.vars.id)),db.ipst.subsidary)(value)
return e

db.ipst.subsidary.requires=MY_ODD_VALIDATOR(db
((db.usersubsidary.t2_person==t2.person_id)&
(db.usersubsidary.subsidary==db.subsidary.id)),'subsidary.id','%(name)
s')
#   end of workaround construct



On Jun 22, 5:44 pm, DenesL  wrote:
> In the current release form.accepts validates the input against a copy
> of the db field requires and that is OK most of the time but to cover
> for cases like this one it would also need to check against the db
> field requires, in case it was modified afterwards.
>
> But this method implies complexity in the controller and is not
> intuitive:
> 1) create widget for input and use the requires for things like drop-
> down generation and input validation.
> 2) modify requires for db side needs, which is the true use of
> requires.
>
> How would you modify the OptionsWidget to separate input-requires from
> db-requires, and at the same time keep it intuitive?.
>
> A convention? the first validator on the list is used for drop-downs
> an such? is this backward compatible?
> Or by perfecting the clone field trick?
>
> Denes.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24967] Re: global logging to file

2009-06-25 Thread Hans

Richard,

the following solution works for me in production without any
problems. I use it for periodic, unattended functions (cron). I've
send Massimo the code in case he wants to include it into  web2py or
make it available as optional add-on download.

Hans


'''
To use the per application log file with rotating file handler in
web2py you need to put this file (log.py) into your models folder. The
log
file itself is created in your_web2py_path/applications/
your_application/app.log

Writing into the log file from your controller works as follows:
def my_function():
logging.debug('my function abc is starting')
logging.error('huston we got a %s problem.' % 'major')
return

Viewing the log file through your application works as follows:
def show_log():
return get_log()

If required the GAE solution needs work.
A BIG thank you to Iceberg!
Feedback and usage is welcome ;-)

Important note: do *not* 'import logging' in your controller if you
use log.py. its done for all your controllers already in the log.py
model and it would break the log.py magic.
'''

import logging

def _init_log(level=logging.DEBUG,formatter="%(asctime)s %(levelname)s
%(funcName)s():%(lineno)d %(message)
s",filename='app.log',maxBytes=1024*1024,backupCount=2):
import os,logging.handlers
logger=logging.getLogger(request.application)
logger.setLevel(level)
if request.env.web2py_runtime_gae: # if running on Google App
Engine
handler=logging.handlers.HTTPHandler(request.env.http_host,URL
(r=request,f='log')) # assuming there is an optional log action
else:
handler=logging.handlers.RotatingFileHandler(os.path.join
(request.folder,filename),maxBytes=maxBytes,backupCount=backupCount)
handler.setLevel(level)
handler.setFormatter(logging.Formatter(formatter))
logger.addHandler(handler)
logger.debug("web2py application %s starting" %
request.application)
return logger

def get_log():
try:
f = open(logging.handlers[0].baseFilename, 'r')
c = f.readlines()
f.close()
return {'log':TABLE(*[TR(str(item)) for item in c])}
except:
return ()

logging=cache.ram('mylog',lambda:_init_log(),time_expire=)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:25011] Datatables + jEditable

2009-06-25 Thread Hans

...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:25012] jEditable and Datatables

2009-06-25 Thread Hans

I've got datatables working well.
After installing the app do csv import via appadmin to have some data
to play with.
you find csv example data in the /private folder.

Unfortunately I've not got jEditable working. My js sucks ;-)
Is anyone here able to help getting also jEditable working ?

app + data attached in the next reply.

Hans
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:25057] Re: global logging to file

2009-06-26 Thread Hans

Mike,
instead of importing in your Web2py controller use
execfile('your_module.py')

In your module ...
try:
  # this variable is available in Web2Py
  # but raises an exception if run outside Web2Py
  # since its not defined
request.env.web2py_version
  # put here your web2py related code...
print 'code executed in Web2py %s' % request.env.web2py_version
except:
# put here your not Web2Py related code
print 'code NOT executed in Web2py environment'

#put here your general code
print 'this part is always executed'

Hans

On Jun 25, 10:40 pm, MikeEllis  wrote:
> This looks really useful. Thanks for writing it. I'm trying to import
> some existing python modules that have logging calls into a web2py
> app.  Just putting log.py into my models directory helps some, but I'm
> not seeing any messages from my existing modules with level lower than
> logging.ERROR. I am, however, getting lower level (down to
> logging.DEBUG) from the web2py framework.  I suspect it has something
> to do with the customized logger my modules are using.  I don't want
> to go through and comment out all the calls to my version of getLogger
> () because many of these modules are used by other code.  I'm
> wondering if there's a way for a python module to detect at runtime
> whether it's being imported from the web2py framework. I might then be
> able to make my customized logging setup do nothing when running under
> web2py.  Any suggestions?
>
> Thanks,
> Mike Ellus
>
> On Jun 25, 8:29 am, Hans 
> wrote:
>
> > Richard,
>
> > the following solution works for me in production without any
> > problems. I use it for periodic, unattended functions (cron). I've
> > send Massimo the code in case he wants to include it into  web2py or
> > make it available as optional add-on download.
>
> > Hans
>
> > '''
> > To use the per application log file with rotating file handler in
> > web2py you need to put this file (log.py) into your models folder. The
> > log
> > file itself is created in your_web2py_path/applications/
> > your_application/app.log
>
> > Writing into the log file from your controller works as follows:
> > def my_function():
> >    logging.debug('my function abc is starting')
> >    logging.error('huston we got a %s problem.' % 'major')
> >     return
>
> > Viewing the log file through your application works as follows:
> > def show_log():
> >     return get_log()
>
> > If required the GAE solution needs work.
> > A BIG thank you to Iceberg!
> > Feedback and usage is welcome ;-)
>
> > Important note: do *not* 'importlogging' in your controller if you
> > use log.py. its done for all your controllers already in the log.py
> > model and it would break the log.py magic.
> > '''
>
> > importlogging
>
> > def _init_log(level=logging.DEBUG,formatter="%(asctime)s %(levelname)s
> > %(funcName)s():%(lineno)d %(message)
> > s",filename='app.log',maxBytes=1024*1024,backupCount=2):
> >     import os,logging.handlers
> >     logger=logging.getLogger(request.application)
> >     logger.setLevel(level)
> >     if request.env.web2py_runtime_gae: # if running on Google App
> > Engine
> >         handler=logging.handlers.HTTPHandler(request.env.http_host,URL
> > (r=request,f='log')) # assuming there is an optional log action
> >     else:
> >         handler=logging.handlers.RotatingFileHandler(os.path.join
> > (request.folder,filename),maxBytes=maxBytes,backupCount=backupCount)
> >     handler.setLevel(level)
> >     handler.setFormatter(logging.Formatter(formatter))
> >     logger.addHandler(handler)
> >     logger.debug("web2py application %s starting" %
> > request.application)
> >     return logger
>
> > def get_log():
> >     try:
> >         f = open(logging.handlers[0].baseFilename, 'r')
> >         c = f.readlines()
> >         f.close()
> >         return {'log':TABLE(*[TR(str(item)) for item in c])}
> >     except:
> >         return ()
>
> > logging=cache.ram('mylog',lambda:_init_log(),time_expire=)
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:25453] Re: XForms version of SQLFORM

2009-07-01 Thread Hans

Another interesting XForms implementation seems to me http://www.orbeon.com/

I guess
* 'fully interactive forms' without the need for writing form code/
AJAX/... see Form Builder
* 'as-you-type-validation'
* 'form submissions are handled for you'
* 'no more struggling with AJAX/scripting languages or browser
incompatibilities'
would go on my x-mas wish list to Santa Massimo ;-)

Hans


On 1 Jul., 19:13, mdipierro  wrote:
> right now you can do
>
> requires=IS_IN_DB(...) # options or
> requires=[IS_IN_DB(...)] # no options
> both cases validate the same serverside.
>
> I think the same may work with XForms
>
> On Jul 1, 11:36 am, Hans Donner  wrote:
>
> > depending on the volume of the data the IS_IN_DB can be included (eg
> > data in javascript or so), so with jquery you can do some checking.
>
> > in the end, validation must always be done on the server side
>
> > 2009/7/1 mdipierro :
>
> > > this
>
> > >> IS_NOT_IN_DB = I don't see how to support this
>
> > > would only be serverside so nothing to do.
>
> > > On Jul 1, 10:56 am, Fran  wrote:
> > >> On Jul 1, 4:39 pm, mdipierro  wrote:
>
> > >> > If XForms hanles select/options it must be possible to send the
> > >> > options. no?
>
> > >> IS_IN_SET = no problem
> > >> IS_IN_DB = ok, although we should continually refresh the form to see
> > >> new data being added
> > >> IS_NOT_IN_DB = I don't see how to support this
>
> > >> The 'only show this field if previous answer was x' has no direct
> > >> Web2Py model analogue
> > >> - I use jQuery to achieve this kind of thing in HTML views
> > >> Am not sure if we can add something within Web2Py model to handle both
> > >> of these programatically or whether this will always have to be
> > >> something we touch up manually afterwards.
> > >> e.g. I have 'unit_cost' for One-time costs &
> > >> 'monthly_cost'/'minute_cost'/'megabyte_cost' for Recurring costs
>
> > >> F
>
> > >> > On Jul 1, 10:28 am, Fran  wrote:
>
> > >> > > Whilst most stuff seems starightforward, the harder cases are things
> > >> > > like:
>
> > >> > > db.budget_item.code.requires = IS_NOT_IN_DB(db, 'budget_item.code')
> > >> > > Obviously if working offline then this referencedata isn't available
> > >> > > - I guess we just have to ignore that within the XForm itself & 
> > >> > > handle
> > >> > > it during form submission.
>
> > >> > > db.Field('created_on', 'datetime', readable=False, writable=False,
> > >> > > default=request.now)
> > >> > > The Hidden field part is straightfwd (just don't provide a Control)
> > >> > > But the default value doesn't make sense to be within the form
> > >> > > definition as it makes sense at submission time per-instance not as a
> > >> > > default when form is downloaded to device! (Same goes for uuid)
> > >> > > datetime may need some tweaking - this is available:  > >> > > nodeset="created-on" type="date" />
>
> > >> > > F
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:25580] Re: need an ajax spreadsheet

2009-07-03 Thread Hans

great stuff massimo!!!

how can the size of the cells be adjusted? Basically I want wider
cells.

Thanks,
Hans

On Jul 3, 4:16 am, mdipierro  wrote:
> Do you need to embed an ajax spreadsheet in you app. Now you have it:
>
> http://www.vimeo.com/5432441http://www.web2py.com/appliances/default/show/53
>
> Please let know about bugs
>
> Massimo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:25624] Re: need an ajax spreadsheet

2009-07-04 Thread Hans

very nice!

how can a cell be made a drop down selection with values from db ?


On Jul 3, 10:48 pm, mdipierro  wrote:
> with that looks like this:http://www.web2py.com/examples/spreadsheet
>
> On Jul 3, 3:40 pm, mdipierro  wrote:
>
> > sheet['cell_name'].size=4 # is the default. You will have to change it
> > for every cell or change it in sheet.py
> > Here is a much better index html that makes it look more like Excel:
>
> > {{extend 'layout.html'}}
>
> > 
> > /*
>
> >    the code in this page is here just to provide an example
> >    none of the css markup and script is required for the sheet to
> > function
> >    it is required to make it look good and can be further customized
>
> > */
> > .sheet td {
> >     text-align: left;
> >     vertical-align: top;
> >     padding: 0 0 0 0;
> >     border: 0 0 0 0;
> >     spacing: 0 0 0 0;}
>
> > .sheet input {
> >     border: 0;}
>
> > td.colhead, td.rowhead {
> >     background-color: #bb;
> >     padding-left: 5px;
> >     padding-right: 5px;}
>
> > td.rowhead {
> >     width: 30px;
> >     text-align: right;}
>
> > 
>
> > 
> >   
> >   
> >     
> >       
> >       
> >         
> >       
> >     
> >     
> >       
> >       {{for c in xrange(sheet.cols):}}
> >       c{{=c}}
> >       {{pass}}
> >     
> >     {{for r in xrange(sheet.rows):}}
> >     
> >       r{{=r}}
> >       {{for c in xrange(sheet.cols):}}
> >       
> >         {{=XML(sheet.nodes['r%sc%s'%(r,c)].xml())}}
> >       
> >       {{pass}}
> >     
> >     {{pass}}
> >   
> >   
> > 
>
> > 
> >   function update_formula(t) {
> >      if(t) {
> >       jQuery('#selected_cell').html(jQuery(t).attr('id'));
> >       jQuery('#formula').val(jQuery(t).val());
> >      } else {
> >       jQuery('#selected_cell').html('');
> >       jQuery('#formula').val('');
> >      }
> >   };
> >   jQuery('.cells input').focus(function(){update_formula(this);});
> >   jQuery('.cells input').keyup(function(){update_formula(this);});
> >   jQuery('.cells input').blur(function(){update_formula(null);});
> > 
>
> > On Jul 3, 2:47 pm, Hans 
> > wrote:
>
> > > great stuff massimo!!!
>
> > > how can the size of the cells be adjusted? Basically I want wider
> > > cells.
>
> > > Thanks,
> > > Hans
>
> > > On Jul 3, 4:16 am, mdipierro  wrote:
>
> > > > Do you need to embed an ajax spreadsheet in you app. Now you have it:
>
> > > >http://www.vimeo.com/5432441http://www.web2py.com/appliances/default/...
>
> > > > Please let know about bugs
>
> > > > Massimo
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:25635] Re: need an ajax spreadsheet

2009-07-04 Thread Hans

That would work for me.
Unfortunately I don't know how to register an event nor do I know how
to open a popup.

On Jul 4, 5:49 pm, mdipierro  wrote:
> At this time you cannot do select/option. You would have to register
> an onfocus event that opens a popup and when you select a value it
> copies it in the cell and informs the sever. Doable in about 10 lines
> of code but a bit tricky. If you do it let me know.
>
> On Jul 4, 8:31 am, Hans 
> wrote:
>
> > very nice!
>
> > how can a cell be made a drop down selection with values from db ?
>
> > On Jul 3, 10:48 pm, mdipierro  wrote:
>
> > > with that looks like this:http://www.web2py.com/examples/spreadsheet
>
> > > On Jul 3, 3:40 pm, mdipierro  wrote:
>
> > > > sheet['cell_name'].size=4 # is the default. You will have to change it
> > > > for every cell or change it in sheet.py
> > > > Here is a much better index html that makes it look more like Excel:
>
> > > > {{extend 'layout.html'}}
>
> > > > 
> > > > /*
>
> > > >    the code in this page is here just to provide an example
> > > >    none of the css markup and script is required for the sheet to
> > > > function
> > > >    it is required to make it look good and can be further customized
>
> > > > */
> > > > .sheet td {
> > > >     text-align: left;
> > > >     vertical-align: top;
> > > >     padding: 0 0 0 0;
> > > >     border: 0 0 0 0;
> > > >     spacing: 0 0 0 0;}
>
> > > > .sheet input {
> > > >     border: 0;}
>
> > > > td.colhead, td.rowhead {
> > > >     background-color: #bb;
> > > >     padding-left: 5px;
> > > >     padding-right: 5px;}
>
> > > > td.rowhead {
> > > >     width: 30px;
> > > >     text-align: right;}
>
> > > > 
>
> > > > 
> > > >   
> > > >   
> > > >     
> > > >       
> > > >       
> > > >         
> > > >       
> > > >     
> > > >     
> > > >       
> > > >       {{for c in xrange(sheet.cols):}}
> > > >       c{{=c}}
> > > >       {{pass}}
> > > >     
> > > >     {{for r in xrange(sheet.rows):}}
> > > >     
> > > >       r{{=r}}
> > > >       {{for c in xrange(sheet.cols):}}
> > > >       
> > > >         {{=XML(sheet.nodes['r%sc%s'%(r,c)].xml())}}
> > > >       
> > > >       {{pass}}
> > > >     
> > > >     {{pass}}
> > > >   
> > > >   
> > > > 
>
> > > > 
> > > >   function update_formula(t) {
> > > >      if(t) {
> > > >       jQuery('#selected_cell').html(jQuery(t).attr('id'));
> > > >       jQuery('#formula').val(jQuery(t).val());
> > > >      } else {
> > > >       jQuery('#selected_cell').html('');
> > > >       jQuery('#formula').val('');
> > > >      }
> > > >   };
> > > >   jQuery('.cells input').focus(function(){update_formula(this);});
> > > >   jQuery('.cells input').keyup(function(){update_formula(this);});
> > > >   jQuery('.cells input').blur(function(){update_formula(null);});
> > > > 
>
> > > > On Jul 3, 2:47 pm, Hans 
> > > > wrote:
>
> > > > > great stuff massimo!!!
>
> > > > > how can the size of the cells be adjusted? Basically I want wider
> > > > > cells.
>
> > > > > Thanks,
> > > > > Hans
>
> > > > > On Jul 3, 4:16 am, mdipierro  wrote:
>
> > > > > > Do you need to embed an ajax spreadsheet in you app. Now you have 
> > > > > > it:
>
> > > > > >http://www.vimeo.com/5432441http://www.web2py.com/appliances/default/...
>
> > > > > > Please let know about bugs
>
> > > > > > Massimo
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:26055] Upload with previously used but removed applicationname

2009-07-09 Thread Hans

This has low priority for me because of possible workaround below -
don't spend much time on this.

I use pack-all on a windows development pc and try to upload the
ips.w2p on the ubuntu production server (after having used uninstall
'ips'). all in web2py admin/default/site web interface.
when I upload the file with the same name (rename it field 'ips') then
I get a flash response: unable to install "ips".
uploading the same file with another name (like 'xps') works.
so I just go on linux shell and rename it e.g. mv ./xps ./ips to work
around the problem.
the folder ips does not exist on linux any more after the uninstall
via admin interface. also changing the name of the file ips.w2p does
not make a difference.

are (old) application names in web2py stored somewhere else too?

any other idea?

both systems are on web2py 1.65.1
development on win XP
production on ubuntu

Hans
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:26145] Re: Upload with previously used but removed applicationname

2009-07-10 Thread Hans

Problem was that in web2py/deposit/ there was the ips.w2p file with
owner root rather than the web2py user...maybe through manual copy...
changed owner and now its working like it should.

Thanks Massimo for pointing me into the right folder!

On Jul 9, 10:47 pm, mdipierro  wrote:
> odd. tehcnically uploaded files go in web2py/deposit/ before being
> unpacked
>
> On Jul 9, 2:39 pm, Hans 
> wrote:
>
> > This has low priority for me because of possible workaround below -
> > don't spend much time on this.
>
> > I use pack-all on a windows development pc and try to upload the
> > ips.w2p on the ubuntu production server (after having used uninstall
> > 'ips'). all in web2py admin/default/site web interface.
> > when I upload the file with the same name (rename it field 'ips') then
> > I get a flash response: unable to install "ips".
> > uploading the same file with another name (like 'xps') works.
> > so I just go on linux shell and rename it e.g. mv ./xps ./ips to work
> > around the problem.
> > the folder ips does not exist on linux any more after the uninstall
> > via admin interface. also changing the name of the file ips.w2p does
> > not make a difference.
>
> > are (old) application names in web2py stored somewhere else too?
>
> > any other idea?
>
> > both systems are on web2py 1.65.1
> > development on win XP
> > production on ubuntu
>
> > Hans
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27428] feature request: auth email to approver

2009-07-26 Thread Hans

For me it would be great if the approver gets a notification email as
soon as his action is required. The idea is something like below

auth.settings.registration_approver='youremailaddr...@yourdomain'
auth.messages.approver_email = \
 'A pending registration from %(email)s on application %
(response.title)s requires your approval'


Does that make sense?

Thanks,
Hans
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27457] Re: feature request: auth email to approver

2009-07-27 Thread Hans

Grazie Massimo!

The following works well for my need:

auth.settings.registration_requires_verification = True
auth.settings.registration_requires_approval = True
auth.messages.verify_email = \
 'Click on the link https://mydomain/fips/default/user/verify_email/%(key)s
to verify your FIPS registration'
auth.settings.verify_email_onaccept = lambda form:\
auth.settings.mailer.send(to='adminwithapprovalpo...@admindomain',
\
  subject='FIPS Approval Pending',\
  message='Your action is required. Please
approve user %s asap.' % form.email)

So the from me requested feature is there already and working well ;-)

Hans
On Jul 27, 2:25 am, mdipierro  wrote:
> Yes but you can do already
>
> auth.settings.registration_requires_approval = False
> auth.settings.register_onaccept = lambda form:
> auth.settings.mailer.send()
>
> why a notification email should be more important (i.e. built-in) vs
> any other action that may be required on login?
>
> Massimo
>
> On Jul 26, 12:05 pm, Hans 
> wrote:
>
> > For me it would be great if the approver gets a notification email as
> > soon as his action is required. The idea is something like below
>
> > auth.settings.registration_approver='youremailaddr...@yourdomain'
> > auth.messages.approver_email = \
> >  'A pending registration from %(email)s on application %
> > (response.title)s requires your approval'
>
> > Does that make sense?
>
> > Thanks,
> > Hans
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27536] Re: web2py development and deployment

2009-07-29 Thread Hans

The following trick I used with WingIDE (with other modules)...might
work also for your IDE.
Instead of
import rpdb2; rpdb2.start_embedded_debugger('any_password')
use
if 0:
import rpdb2; rpdb2.start_embedded_debugger('any_password')

In production (not using WingIDE) the if will always be false, hence
not execute the import.
But WingIDE executes ALL imports in a python file when loaded/started,
regardless if the program flow reaches the import statement later or
not.

BTW in production I'm using Ubuntu 8.04.1+MySQL+Apache+SSL+WSGI,
development WinXP+MySQL+WingIDE Professional

WingIDE Professional is fantastic. If you develop open source you can
get a free Professional license.

Hans

On Jul 29, 12:02 am, Fran  wrote:
> On Jul 28, 10:52 pm, rb  wrote:
>
> > I'm not crazy about having to modify code in
> > web2py.py in order to do debugging. I've never used a debugger before
> > that forced me to modify code.
>
> Could you not just have it as a line in your model which you can
> easily comment-out when going into production?
>
> F
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:18502] Multi Column Unique Key, how to code best in web2py?

2009-03-23 Thread Hans

Massimo and web2py.experts,

After initial successful tests with web2py we are trying to get the
first 'little' enterprise application done with it. And like
enterprises do we need to life with extensive use of multi column
unique keys. Despite reading through various threads on this we could
not get it working already with a 'simple' 2 column unique key. Either
we loose the "drop box" option/functionality or we can't use it as one
column of a multi column unique key. See the last 3 lines of the
following code example. I'm sure someone here can share a working
example of how to implement such a basic enterprise requirement in
web2py code.

Beyond that I would appreciate help on how a good code for a 3 column
unique key would be implemented (a good example would be shapename
+colorname+month below).

Thanks,
Hans

db=SQLDB('sqlite://test.db')

db.define_table('shape',
  SQLField('name'),
  migrate='shape.table')

db.define_table('color',
  SQLField('name'),
  migrate='color.table')

db.define_table('shapecolor',
  SQLField('shapename'),
  SQLField('colorname'),
  SQLField('month','date',requires=IS_DATE('%Y-%m')),
  migrate='shapecolor.table')

db.shapecolor.shapename.requires=IS_IN_DB(db,db.shape.name,'%(name)
s')

# 1st try
db.shapecolor.colorname.requires=IS_IN_DB(db,db.color.name,'%(name)
s'),IS_NOT_IN_DB(db
(db.shapecolor.shapename==request.vars.shapename),'shapecolor.colorname')
#<<< this breaks db.color.name dropdown
# 2nd try
db.shapecolor.colorname.requires=[IS_IN_DB(db,db.color.name,'%(name)
s'),IS_NOT_IN_DB(db
(db.shapecolor.shapename==request.vars.shapename),'shapecolor.colorname')]
#<<< this breaks db.color.name dropdown as well
# 3rd try
db.shapecolor.colorname.requires=IS_IN_DB(db,db.color.name,'%(name)
s')  #<<< dropdown working but no multi column unique key!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:18804] search() in T2, [next and previous page], manual "Submit" required

2009-03-30 Thread Hans

Pagination works fine when using t2.itemize(), but neither "[next
page]" nor "[previous page]" works when using t2.search(). It seems
they only work when you hit the submit button every time after hitting
"[next page]" or "[previous page]". Not
intuitive enough. Is there a fix or workaround? like self submitting
form? example code would be greatly appreciated on both
1) how to make a form self submitting and
2) a even better solution to the t2.search() next/previous page
problem, if it exists

Thank you,
Hans
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:/] Re: search() in T2, [next and previous page], manual "Submit" required

2009-03-30 Thread Hans

Is there a more practicable temporary workaround than changing the
development framework?
Can a form submit itself or something similar, how ?

Hans

On Mar 30, 8:14 pm, mdipierro  wrote:
> Yes it is a bug. It will not be resolved too soon since first we need
> to merge t2.search with crud.select
>
> On Mar 30, 1:03 pm, Hans 
> wrote:
>
> > Pagination works fine when using t2.itemize(), but neither "[next
> > page]" nor "[previous page]" works when using t2.search(). It seems
> > they only work when you hit the submit button every time after hitting
> > "[next page]" or "[previous page]". Not
> > intuitive enough. Is there a fix or workaround? like self submitting
> > form? example code would be greatly appreciated on both
> > 1) how to make a form self submitting and
> > 2) a even better solution to the t2.search() next/previous page
> > problem, if it exists
>
> > Thank you,
> > Hans
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:18811] t2.display(), reference field representation in view

2009-03-30 Thread Hans

t2.update() displays reference fields like defined in requires= It
retrieves and displays the values from the referenced table.

t2.display() does only display the numeric id value of the referenced
table.

what code is required to get t2.display show values of selected fields
in the referenced table instead?

code example below.

Hans



db.define_table('model_category',
SQLField('code','string',length=3,required=True,
   requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB
(db,'model_category.code')],unique=True),
SQLField('text','string'))
db.model_category.represent=lambda model_category: A
(model_category.code + ' ' + model_category.text,_href=t2.action
('display_model_category',model_category.id))

db.define_table('model',
SQLField('code','string',required=True,
   requires=IS_NOT_EMPTY(),IS_NOT_IN_DB
(db,'model.code')],unique=True),
SQLField('description','string',length=64,default=None),
SQLField('successor_of','reference model_master',
   requires=IS_NULL_OR(IS_IN_DB(db,'model.code'))),
SQLField('category','reference model_category',
   requires=IS_NULL_OR(IS_IN_DB(db,'model_category.id','%(code)s %
(text)s'

def display_model():
item=t2.display(db.model)
return dict(item=item)

def update_model():
item=t2.update(db.model)
return dict(item=item)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:19556] http://mdp.cti.depaul.edu/ down?

2009-04-10 Thread Hans

For me it looks like http://mdp.cti.depaul.edu/ and http://www.web2py.com
are down. http://depaul.edu/ is working.

Can someone confirm or is the problem on our network side ?

Hans
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:19561] Re: http://mdp.cti.depaul.edu/ down?

2009-04-10 Thread Hans

now for me its working again.

hans

On Apr 10, 7:17 pm, Boris Manojlovic 
wrote:
> it really didn't worked today so it was not just you :)
>
> On Fri, Apr 10, 2009 at 7:16 PM, Álvaro Justen [Turicas] <
>
>
>
> alvarojus...@gmail.com> wrote:
>
> > On Fri, Apr 10, 2009 at 1:41 PM, Hans
> >  wrote:
> > > For me it looks likehttp://mdp.cti.depaul.edu/and
> >http://www.web2py.com
> > > are down.http://depaul.edu/is working.
>
> > > Can someone confirm or is the problem on our network side ?
>
> > Yesterday I can't access these sites (they are the same IP, same
> > machine) but today it's OK.
> > Try to traceroute to 140.192.34.200 - it can be a route problem of
> > your provider (or from another backbone).
>
> > alv...@moveeel:~$ traceroutewww.web2py.com
> > traceroute towww.web2py.com(140.192.34.200), 30 hops max, 40 byte
> > packets
> >  1  192.168.1.1 (192.168.1.1)  1.629 ms  1.959 ms  2.627 ms
> >  2  10.183.0.1 (10.183.0.1)  6.728 ms  7.435 ms  7.846 ms
> >  3  201.39.229.131 (201.39.229.131)  8.598 ms  9.054 ms  9.465 ms
> >  4  201.39.229.133 (201.39.229.133)  10.505 ms  13.579 ms  14.012 ms
> >  5  200.255.52.13 (200.255.52.13)  316.001 ms  316.384 ms  316.891 ms
> >  6  200.244.163.47 (200.244.163.47)  1697.056 ms  1862.749 ms *
> >  7  ebt-T0-5-3-0-intl01.nyk.embratel.net.br (200.230.251.78)  2000.368
> > ms  2000.912 ms  2001.326 ms
> >  8  208.214.102.33 (208.214.102.33)  1598.674 ms  1604.979 ms  1605.521 ms
> >  9  0.so-2-0-0.XL1.NYC1.ALTER.NET (152.63.22.118)  2007.893 ms
> > 2008.387 ms  2009.525 ms
> > 10  0.so-7-3-0.XL3.NYC4.ALTER.NET (152.63.16.254)  2014.696 ms
> > 2015.255 ms  2021.964 ms
> > 11  0.ge-6-0-0.BR3.NYC4.ALTER.NET (152.63.18.5)  2021.332 ms  2029.797
> > ms 0.ge-5-0-0.BR3.NYC4.ALTER.NET (152.63.3.110)  2029.161 ms
> > 12  154.54.12.181 (154.54.12.181)  1682.909 ms  1677.243 ms  1677.148 ms
> > 13  te4-1.mpd01.jfk05.atlas.cogentco.com (154.54.1.153)  1655.279 ms
> > 1655.290 ms  1655.566 ms
> > 14  154.54.7.13 (154.54.7.13)  1662.064 ms
> > te2-4.ccr01.jfk02.atlas.cogentco.com (154.54.6.49)  1761.162 ms
> > 1767.033 ms
> > 15  te2-2.mpd01.bos01.atlas.cogentco.com (154.54.6.1)  1655.910 ms
> > 1661.950 ms  1658.117 ms
> > 16  * te7-8.ccr01.ord01.atlas.cogentco.com (154.54.7.81)  1675.390 ms
> > te2-2.ccr01.ord01.atlas.cogentco.com (154.54.6.154)  1687.326 ms
> > 17  te3-4.mpd01.ord03.atlas.cogentco.com (154.54.6.206)  1772.752 ms
> > vl3488.mpd01.ord03.atlas.cogentco.com (154.54.5.26)  1833.048 ms
> > 1832.130 ms
> > 18  DePaul.demarc.cogentco.com (66.250.5.34)  1762.168 ms  1767.830 ms
> >  1768.271 ms
> > 19  mfc-sac-1s-v844.netequip.depaul.edu (140.192.9.145)  1866.187 ms
> > 1888.065 ms  1893.365 ms
> > 20  mfc-cst-bs-v841.netequip.depaul.edu (140.192.9.177)  1905.406 ms *
> >  1971.492 ms
> > 21  mdp.cti.depaul.edu (140.192.34.200)  1919.781 ms  1913.543 ms
> >  1933.846 ms
>
> > Yes, the ISP I'm using here in my parents' town sucks (1919ms!).
>
> > --
> >  Álvaro Justen
> >  Peta5 - Telecomunicações e Software Livre
> >  21 3021-6001 / 9898-0141
> >  http://www.peta5.com.br/
>
> --
> "Only two things are infinite, the universe and human stupidity, and I'm not
> sure about the former."-Albert Einstein
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20073] db.table.field.represent question

2009-04-20 Thread Hans

The repesent code below produces following A title output:
'table.field2 123.456'  if the field2 value is 123.456 and
'table.field2' if the field2 value is None

What I want to achieve is following A title output:
'123.456' if the field2 value is 123.456 and
'None' if the field2 value is None

How can this be achieved?

Thanks,
Hans

db.table.id.represent = lambda value: A('%s' % (db
(db.table.id==value).select(db.table.field2)),_href=URL
(r=request,f='edit',args=value))

records=SQLTABLE(db(query).select(
db.table2.code,
db.table3.code,
db.table.id,
left=[db.table2.on(rows_table2),
  db.table3.on(rows_table3),
  db.table.on(rows_table)
 ],
orderby=db.table3.code|db.table2.code),
headers=headers
)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20095] Re: db.table.field.represent question

2009-04-20 Thread Hans

Thanks Massimo!

The following code worked for me

db.table.id.represent = lambda value: A(db
(db.table.id==value).select(db.table.field2)[0].field2,_href=URL
(r=request,f='update',args=value)) if len(db(db.table.id==value).select
(db.table.field2))>0 else A('None',_href=URL
(r=request,f='create',args='None'))


On Apr 20, 4:23 pm, mdipierro  wrote:
> I think you just need
>
> db.table.id.represent = lambda value: A(db.table
> [value].field2,_href=URL(r=request,f='edit',args=value))
>
> On 20 Apr, 08:55, Hans  wrote:
>
> > The repesent code below produces following A title output:
> > 'table.field2 123.456'  if the field2 value is 123.456 and
> > 'table.field2' if the field2 value is None
>
> > What I want to achieve is following A title output:
> > '123.456' if the field2 value is 123.456 and
> > 'None' if the field2 value is None
>
> > How can this be achieved?
>
> > Thanks,
> > Hans
>
> > db.table.id.represent = lambda value: A('%s' % (db
> > (db.table.id==value).select(db.table.field2)),_href=URL
> > (r=request,f='edit',args=value))
>
> >     records=SQLTABLE(db(query).select(
> >         db.table2.code,
> >         db.table3.code,
> >         db.table.id,
> >         left=[db.table2.on(rows_table2),
> >               db.table3.on(rows_table3),
> >               db.table.on(rows_table)
> >              ],
> >         orderby=db.table3.code|db.table2.code),
> >         headers=headers
> >         )
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20096] Re: db.table.field.represent question

2009-04-20 Thread Hans

Follow on question:

I've defined aliases of db.table.
When I later in the controller set db.alias1.field2.represent then it
is applied also to db.table.field2 and ALL other alliases!

How can the representation of only one specific
db.alias1.field2.represent be set while having different ones on
db.alias2.field2.represent, db.alias3.field2.represent and so on ?


On Apr 20, 7:10 pm, Hans 
wrote:
> Thanks Massimo!
>
> The following code worked for me
>
>     db.table.id.represent = lambda value: A(db
> (db.table.id==value).select(db.table.field2)[0].field2,_href=URL
> (r=request,f='update',args=value)) if len(db(db.table.id==value).select
> (db.table.field2))>0 else A('None',_href=URL
> (r=request,f='create',args='None'))
>
> On Apr 20, 4:23 pm, mdipierro  wrote:
>
> > I think you just need
>
> > db.table.id.represent = lambda value: A(db.table
> > [value].field2,_href=URL(r=request,f='edit',args=value))
>
> > On 20 Apr, 08:55, Hans  wrote:
>
> > > The repesent code below produces following A title output:
> > > 'table.field2 123.456'  if the field2 value is 123.456 and
> > > 'table.field2' if the field2 value is None
>
> > > What I want to achieve is following A title output:
> > > '123.456' if the field2 value is 123.456 and
> > > 'None' if the field2 value is None
>
> > > How can this be achieved?
>
> > > Thanks,
> > > Hans
>
> > > db.table.id.represent = lambda value: A('%s' % (db
> > > (db.table.id==value).select(db.table.field2)),_href=URL
> > > (r=request,f='edit',args=value))
>
> > >     records=SQLTABLE(db(query).select(
> > >         db.table2.code,
> > >         db.table3.code,
> > >         db.table.id,
> > >         left=[db.table2.on(rows_table2),
> > >               db.table3.on(rows_table3),
> > >               db.table.on(rows_table)
> > >              ],
> > >         orderby=db.table3.code|db.table2.code),
> > >         headers=headers
> > >         )
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20170] csv export of a join select, how to?

2009-04-21 Thread Hans

I would like to make a controller function that does csv export of a
join select (similar like SQL below but into csv - temporary table ok
if necessary) . How can this be done in web2py?

SELECT Persons.LastName,Orders.OrderNo INTO Persons_Order_Backup FROM
Persons INNER JOIN Orders ON Persons.P_Id=Orders.P_Id

Thanks,
Hans
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20175] Re: csv export of a join select, how to?

2009-04-21 Thread Hans

how do I get my_exporter() into csv? is there a web2py function which
can be called?

On Apr 21, 4:17 pm, mdipierro  wrote:
> def my_exporter():
>     return str(db(...).select(...))
>
> On 21 Apr, 08:52, Hans  wrote:
>
> > I would like to make a controller function that does csv export of a
> > join select (similar like SQL below but into csv - temporary table ok
> > if necessary) . How can this be done in web2py?
>
> > SELECT Persons.LastName,Orders.OrderNo INTO Persons_Order_Backup FROM
> > Persons INNER JOIN Orders ON Persons.P_Id=Orders.P_Id
>
> > Thanks,
> > Hans
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20185] Re: csv export of a join select, how to?

2009-04-21 Thread Hans

WOW Massimo! That's almost too simple to believe it ;-)

def my_exporter():
response.headers['Content-Type']='text/x-csv'
response.headers['Content-Disposition']='attachment;
filename=yourpreferredfilename.csv'
return str(db(...).select(...))

On Apr 21, 4:57 pm, mdipierro  wrote:
> the str(..) in  str(db(...).select(...)) converts the result of the
> slect into CSV.
>
> when you call the action "http:///my_exporter"; it returns a text
> page containing CSV.
>
> If you want the browser to automatically save it in a file you may
> want to add two lines:
>
> def my_exporter():
>     response.headers['Content-Type']='text/x-csv'
>     response.headers['Content-Disposition']='attachment;
> filename=yourpreferredfilename.csv" '
>     return str(db(...).select(...))
>
> Massimo
>
> On 21 Apr, 09:38, Hans  wrote:
>
> > how do I get my_exporter() into csv? is there a web2py function which
> > can be called?
>
> > On Apr 21, 4:17 pm, mdipierro  wrote:
>
> > > def my_exporter():
> > >     return str(db(...).select(...))
>
> > > On 21 Apr, 08:52, Hans  wrote:
>
> > > > I would like to make a controller function that does csv export of a
> > > > join select (similar like SQL below but into csv - temporary table ok
> > > > if necessary) . How can this be done in web2py?
>
> > > > SELECT Persons.LastName,Orders.OrderNo INTO Persons_Order_Backup FROM
> > > > Persons INNER JOIN Orders ON Persons.P_Id=Orders.P_Id
>
> > > > Thanks,
> > > > Hans
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20195] Re: db.table.field.represent question

2009-04-21 Thread Hans

Thanks Fran for your good hint.
Unfortunately in my case I need different field.represents within one
select, that's why I use the aliases.
Looks like I need to alter the SQLTABLE columns content before passing
it on.

Hans

On Apr 20, 9:46 pm, Fran  wrote:
> On Apr 20, 6:38 pm, mdipierro  wrote:
>
> > It cannot be done. because the same fiels in aliased tables is the
> > same field.
>
> It kind-of can though, surely?
> i.e. do the default .represent in the model, so that it is always
> available.
> A transient .represent can then be done within the context of a
> specific controller function to over-ride this.
>
> Not /quite/ what was asked, but may be useful.
> (I do this)
>
> F
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20608] Re: do you consult? do you have a company?

2009-04-27 Thread Hans

We provide tailored IT-Solutions, Consulting and Services.
http://www.easytouch-edv.com

On Apr 27, 7:42 am, mdipierro  wrote:
> I added the link.
>
> On 27 Apr, 00:37, SergeyPo  wrote:
>
> > My company Zarealye develops personal loans data mining application
> > with web frontend, uses web2py.  Link to English web page 
> > ishttp://zarealye.com/ca/Collect_Advantage/
>
> > And we have large CRM project with call centre intergration in our
> > plans.
>
> > On Apr 27, 8:44 am, mdipierro  wrote:
>
> > > If you work or own a company that uses web2py, in particular if you do
> > > any consulting, you may want to be listed as an "affiliated company"
> > > on the web2py page.
>
> > > It is free. Just ask me.
>
> > > Massimo
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20730] odd error: bug or limitation or ?

2009-04-28 Thread Hans

I'm experiencing a strange behavior within the code below. I tried to
split the problem in the smallest pieces which I'm able to debug. My
interpretation of the findings is that most likely I run into a web2py
internal variable length issue/limitation. Let me tell you why I think
that:

The tables ips1, ips2, ips3, ips4 and ips5 are identical aliases of
db.ipst.
There code works without error like it is below (watch the 3 commented
lines!).
The code also works without error if I comment out *ANY 3* out of the
db.ipst.id and its 5 aliases.
Each code line below (also the 3 commented ones) works without error
as long as any 3 other lines from db.ipst.id and its 5 aliases are
commented out - all combinations work.
The problem only occurs if I have less than 3 of the lines below
commented out.

Unfortunately I'm not able to debug into web2py framework code - and
despite hours of finding a solution for that I could not find one. And
based on the tools I have I'm at the end of all ideas I had.

If it helps I can also send you login information (and instructions to
get to the function with the issue) for the development server via
personal email upon request.

I'm using MySQL and Web2Py 1.61.1.


records=SQLTABLE(db(db.model_master.id==mid).select(
db.model_master.code,
db.subsidary.name,
db.ipst.id,
ips1.id,
#ips2.id,
#ips3.id,
#ips4.id,
ips5.id,
left=[db.ipst.on(rows_ipst),
  ips1.on(rows_ips1),
  ips2.on(rows_ips2),
  ips3.on(rows_ips3),
  ips4.on(rows_ips4),
  ips5.on(rows_ips5)
 ],
orderby=db.model_master.code|db.subsidary.line),
headers=headers)



Error traceback

Traceback (most recent call last):
  File "/usr/lib/web2py/gluon/restricted.py", line 98, in restricted
exec ccode in environment
  File "/usr/lib/web2py/applications/ips/controllers/default.py", line
657, in 
  File "/usr/lib/web2py/gluon/globals.py", line 75, in 
self._caller = lambda f: f()
  File "/usr/lib/web2py/applications/plugin_t2/modules/t2.py", line
1188, in h
return f(*a,**b)
  File "/usr/lib/web2py/applications/ips/controllers/default.py", line
537, in fcc
orderby=db.model_master.code|db.subsidary.line),
  File "/usr/lib/web2py/gluon/sql.py", line 1977, in select
r = response(query)
  File "/usr/lib/web2py/gluon/sql.py", line 1972, in response
self._db._execute(query)
  File "/usr/lib/web2py/gluon/sql.py", line 691, in 
self._execute = lambda *a, **b: self._cursor.execute(*a,**b)
  File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line
166, in execute
self.errorhandler(self, exc, value)
  File "/var/lib/python-support/python2.5/MySQLdb/connections.py",
line 35, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1054, "Unknown column 'subsidary.id' in 'on
clause'")
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20803] Re: odd error: bug or limitation or ?

2009-04-29 Thread Hans

Update: I've found that its a mysql issue not a web2py one.

On Apr 28, 4:52 pm, Hans 
wrote:
> I'm experiencing a strange behavior within the code below. I tried to
> split the problem in the smallest pieces which I'm able to debug. My
> interpretation of the findings is that most likely I run into a web2py
> internal variable length issue/limitation. Let me tell you why I think
> that:
>
> The tables ips1, ips2, ips3, ips4 and ips5 are identical aliases of
> db.ipst.
> There code works without error like it is below (watch the 3 commented
> lines!).
> The code also works without error if I comment out *ANY 3* out of the
> db.ipst.id and its 5 aliases.
> Each code line below (also the 3 commented ones) works without error
> as long as any 3 other lines from db.ipst.id and its 5 aliases are
> commented out - all combinations work.
> The problem only occurs if I have less than 3 of the lines below
> commented out.
>
> Unfortunately I'm not able to debug into web2py framework code - and
> despite hours of finding a solution for that I could not find one. And
> based on the tools I have I'm at the end of all ideas I had.
>
> If it helps I can also send you login information (and instructions to
> get to the function with the issue) for the development server via
> personal email upon request.
>
> I'm using MySQL and Web2Py 1.61.1.
>
>     records=SQLTABLE(db(db.model_master.id==mid).select(
>         db.model_master.code,
>         db.subsidary.name,
>         db.ipst.id,
>         ips1.id,
> #        ips2.id,
> #        ips3.id,
> #        ips4.id,
>         ips5.id,
>         left=[db.ipst.on(rows_ipst),
>               ips1.on(rows_ips1),
>               ips2.on(rows_ips2),
>               ips3.on(rows_ips3),
>               ips4.on(rows_ips4),
>               ips5.on(rows_ips5)
>              ],
>         orderby=db.model_master.code|db.subsidary.line),
>         headers=headers)
>
> Error traceback
>
> Traceback (most recent call last):
>   File "/usr/lib/web2py/gluon/restricted.py", line 98, in restricted
>     exec ccode in environment
>   File "/usr/lib/web2py/applications/ips/controllers/default.py", line
> 657, in 
>   File "/usr/lib/web2py/gluon/globals.py", line 75, in 
>     self._caller = lambda f: f()
>   File "/usr/lib/web2py/applications/plugin_t2/modules/t2.py", line
> 1188, in h
>     return f(*a,**b)
>   File "/usr/lib/web2py/applications/ips/controllers/default.py", line
> 537, in fcc
>     orderby=db.model_master.code|db.subsidary.line),
>   File "/usr/lib/web2py/gluon/sql.py", line 1977, in select
>     r = response(query)
>   File "/usr/lib/web2py/gluon/sql.py", line 1972, in response
>     self._db._execute(query)
>   File "/usr/lib/web2py/gluon/sql.py", line 691, in 
>     self._execute = lambda *a, **b: self._cursor.execute(*a,**b)
>   File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line
> 166, in execute
>     self.errorhandler(self, exc, value)
>   File "/var/lib/python-support/python2.5/MySQLdb/connections.py",
> line 35, in defaulterrorhandler
>     raise errorclass, errorvalue
> OperationalError: (1054, "Unknown column 'subsidary.id' in 'on
> clause'")
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20844] Re: odd error: bug or limitation or ?

2009-04-29 Thread Hans

Yarko,

deep down in the reference manual of mysql 5.1 I've found the reason
for the issue, http://dev.mysql.com/doc/refman/5.1/en/join.html.

Basically as of mysql version 5.0.12 there where some changes
introduced which are not backward compatible (on older mysql versions
the select/joins work on newer I get the described error). The change
was caused by mysql moving to SQL 2003 compliance.

Thanks god the docu and manuals of mysql are very good and it was easy
to re-write the select command in order to work on SQL 2003 based on
the information in the docu. Basically it was down to avoiding the
comma join which causes in combination with ON joins headache as of
SQL 2003.

In my case the solution looks like:

records=SQLTABLE(db(db.model_master.id==mid).select(
db.model_master.code,
db.subsidary.name,
db.ipst.id,
ips1.id,
ips2.id,
ips3.id,
ips4.id,
ips5.id,
left=[db.subsidary.on(db.subsidary.id>0),
  db.ipst.on(rows_ipst),
  ips1.on(rows_ips1),
  ips2.on(rows_ips2),
  ips3.on(rows_ips3),
  ips4.on(rows_ips4),
  ips5.on(rows_ips5)
 ],
orderby=db.model_master.code|db.subsidary.line),
headers=headers)

Here db.subsidary is not a comma join any more but a join with ON
clause - making it SQL 2003 compliant.

Hans

On Apr 29, 4:42 pm, Yarko Tymciurak  wrote:
> I'd be interested to hear a little more about what the mysql issue is...
> (I don't use, but am/will be forced to on one work server, so want to hear
> what others are going thru)
>
> Thanks,
> - Yarko
>
> 2009/4/29 mdipierro 
>
>
>
> > there lots of mysql issues unfortunately.
>
> > On Apr 29, 7:08 am, Hans 
> > wrote:
> > > Update: I've found that its a mysql issue not a web2py one.
>
> > > On Apr 28, 4:52 pm, Hans 
> > > wrote:
>
> > > > I'm experiencing a strange behavior within the code below. I tried to
> > > > split the problem in the smallest pieces which I'm able to debug. My
> > > > interpretation of the findings is that most likely I run into a web2py
> > > > internal variable length issue/limitation. Let me tell you why I think
> > > > that:
>
> > > > The tables ips1, ips2, ips3, ips4 and ips5 are identical aliases of
> > > > db.ipst.
> > > > There code works without error like it is below (watch the 3 commented
> > > > lines!).
> > > > The code also works without error if I comment out *ANY 3* out of the
> > > > db.ipst.id and its 5 aliases.
> > > > Each code line below (also the 3 commented ones) works without error
> > > > as long as any 3 other lines from db.ipst.id and its 5 aliases are
> > > > commented out - all combinations work.
> > > > The problem only occurs if I have less than 3 of the lines below
> > > > commented out.
>
> > > > Unfortunately I'm not able to debug into web2py framework code - and
> > > > despite hours of finding a solution for that I could not find one. And
> > > > based on the tools I have I'm at the end of all ideas I had.
>
> > > > If it helps I can also send you login information (and instructions to
> > > > get to the function with the issue) for the development server via
> > > > personal email upon request.
>
> > > > I'm using MySQL and Web2Py 1.61.1.
>
> > > >     records=SQLTABLE(db(db.model_master.id==mid).select(
> > > >         db.model_master.code,
> > > >         db.subsidary.name,
> > > >         db.ipst.id,
> > > >         ips1.id,
> > > > #        ips2.id,
> > > > #        ips3.id,
> > > > #        ips4.id,
> > > >         ips5.id,
> > > >         left=[db.ipst.on(rows_ipst),
> > > >               ips1.on(rows_ips1),
> > > >               ips2.on(rows_ips2),
> > > >               ips3.on(rows_ips3),
> > > >               ips4.on(rows_ips4),
> > > >               ips5.on(rows_ips5)
> > > >              ],
> > > >         orderby=db.model_master.code|db.subsidary.line),
> > > >         headers=headers)
>
> > > > Error traceback
>
> > > > Traceback (most recent call last):
> > > >   File "/usr/lib/web2py/gluon/restricted.py", line 98, in restricted
> > > >     exec ccode in environment
> > > >   File "/usr/lib/web2py/applications/ips/controllers/default.py", line
> > > > 657, in 
> > >

[web2py:20846] Re: odd error: bug or limitation or ?

2009-04-29 Thread Hans

So the limitation was my capability to write a SQL 2003 compliant
select statement ;-)

On Apr 29, 11:59 pm, Hans 
wrote:
> Yarko,
>
> deep down in the reference manual of mysql 5.1 I've found the reason
> for the issue,http://dev.mysql.com/doc/refman/5.1/en/join.html.
>
> Basically as of mysql version 5.0.12 there where some changes
> introduced which are not backward compatible (on older mysql versions
> the select/joins work on newer I get the described error). The change
> was caused by mysql moving to SQL 2003 compliance.
>
> Thanks god the docu and manuals of mysql are very good and it was easy
> to re-write the select command in order to work on SQL 2003 based on
> the information in the docu. Basically it was down to avoiding the
> comma join which causes in combination with ON joins headache as of
> SQL 2003.
>
> In my case the solution looks like:
>
>     records=SQLTABLE(db(db.model_master.id==mid).select(
>         db.model_master.code,
>         db.subsidary.name,
>         db.ipst.id,
>         ips1.id,
>         ips2.id,
>         ips3.id,
>         ips4.id,
>         ips5.id,
>         left=[db.subsidary.on(db.subsidary.id>0),
>               db.ipst.on(rows_ipst),
>               ips1.on(rows_ips1),
>               ips2.on(rows_ips2),
>               ips3.on(rows_ips3),
>               ips4.on(rows_ips4),
>               ips5.on(rows_ips5)
>              ],
>         orderby=db.model_master.code|db.subsidary.line),
>         headers=headers)
>
> Here db.subsidary is not a comma join any more but a join with ON
> clause - making it SQL 2003 compliant.
>
> Hans
>
> On Apr 29, 4:42 pm, Yarko Tymciurak  wrote:
>
> > I'd be interested to hear a little more about what the mysql issue is...
> > (I don't use, but am/will be forced to on one work server, so want to hear
> > what others are going thru)
>
> > Thanks,
> > - Yarko
>
> > 2009/4/29 mdipierro 
>
> > > there lots of mysql issues unfortunately.
>
> > > On Apr 29, 7:08 am, Hans 
> > > wrote:
> > > > Update: I've found that its a mysql issue not a web2py one.
>
> > > > On Apr 28, 4:52 pm, Hans 
> > > > wrote:
>
> > > > > I'm experiencing a strange behavior within the code below. I tried to
> > > > > split the problem in the smallest pieces which I'm able to debug. My
> > > > > interpretation of the findings is that most likely I run into a web2py
> > > > > internal variable length issue/limitation. Let me tell you why I think
> > > > > that:
>
> > > > > The tables ips1, ips2, ips3, ips4 and ips5 are identical aliases of
> > > > > db.ipst.
> > > > > There code works without error like it is below (watch the 3 commented
> > > > > lines!).
> > > > > The code also works without error if I comment out *ANY 3* out of the
> > > > > db.ipst.id and its 5 aliases.
> > > > > Each code line below (also the 3 commented ones) works without error
> > > > > as long as any 3 other lines from db.ipst.id and its 5 aliases are
> > > > > commented out - all combinations work.
> > > > > The problem only occurs if I have less than 3 of the lines below
> > > > > commented out.
>
> > > > > Unfortunately I'm not able to debug into web2py framework code - and
> > > > > despite hours of finding a solution for that I could not find one. And
> > > > > based on the tools I have I'm at the end of all ideas I had.
>
> > > > > If it helps I can also send you login information (and instructions to
> > > > > get to the function with the issue) for the development server via
> > > > > personal email upon request.
>
> > > > > I'm using MySQL and Web2Py 1.61.1.
>
> > > > >     records=SQLTABLE(db(db.model_master.id==mid).select(
> > > > >         db.model_master.code,
> > > > >         db.subsidary.name,
> > > > >         db.ipst.id,
> > > > >         ips1.id,
> > > > > #        ips2.id,
> > > > > #        ips3.id,
> > > > > #        ips4.id,
> > > > >         ips5.id,
> > > > >         left=[db.ipst.on(rows_ipst),
> > > > >               ips1.on(rows_ips1),
> > > > >               ips2.on(rows_ips2),
> > > > >               ips3.on(rows_ips3),
> > > > >               ips4.on(rows_ips4),
> > > > >         

[web2py:21132] Re: Table already exists problem [again]

2009-05-04 Thread Hans

I'm having a similar problem. Last time I solved it by deleting the
database and setting it up new. With more data it gets a pain. I read
about setting 'migrate=False' to avoid the issue. I could use that for
'own' tables, but I get the same error for tables created by the T2
plugin.
Like TheDude also I have changed the user/pass for MySQL connection.
Maybe Web2Py thinks it needs to create the tables new after user/pass
change?

Traceback (most recent call last):
  File "/usr/lib/web2py/gluon/restricted.py", line 98, in restricted
exec ccode in environment
  File "/usr/lib/web2py/applications/ips/models/db.py", line 19, in

t2=T2(request,response,session,cache,T,db)
  File "/usr/lib/web2py/applications/plugin_t2/modules/t2.py", line
98, in __init__
self._create_tables()
  File "/usr/lib/web2py/applications/plugin_t2/modules/t2.py", line
341, in _create_tables
t=db.define_table('t2_person',T2.base_table(db,'t2_person'))
  File "/usr/lib/web2py/gluon/sql.py", line 938, in define_table
raise e
OperationalError: (1050, "Table 't2_person' already exists")

On May 4, 7:10 am, TheDude  wrote:
> Massimo, I know that we've talked about this in the past, but here we
> go again...
>
> I'm using the latest web2py, in my applications, I would define tables
> as usual only to get an SQL error saying the table exists. I tried
> clearing out my "databases" folder, and the only way to clear out
> would be to delete the database entirely (which is something that I
> *should not* have to do). According to web2py docs, the DAL handles
> this type of crap perfectly and just fine. As it should, leave the
> migration/DAL issues to DAL and not to the user. This is what turned
> my head towards web2py over Django.
>
> Is CREATE TABLE `tablename` IF NOT EXISTS SQL ANSI? Either way, the
> MySQL handler should perform this rather than just create table under
> the next patch. It would solve *a lot* of hassle. The problem occurred
> AFTER I changed my user/pass combo for the MySQL connection string.
> Could this cause any problems?
>
> Someone else had this problem unresolved a long time 
> ago...http://groups.google.com/group/web2py/browse_thread/thread/94a7107c68...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21148] Re: Table already exists problem [again]

2009-05-04 Thread Hans

how to apply this for T2 tables like t2_person?
would this workaround survive version updates of T2?

hans


On May 4, 4:23 pm, mdipierro  wrote:
> This is complex. Currently the way to avoid the problem is to name
> the .table files via
>
> db.define_table('something',,migrate='something.table')
>
> using "IF EXISTS" would only solve this problem to create others.
>
> Massimo
>
> On May 4, 7:02 am, Hans 
> wrote:
>
> > I'm having a similar problem. Last time I solved it by deleting the
> > database and setting it up new. With more data it gets a pain. I read
> > about setting 'migrate=False' to avoid the issue. I could use that for
> > 'own' tables, but I get the same error for tables created by the T2
> > plugin.
> > Like TheDude also I have changed the user/pass for MySQL connection.
> > Maybe Web2Py thinks it needs to create the tables new after user/pass
> > change?
>
> > Traceback (most recent call last):
> >   File "/usr/lib/web2py/gluon/restricted.py", line 98, in restricted
> >     exec ccode in environment
> >   File "/usr/lib/web2py/applications/ips/models/db.py", line 19, in
> > 
> >     t2=T2(request,response,session,cache,T,db)
> >   File "/usr/lib/web2py/applications/plugin_t2/modules/t2.py", line
> > 98, in __init__
> >     self._create_tables()
> >   File "/usr/lib/web2py/applications/plugin_t2/modules/t2.py", line
> > 341, in _create_tables
> >     t=db.define_table('t2_person',T2.base_table(db,'t2_person'))
> >   File "/usr/lib/web2py/gluon/sql.py", line 938, in define_table
> >     raise e
> > OperationalError: (1050, "Table 't2_person' already exists")
>
> > On May 4, 7:10 am, TheDude  wrote:
>
> > > Massimo, I know that we've talked about this in the past, but here we
> > > go again...
>
> > > I'm using the latest web2py, in my applications, I would define tables
> > > as usual only to get an SQL error saying the table exists. I tried
> > > clearing out my "databases" folder, and the only way to clear out
> > > would be to delete the database entirely (which is something that I
> > > *should not* have to do). According to web2py docs, the DAL handles
> > > this type of crap perfectly and just fine. As it should, leave the
> > > migration/DAL issues to DAL and not to the user. This is what turned
> > > my head towards web2py over Django.
>
> > > Is CREATE TABLE `tablename` IF NOT EXISTS SQL ANSI? Either way, the
> > > MySQL handler should perform this rather than just create table under
> > > the next patch. It would solve *a lot* of hassle. The problem occurred
> > > AFTER I changed my user/pass combo for the MySQL connection string.
> > > Could this cause any problems?
>
> > > Someone else had this problem unresolved a long time 
> > > ago...http://groups.google.com/group/web2py/browse_thread/thread/94a7107c68...
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21222] Re: Table already exists problem [again]

2009-05-05 Thread Hans

Massimo,

'T2 is dead and not longer supported' is definitely a killer
argument :-/
If I'm not mistaken then the same problem exist with the auth_ tables.

How should the db.define_table
('something',,migrate='something.table') workaround be applied to
auth_ tables in a way that it survives framework updates?

Hans

On May 4, 4:54 pm, mdipierro  wrote:
> T2 is dead. I will be no longer be supported. In fact much of the T2
> functionality is in gluon.tools
> T3 will survive but will be rebuilt on top of tools and events
>
> Massimo
>
> On May 4, 9:39 am, Hans 
> wrote:
>
> > how to apply this for T2 tables like t2_person?
> > would this workaround survive version updates of T2?
>
> > hans
>
> > On May 4, 4:23 pm, mdipierro  wrote:
>
> > > This is complex. Currently the way to avoid the problem is to name
> > > the .table files via
>
> > > db.define_table('something',,migrate='something.table')
>
> > > using "IF EXISTS" would only solve this problem to create others.
>
> > > Massimo
>
> > > On May 4, 7:02 am, Hans 
> > > wrote:
>
> > > > I'm having a similar problem. Last time I solved it by deleting the
> > > > database and setting it up new. With more data it gets a pain. I read
> > > > about setting 'migrate=False' to avoid the issue. I could use that for
> > > > 'own' tables, but I get the same error for tables created by the T2
> > > > plugin.
> > > > Like TheDude also I have changed the user/pass for MySQL connection.
> > > > Maybe Web2Py thinks it needs to create the tables new after user/pass
> > > > change?
>
> > > > Traceback (most recent call last):
> > > >   File "/usr/lib/web2py/gluon/restricted.py", line 98, in restricted
> > > >     exec ccode in environment
> > > >   File "/usr/lib/web2py/applications/ips/models/db.py", line 19, in
> > > > 
> > > >     t2=T2(request,response,session,cache,T,db)
> > > >   File "/usr/lib/web2py/applications/plugin_t2/modules/t2.py", line
> > > > 98, in __init__
> > > >     self._create_tables()
> > > >   File "/usr/lib/web2py/applications/plugin_t2/modules/t2.py", line
> > > > 341, in _create_tables
> > > >     t=db.define_table('t2_person',T2.base_table(db,'t2_person'))
> > > >   File "/usr/lib/web2py/gluon/sql.py", line 938, in define_table
> > > >     raise e
> > > > OperationalError: (1050, "Table 't2_person' already exists")
>
> > > > On May 4, 7:10 am, TheDude  wrote:
>
> > > > > Massimo, I know that we've talked about this in the past, but here we
> > > > > go again...
>
> > > > > I'm using the latest web2py, in my applications, I would define tables
> > > > > as usual only to get an SQL error saying the table exists. I tried
> > > > > clearing out my "databases" folder, and the only way to clear out
> > > > > would be to delete the database entirely (which is something that I
> > > > > *should not* have to do). According to web2py docs, the DAL handles
> > > > > this type of crap perfectly and just fine. As it should, leave the
> > > > > migration/DAL issues to DAL and not to the user. This is what turned
> > > > > my head towards web2py over Django.
>
> > > > > Is CREATE TABLE `tablename` IF NOT EXISTS SQL ANSI? Either way, the
> > > > > MySQL handler should perform this rather than just create table under
> > > > > the next patch. It would solve *a lot* of hassle. The problem occurred
> > > > > AFTER I changed my user/pass combo for the MySQL connection string.
> > > > > Could this cause any problems?
>
> > > > > Someone else had this problem unresolved a long time 
> > > > > ago...http://groups.google.com/group/web2py/browse_thread/thread/94a7107c68...
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21241] Re: Table already exists problem [again]

2009-05-05 Thread Hans

IMO one more thing to consider is that a database is not necessarily
exclusively owned by one application. I would even go further and say
default should be a database is NOT exclusively owned by one app and
also not by one framework.

Currently the problem arises if the .table files of one web2py app
(stored in app/database folder) get out of sync with the database.
To get the .table files of a web2py app out of sync with a central
database is easy. Just have a 2nd app create a table which is also
used by app #1. If app #1 does not set 'migrate=False', including
auth.define_table(migrate=False), this app will not work any more.
Same for app #3, #4, ... Those apps can also be non web2py apps which
automatically create non existing tables, like web2py does it by
default.

my 2 eurocents

Hans

I understand that throwing the default assumption 'the application
owns the database tab
On May 5, 6:13 pm, mdipierro  wrote:
> Yes or perhaps a repair.py script.
>
> Massimo
>
> On May 5, 10:24 am, Yarko Tymciurak  wrote:
>
> > On Tue, May 5, 2009 at 9:25 AM, mdipierro  wrote:
>
> > 
>
> > > The only problems I can see would arise if:
> > > - You delete databases/*.table but the database is still there
> > > (updates do not cause this). Bad luck. One should not delete files, or
> > > at least make a backup.
>
> > Maybe at some point we can address this w/ some mercurial checkin of such
> > important files on a running system...
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21250] Re: Table already exists problem [again]

2009-05-05 Thread Hans

Symlinking the app/database folder would work in environments with up
to one application server.

Unfortunately also I don't know how to query the database table
structure in all web2py supported databases. But, maybe, we have some
experts for one or the other supported database on the forum and
willing to contribute!?

On May 5, 9:14 pm, mdipierro  wrote:
> I agree and it does not have to me. The current system does not limit
> that. It only limits the fact that one app should do migrations. If
> more than one app may do migrations just symlink the database folder.
>
> Massimo
>
> On May 5, 2:09 pm, Hans 
> wrote:
>
> > IMO one more thing to consider is that a database is not necessarily
> > exclusively owned by one application. I would even go further and say
> > default should be a database is NOT exclusively owned by one app and
> > also not by one framework.
>
> > Currently the problem arises if the .table files of one web2py app
> > (stored in app/database folder) get out of sync with the database.
> > To get the .table files of a web2py app out of sync with a central
> > database is easy. Just have a 2nd app create a table which is also
> > used by app #1. If app #1 does not set 'migrate=False', including
> > auth.define_table(migrate=False), this app will not work any more.
> > Same for app #3, #4, ... Those apps can also be non web2py apps which
> > automatically create non existing tables, like web2py does it by
> > default.
>
> > my 2 eurocents
>
> > Hans
>
> > I understand that throwing the default assumption 'the application
> > owns the database tab
> > On May 5, 6:13 pm, mdipierro  wrote:
>
> > > Yes or perhaps a repair.py script.
>
> > > Massimo
>
> > > On May 5, 10:24 am, Yarko Tymciurak  wrote:
>
> > > > On Tue, May 5, 2009 at 9:25 AM, mdipierro  
> > > > wrote:
>
> > > > 
>
> > > > > The only problems I can see would arise if:
> > > > > - You delete databases/*.table but the database is still there
> > > > > (updates do not cause this). Bad luck. One should not delete files, or
> > > > > at least make a backup.
>
> > > > Maybe at some point we can address this w/ some mercurial checkin of 
> > > > such
> > > > important files on a running system...
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21405] selection of local file

2009-05-07 Thread Hans

I'm trying to import some content directly from an excel file which
the user selects from its local files. I've taken and modified code
from the admin controller for retrieving the path/filename thru a nice
file selection window.

The problem: I get only the filename of a locked temporary file, not
the original filename. If I close the temporary file, to remove the
lock, the file is automatically deleted...

I would not mind to work with a temporary copy of the original file,
but retrieving the original path/filename thru a similar file
selection window would be prefered. How can this be achieved?

Hans
P.S. I'm using the xlrd module from http://pypi.python.org/pypi/xlrd

### viewer ###
{{extend 'layout.html'}}
excel_read.html template


{{=t2.T('Select File')}}
{{=FORM('File: ',INPUT(_type='file',_name='filename'),INPUT
(_type='submit', _value='submit'))}}



{{=BEAUTIFY(response._vars)}}



### controller ###
def excel_read():
result={}
if request.vars.filename != None:
try:
import xlrd

# >>> can't locate the originally selected path/filename in
request.vars.filename <<<
book = xlrd.open_workbook(request.vars.filename.file.name)
# >>> with a valid path/filename it works <<<
book = xlrd.open_workbook('F:/Documents and Settings/Hans/
Desktop/test.xls')

result['The number of worksheets is']=book.nsheets
result["Worksheet name(s)"]= book.sheet_names()
sh = book.sheet_by_index(0)
result['sh.name']=sh.name
result['sh.nrows']=sh.nrows
result['sh.ncols']=sh.ncols
result['Cell D30 is']=sh.cell_value(rowx=29, colx=3)
for rx in range(sh.nrows):
result['row ' + str(rx)]=sh.row(rx)
except:
response.flash = T('excel_read exception')
return dict(result=result)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21409] Re: cool menu

2009-05-07 Thread Hans

wow, very cool!
how can it (or something similar) be integrated into a web2py app?

hans

On May 7, 9:44 pm, mdipierro  wrote:
> http://www.filamentgroup.com/lab/jquery_ipod_style_and_flyout_menus/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21509] Re: selection of local file

2009-05-08 Thread Hans

There is a problem with the following code line
> open(path,'w').write(request.vars.filename.file.read())

It creates the file 'a_dummy_file_name.xls' but it is not the same
size as the original file, for example:
6790KB original.xls
6862KB a_dummy_file_name.xls

If I try to open the dummy file with excel or open office it says the
file is corrupt.
I've tried to copy the file manually right after this code line and
continued execution from there onward...rest works nicely.

I tried on windows and on ubuntu, seems the same problem.

Any idea how to solve that issue with the corrupt file (=getting a
exact copy) ?


thanks,
hans


On May 7, 10:56 pm, mdipierro  wrote:
> This should do
>
>  def excel_read():
>     result={}
>     if request.vars.filename != None:
>         try:
>             import xlrd
>             path=os.path.join
> (request.folder,'private','a_dummy_file_name.xls')
>             open(path,'w').write(request.vars.filename.file.read())
>             book = xlrd.open_workbook(path)
>             result['The number of worksheets is']=book.nsheets
>             result["Worksheet name(s)"]= book.sheet_names()
>             sh = book.sheet_by_index(0)
>             result['sh.name']=sh.name
>             result['sh.nrows']=sh.nrows
>             result['sh.ncols']=sh.ncols
>             result['Cell D30 is']=sh.cell_value(rowx=29, colx=3)
>             for rx in range(sh.nrows):
>                 result['row ' + str(rx)]=sh.row(rx)
>         except:
>             response.flash = T('excel_read exception')
>     return dict(result=result)
>
> for you request.vars.filename is a cgi.FieldStorage object. It is not
> a named file.
> It containes
> - request.vars.filename.file (a buffered input stream)
> - request.vars.filename.filename (the original filename)
> For you to access it you should read the stream and save it with a
> name. Do not use the original filename to avoid directory traversal
> attacks.
>
> Massimo
>
> On May 7, 2:58 pm, Hans 
> wrote:
>
> > I'm trying to import some content directly from an excel file which
> > the user selects from its local files. I've taken and modified code
> > from the admin controller for retrieving the path/filename thru a nice
> > file selection window.
>
> > The problem: I get only the filename of a locked temporary file, not
> > the original filename. If I close the temporary file, to remove the
> > lock, the file is automatically deleted...
>
> > I would not mind to work with a temporary copy of the original file,
> > but retrieving the original path/filename thru a similar file
> > selection window would be prefered. How can this be achieved?
>
> > Hans
> > P.S. I'm using the xlrd module fromhttp://pypi.python.org/pypi/xlrd
>
> > ### viewer ###
> > {{extend 'layout.html'}}
> > excel_read.html template
>
> > 
> > {{=t2.T('Select File')}}
> > {{=FORM('File: ',INPUT(_type='file',_name='filename'),INPUT
> > (_type='submit', _value='submit'))}}
> > 
>
> > 
> > {{=BEAUTIFY(response._vars)}}
> > 
>
> > ### controller ###
> > def excel_read():
> >     result={}
> >     if request.vars.filename != None:
> >         try:
> >             import xlrd
>
> > # >>> can't locate the originally selected path/filename in
> > request.vars.filename <<<
> >             book = xlrd.open_workbook(request.vars.filename.file.name)
> > # >>> with a valid path/filename it works <<<
> >             book = xlrd.open_workbook('F:/Documents and Settings/Hans/
> > Desktop/test.xls')
>
> >             result['The number of worksheets is']=book.nsheets
> >             result["Worksheet name(s)"]= book.sheet_names()
> >             sh = book.sheet_by_index(0)
> >             result['sh.name']=sh.name
> >             result['sh.nrows']=sh.nrows
> >             result['sh.ncols']=sh.ncols
> >             result['Cell D30 is']=sh.cell_value(rowx=29, colx=3)
> >             for rx in range(sh.nrows):
> >                 result['row ' + str(rx)]=sh.row(rx)
> >         except:
> >             response.flash = T('excel_read exception')
> >     return dict(result=result)
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21512] Re: selection of local file

2009-05-08 Thread Hans

> shutil.copyfileobj(request.vars.filename,open(path,'w'))
raises exception: (, AttributeError
('read',), )

tried also
   shutil.copyfileobj(request.vars.filename.file,open(path,'w'))
which creates a copy, but again a corrupt copy.

This tests now were done just on windows xp.

Any other ideas how this can be achieved?

Hans


On May 8, 10:29 pm, mdipierro  wrote:
> It may be an issue with buffer size. Try
>
> import shutil
> shutil.copyfileobj(request.vars.filename,open(path,'w'))
>
> Massimo
>
> On May 8, 2:56 pm, Hans 
> wrote:
>
> > There is a problem with the following code line
>
> > >             open(path,'w').write(request.vars.filename.file.read())
>
> > It creates the file 'a_dummy_file_name.xls' but it is not the same
> > size as the original file, for example:
> > 6790KB original.xls
> > 6862KB a_dummy_file_name.xls
>
> > If I try to open the dummy file with excel or open office it says the
> > file is corrupt.
> > I've tried to copy the file manually right after this code line and
> > continued execution from there onward...rest works nicely.
>
> > I tried on windows and on ubuntu, seems the same problem.
>
> > Any idea how to solve that issue with the corrupt file (=getting a
> > exact copy) ?
>
> > thanks,
> > hans
>
> > On May 7, 10:56 pm, mdipierro  wrote:
>
> > > This should do
>
> > >  def excel_read():
> > >     result={}
> > >     if request.vars.filename != None:
> > >         try:
> > >             import xlrd
> > >             path=os.path.join
> > > (request.folder,'private','a_dummy_file_name.xls')
> > >             open(path,'w').write(request.vars.filename.file.read())
> > >             book = xlrd.open_workbook(path)
> > >             result['The number of worksheets is']=book.nsheets
> > >             result["Worksheet name(s)"]= book.sheet_names()
> > >             sh = book.sheet_by_index(0)
> > >             result['sh.name']=sh.name
> > >             result['sh.nrows']=sh.nrows
> > >             result['sh.ncols']=sh.ncols
> > >             result['Cell D30 is']=sh.cell_value(rowx=29, colx=3)
> > >             for rx in range(sh.nrows):
> > >                 result['row ' + str(rx)]=sh.row(rx)
> > >         except:
> > >             response.flash = T('excel_read exception')
> > >     return dict(result=result)
>
> > > for you request.vars.filename is a cgi.FieldStorage object. It is not
> > > a named file.
> > > It containes
> > > - request.vars.filename.file (a buffered input stream)
> > > - request.vars.filename.filename (the original filename)
> > > For you to access it you should read the stream and save it with a
> > > name. Do not use the original filename to avoid directory traversal
> > > attacks.
>
> > > Massimo
>
> > > On May 7, 2:58 pm, Hans 
> > > wrote:
>
> > > > I'm trying to import some content directly from an excel file which
> > > > the user selects from its local files. I've taken and modified code
> > > > from the admin controller for retrieving the path/filename thru a nice
> > > > file selection window.
>
> > > > The problem: I get only the filename of a locked temporary file, not
> > > > the original filename. If I close the temporary file, to remove the
> > > > lock, the file is automatically deleted...
>
> > > > I would not mind to work with a temporary copy of the original file,
> > > > but retrieving the original path/filename thru a similar file
> > > > selection window would be prefered. How can this be achieved?
>
> > > > Hans
> > > > P.S. I'm using the xlrd module fromhttp://pypi.python.org/pypi/xlrd
>
> > > > ### viewer ###
> > > > {{extend 'layout.html'}}
> > > > excel_read.html template
>
> > > > 
> > > > {{=t2.T('Select File')}}
> > > > {{=FORM('File: ',INPUT(_type='file',_name='filename'),INPUT
> > > > (_type='submit', _value='submit'))}}
> > > > 
>
> > > > 
> > > > {{=BEAUTIFY(response._vars)}}
> > > > 
>
> > > > ### controller ###
> > > > def excel_read():
> > > >     result={}
> >

[web2py:21513] Re: selection of local file

2009-05-08 Thread Hans

> shutil.copyfileobj(request.vars.filename,open(path,'w'))
raises exception: (, AttributeError
('read',), )

tried also
   shutil.copyfileobj(request.vars.filename.file,open(path,'w'))
which creates a copy, but again a corrupt copy.

This tests now were done just on windows xp.

Any other ideas how to solve this?

Hans

On May 8, 10:29 pm, mdipierro  wrote:
> It may be an issue with buffer size. Try
>
> import shutil
> shutil.copyfileobj(request.vars.filename,open(path,'w'))
>
> Massimo
>
> On May 8, 2:56 pm, Hans 
> wrote:
>
> > There is a problem with the following code line
>
> > >             open(path,'w').write(request.vars.filename.file.read())
>
> > It creates the file 'a_dummy_file_name.xls' but it is not the same
> > size as the original file, for example:
> > 6790KB original.xls
> > 6862KB a_dummy_file_name.xls
>
> > If I try to open the dummy file with excel or open office it says the
> > file is corrupt.
> > I've tried to copy the file manually right after this code line and
> > continued execution from there onward...rest works nicely.
>
> > I tried on windows and on ubuntu, seems the same problem.
>
> > Any idea how to solve that issue with the corrupt file (=getting a
> > exact copy) ?
>
> > thanks,
> > hans
>
> > On May 7, 10:56 pm, mdipierro  wrote:
>
> > > This should do
>
> > >  def excel_read():
> > >     result={}
> > >     if request.vars.filename != None:
> > >         try:
> > >             import xlrd
> > >             path=os.path.join
> > > (request.folder,'private','a_dummy_file_name.xls')
> > >             open(path,'w').write(request.vars.filename.file.read())
> > >             book = xlrd.open_workbook(path)
> > >             result['The number of worksheets is']=book.nsheets
> > >             result["Worksheet name(s)"]= book.sheet_names()
> > >             sh = book.sheet_by_index(0)
> > >             result['sh.name']=sh.name
> > >             result['sh.nrows']=sh.nrows
> > >             result['sh.ncols']=sh.ncols
> > >             result['Cell D30 is']=sh.cell_value(rowx=29, colx=3)
> > >             for rx in range(sh.nrows):
> > >                 result['row ' + str(rx)]=sh.row(rx)
> > >         except:
> > >             response.flash = T('excel_read exception')
> > >     return dict(result=result)
>
> > > for you request.vars.filename is a cgi.FieldStorage object. It is not
> > > a named file.
> > > It containes
> > > - request.vars.filename.file (a buffered input stream)
> > > - request.vars.filename.filename (the original filename)
> > > For you to access it you should read the stream and save it with a
> > > name. Do not use the original filename to avoid directory traversal
> > > attacks.
>
> > > Massimo
>
> > > On May 7, 2:58 pm, Hans 
> > > wrote:
>
> > > > I'm trying to import some content directly from an excel file which
> > > > the user selects from its local files. I've taken and modified code
> > > > from the admin controller for retrieving the path/filename thru a nice
> > > > file selection window.
>
> > > > The problem: I get only the filename of a locked temporary file, not
> > > > the original filename. If I close the temporary file, to remove the
> > > > lock, the file is automatically deleted...
>
> > > > I would not mind to work with a temporary copy of the original file,
> > > > but retrieving the original path/filename thru a similar file
> > > > selection window would be prefered. How can this be achieved?
>
> > > > Hans
> > > > P.S. I'm using the xlrd module fromhttp://pypi.python.org/pypi/xlrd
>
> > > > ### viewer ###
> > > > {{extend 'layout.html'}}
> > > > excel_read.html template
>
> > > > 
> > > > {{=t2.T('Select File')}}
> > > > {{=FORM('File: ',INPUT(_type='file',_name='filename'),INPUT
> > > > (_type='submit', _value='submit'))}}
> > > > 
>
> > > > 
> > > > {{=BEAUTIFY(response._vars)}}
> > > > 
>
> > > > ### controller ###
> > > > def excel_read():
> > > >     result={}
> > > &

[web2py:21514] Re: append/delete to SQLRow

2009-05-08 Thread Hans

r1 = db(query0).select(db.table.ALL,orderby=something)
r2 = db(query1).select(db.table.ALL,orderby=somethingelse)
my_rows = r1.as_list() + r2.as_list()

h1 = SQLTABLE(r1,headers=headers)  #<< works
h2 = SQLTABLE(r2,headers=headers)  #<< works

h3 = SQLTABLE(my_rows,headers=headers)  #<< does not work

So despite this example above I still can't really append/delete rows
in SQLRow objects.

I'd need that to fill a view table where r1 are detailed records below
of that, but still in the same view table the with .sum() query
calculated totals (=r2) and below of that but still in the same view
table a manually consolidated total from a query of a different table.
Ideally would be if also a blank row/record could be inserted between
the detail records and the total row(s).

How can this be best achieved?

hans

On Apr 26, 4:07 pm, Álvaro Justen [Turicas] 
wrote:
> On Sun, Apr 26, 2009 at 1:02 AM, weheh  wrote:
> > Thanks Álvaro, that looks like it would do the trick. How did you
> > learn this? Did you study the gluon code or did you read about this
> > elsewhere?
>
> I read gluon code, but in this case I only used ipython shell.
> Install ipython and do:
> python web2py.py -S yourapp -M
>
> So you will enter in a more powerful shell. Do:
> myrow = db(db.table.id >= 50).select()
>
> Type "myrow." and press TAB: all "myrow" methods and attributes will be shown.
> If you type "myrow.as_list?" and press ENTER, will you see docstring
> for that method (as_list doesn't have...). If you type
> "myrow.as_list??" and press ENTER, code of "as_list" will be shown. It
> is very useful.
>
> --
>  Álvaro Justen
>  Peta5 - Telecomunicações e Software Livre
>  21 3021-6001 / 9898-0141
>  http://www.peta5.com.br/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21544] Re: Tables (and more) with Google Visualization API (JS)

2009-05-09 Thread Hans

Has anyone managed to implement a editable grid into web2py, something
like http://datatables.net/examples/example_editable.html ?
If so could you share a full (working!) example ?

Hans

On 8 Mai, 14:46, mdipierro  wrote:
> http://www.ajaxline.com/10-best-jquery-plugins-for-working-with-tables
>
> On May 8, 4:08 am, Álvaro Justen [Turicas] 
> wrote:
>
> > Click on table headers to orderby and in a row to select it 
> > (client-side):http://google-visualization.appspot.com/python/static_example
>
> > Project's site:http://code.google.com/p/google-visualization-python/
>
> > --
> >  Álvaro Justen
> >  Peta5 - Telecomunicações e Software Livre
> >  21 3021-6001 / 9898-0141
> >  http://www.peta5.com.br/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21588] Re: Newbie debugger issues with IDLE and web2py.py

2009-05-10 Thread Hans

Wing really rocks! And if you are a open source developer you can get
a free license.

On 9 Mai, 22:32, dlypka  wrote:
> Yes, I intend to purchase Wing, however I still wish to gain some
> experience with the core debuggers.
>
> On May 9, 2:53 pm, Yarko Tymciurak  wrote:
>
> > You could try an eval or even a free version of 
> > Wing:http://www.wingware.com/wingide/features
>
> > On Sat, May 9, 2009 at 12:59 PM, dlypka  wrote:
>
> > > On Windows XP, in folder
>
> > > C:\Google\Web2Py\web2py_win_01_60_2\Source\web2py
>
> > > I created this file "idle.bat":
>
> > >    start C:\Python252\Lib\idlelib\idle.pyw %1 %2 %3 %4 %5 %6 %7 %8 %9
>
> > > -
> > > In the web2py folder I have the usual "applications" folder which
> > > contains the "welcome' app folder.
>
> > > I am trying to learn how to debug an app such as 'welcome' with
> > > breakpoints.
> > > 
>
> > > So I do these 2 commands in a Command Shell:
>
> > > CD \Google\Web2Py\web2py_win_01_60_2\Source\web2py
>
> > > idle web2py.py
>
> > > Then I press F5 to run
>
> > > 
>
> > > The Python 2.5.4 Shell starts up a window ending with an error
> > > message:
>
> > > Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
> > > (Intel)] on win32
> > > Type "copyright", "credits" or "license()" for more information.
>
> > >    
> > >    Personal firewall software may warn about the connection IDLE
> > >    makes to its subprocess using this computer's internal loopback
> > >    interface.  This connection is not visible on any external
> > >    interface and no data is sent to or received from the Internet.
> > >    
>
> > > IDLE 1.2.4
> > > >>>  RESTART
> > > 
>
> > > Traceback (most recent call last):
> > >  File "C:\Google\Web2Py\web2py_win_01_60_2\Source\web2py\web2py.py",
> > > line 7, in 
> > >    path = os.path.dirname(os.path.abspath(__file__))
> > > NameError: name '__file__' is not defined
>
> > > ** How can I resolve this  '__file__' is not defined error?
> > > 
>
> > > ---­--
>
> > > If I just do
> > >   python web2py.py
>
> > > It runs web2py normally, (but I don't see any debugging menus)
> > > I also tried
> > >   python web2py.py -S welcome -M
>
> > > And I got a >>> prompt but it seems to be text mode only.
>
> > > So I am trying to use IDLE, hoping it will give me a more visual
> > > debugger with breakpoints, etc.- Hide quoted text -
>
> > - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21591] Re: Tables (and more) with Google Visualization API (JS)

2009-05-10 Thread Hans

I'd love to get dataTable/JEditable included and working on a web2py
app, especially since it should be easy. Unfortunately I dont know how/
where to start. It would be great if someone of the experts could
explain what steps are required!

On 9 Mai, 21:03, mdipierro  wrote:
> I have used dataTable but I never tried jEditable. Should be easy to
> do.
>
> On May 9, 12:03 pm, Hans 
> wrote:
>
> > Has anyone managed to implement a editable grid into web2py, something
> > likehttp://datatables.net/examples/example_editable.html?
> > If so could you share a full (working!) example ?
>
> > Hans
>
> > On 8 Mai, 14:46, mdipierro  wrote:
>
> > >http://www.ajaxline.com/10-best-jquery-plugins-for-working-with-tables
>
> > > On May 8, 4:08 am, Álvaro Justen [Turicas] 
> > > wrote:
>
> > > > Click on table headers to orderby and in a row to select it 
> > > > (client-side):http://google-visualization.appspot.com/python/static_example
>
> > > > Project's site:http://code.google.com/p/google-visualization-python/
>
> > > > --
> > > >  Álvaro Justen
> > > >  Peta5 - Telecomunicações e Software Livre
> > > >  21 3021-6001 / 9898-0141
> > > >  http://www.peta5.com.br/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21808] Re: selection of local file

2009-05-13 Thread Hans

bumping this one since I still could not fix that. Has anyone managed
to solve this yet?

On May 9, 1:09 am, mdipierro  wrote:
> My bad. This was correct:
>  shutil.copyfileobj(request.vars.filename.file,open(path,'w'))
>
> I am surprised you still get a corrupted file. let me run some tests.
>
> Massimo
>
> On May 8, 5:05 pm, Hans 
> wrote:
>
> > > shutil.copyfileobj(request.vars.filename,open(path,'w'))
>
> > raises exception: (, AttributeError
> > ('read',), )
>
> > tried also
> >    shutil.copyfileobj(request.vars.filename.file,open(path,'w'))
> > which creates a copy, but again a corrupt copy.
>
> > This tests now were done just on windows xp.
>
> > Any other ideas how to solve this?
>
> > Hans
>
> > On May 8, 10:29 pm, mdipierro  wrote:
>
> > > It may be an issue with buffer size. Try
>
> > > import shutil
> > > shutil.copyfileobj(request.vars.filename,open(path,'w'))
>
> > > Massimo
>
> > > On May 8, 2:56 pm, Hans 
> > > wrote:
>
> > > > There is a problem with the following code line
>
> > > > >             open(path,'w').write(request.vars.filename.file.read())
>
> > > > It creates the file 'a_dummy_file_name.xls' but it is not the same
> > > > size as the original file, for example:
> > > > 6790KB original.xls
> > > > 6862KB a_dummy_file_name.xls
>
> > > > If I try to open the dummy file with excel or open office it says the
> > > > file is corrupt.
> > > > I've tried to copy the file manually right after this code line and
> > > > continued execution from there onward...rest works nicely.
>
> > > > I tried on windows and on ubuntu, seems the same problem.
>
> > > > Any idea how to solve that issue with the corrupt file (=getting a
> > > > exact copy) ?
>
> > > > thanks,
> > > > hans
>
> > > > On May 7, 10:56 pm, mdipierro  wrote:
>
> > > > > This should do
>
> > > > >  def excel_read():
> > > > >     result={}
> > > > >     if request.vars.filename != None:
> > > > >         try:
> > > > >             import xlrd
> > > > >             path=os.path.join
> > > > > (request.folder,'private','a_dummy_file_name.xls')
> > > > >             open(path,'w').write(request.vars.filename.file.read())
> > > > >             book = xlrd.open_workbook(path)
> > > > >             result['The number of worksheets is']=book.nsheets
> > > > >             result["Worksheet name(s)"]= book.sheet_names()
> > > > >             sh = book.sheet_by_index(0)
> > > > >             result['sh.name']=sh.name
> > > > >             result['sh.nrows']=sh.nrows
> > > > >             result['sh.ncols']=sh.ncols
> > > > >             result['Cell D30 is']=sh.cell_value(rowx=29, colx=3)
> > > > >             for rx in range(sh.nrows):
> > > > >                 result['row ' + str(rx)]=sh.row(rx)
> > > > >         except:
> > > > >             response.flash = T('excel_read exception')
> > > > >     return dict(result=result)
>
> > > > > for you request.vars.filename is a cgi.FieldStorage object. It is not
> > > > > a named file.
> > > > > It containes
> > > > > - request.vars.filename.file (a buffered input stream)
> > > > > - request.vars.filename.filename (the original filename)
> > > > > For you to access it you should read the stream and save it with a
> > > > > name. Do not use the original filename to avoid directory traversal
> > > > > attacks.
>
> > > > > Massimo
>
> > > > > On May 7, 2:58 pm, Hans 
> > > > > wrote:
>
> > > > > > I'm trying to import some content directly from an excel file which
> > > > > > the user selects from its local files. I've taken and modified code
> > > > > > from the admin controller for retrieving the path/filename thru a 
> > > > > > nice
> > > > > > file selection window.
>
> > > > > > The problem: I get only the filename of a locked temporary file, not
> > > > > > the original file

[web2py:21810] Re: selection of local file

2009-05-13 Thread Hans

web2py 1.61.4
WinXP Pro SP3
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)]

If there is anything I can do to mail it down on my side then let me
know!

Thanks,
Hans

On May 13, 9:40 pm, mdipierro  wrote:
> The problem is not so much to solve it but to reproduce it.
>
> what version of web2py are you running? which os? which python
> version?
>
> Massimo
>
> On May 13, 2:32 pm, Hans 
> wrote:
>
> > bumping this one since I still could not fix that. Has anyone managed
> > to solve this yet?
>
> > On May 9, 1:09 am, mdipierro  wrote:
>
> > > My bad. This was correct:
> > >  shutil.copyfileobj(request.vars.filename.file,open(path,'w'))
>
> > > I am surprised you still get a corrupted file. let me run some tests.
>
> > > Massimo
>
> > > On May 8, 5:05 pm, Hans 
> > > wrote:
>
> > > > > shutil.copyfileobj(request.vars.filename,open(path,'w'))
>
> > > > raises exception: (, AttributeError
> > > > ('read',), )
>
> > > > tried also
> > > >    shutil.copyfileobj(request.vars.filename.file,open(path,'w'))
> > > > which creates a copy, but again a corrupt copy.
>
> > > > This tests now were done just on windows xp.
>
> > > > Any other ideas how to solve this?
>
> > > > Hans
>
> > > > On May 8, 10:29 pm, mdipierro  wrote:
>
> > > > > It may be an issue with buffer size. Try
>
> > > > > import shutil
> > > > > shutil.copyfileobj(request.vars.filename,open(path,'w'))
>
> > > > > Massimo
>
> > > > > On May 8, 2:56 pm, Hans 
> > > > > wrote:
>
> > > > > > There is a problem with the following code line
>
> > > > > > >             
> > > > > > > open(path,'w').write(request.vars.filename.file.read())
>
> > > > > > It creates the file 'a_dummy_file_name.xls' but it is not the same
> > > > > > size as the original file, for example:
> > > > > > 6790KB original.xls
> > > > > > 6862KB a_dummy_file_name.xls
>
> > > > > > If I try to open the dummy file with excel or open office it says 
> > > > > > the
> > > > > > file is corrupt.
> > > > > > I've tried to copy the file manually right after this code line and
> > > > > > continued execution from there onward...rest works nicely.
>
> > > > > > I tried on windows and on ubuntu, seems the same problem.
>
> > > > > > Any idea how to solve that issue with the corrupt file (=getting a
> > > > > > exact copy) ?
>
> > > > > > thanks,
> > > > > > hans
>
> > > > > > On May 7, 10:56 pm, mdipierro  wrote:
>
> > > > > > > This should do
>
> > > > > > >  def excel_read():
> > > > > > >     result={}
> > > > > > >     if request.vars.filename != None:
> > > > > > >         try:
> > > > > > >             import xlrd
> > > > > > >             path=os.path.join
> > > > > > > (request.folder,'private','a_dummy_file_name.xls')
> > > > > > >             
> > > > > > > open(path,'w').write(request.vars.filename.file.read())
> > > > > > >             book = xlrd.open_workbook(path)
> > > > > > >             result['The number of worksheets is']=book.nsheets
> > > > > > >             result["Worksheet name(s)"]= book.sheet_names()
> > > > > > >             sh = book.sheet_by_index(0)
> > > > > > >             result['sh.name']=sh.name
> > > > > > >             result['sh.nrows']=sh.nrows
> > > > > > >             result['sh.ncols']=sh.ncols
> > > > > > >             result['Cell D30 is']=sh.cell_value(rowx=29, colx=3)
> > > > > > >             for rx in range(sh.nrows):
> > > > > > >                 result['row ' + str(rx)]=sh.row(rx)
> > > > > > >         except:
> > > > > > >             response.flash = T('excel_read exception')
> > > > > > >     return dict(result=result)
>
> > > > &

[web2py:22068] Re: selection of local file

2009-05-18 Thread Hans

diff did not help since excel files are considered binary format.
the copies are bigger than the original.xls. I also tried to copy the
copy and the 2nd copy is again bigger in size than the 1st copy.
interesting is that shutil.copyfileobj() and .write(read()) generate
identical files, both corrupt for excel and bigger than the original.

Massimo, I sent you an email with a web2py mini app and small .xls
sample files.
can you reproduce the problem?

thanks,
hans

my test environment:
web2py 1.61.4
WinXP Pro SP3
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)]

On May 13, 10:37 pm, mdipierro  wrote:
> from what I understood something was being removed, not added. Am I
> wrong?
>
> On May 13, 3:24 pm, Kacper Krupa  wrote:
>
> > You should try with smaller files and create diff (to check what is
> > added). It seams to be something between uploading <-> saving.
>
> > On May 13, 9:57 pm, Hans 
> > wrote:
>
> > > web2py 1.61.4
> > > WinXP Pro SP3
> > > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
> > > (Intel)]
>
> > > If there is anything I can do to mail it down on my side then let me
> > > know!
>
> > > Thanks,
> > > Hans
>
> > > On May 13, 9:40 pm, mdipierro  wrote:
>
> > > > The problem is not so much to solve it but to reproduce it.
>
> > > > what version of web2py are you running? which os? which python
> > > > version?
>
> > > > Massimo
>
> > > > On May 13, 2:32 pm, Hans 
> > > > wrote:
>
> > > > > bumping this one since I still could not fix that. Has anyone managed
> > > > > to solve this yet?
>
> > > > > On May 9, 1:09 am, mdipierro  wrote:
>
> > > > > > My bad. This was correct:
> > > > > >  shutil.copyfileobj(request.vars.filename.file,open(path,'w'))
>
> > > > > > I am surprised you still get a corruptedfile. let me run some tests.
>
> > > > > > Massimo
>
> > > > > > On May 8, 5:05 pm, Hans 
> > > > > > wrote:
>
> > > > > > > > shutil.copyfileobj(request.vars.filename,open(path,'w'))
>
> > > > > > > raises exception: (, 
> > > > > > > AttributeError
> > > > > > > ('read',), )
>
> > > > > > > tried also
> > > > > > >    shutil.copyfileobj(request.vars.filename.file,open(path,'w'))
> > > > > > > which creates a copy, but again a corrupt copy.
>
> > > > > > > This tests now were done just on windows xp.
>
> > > > > > > Any other ideas how to solve this?
>
> > > > > > > Hans
>
> > > > > > > On May 8, 10:29 pm, mdipierro  wrote:
>
> > > > > > > > It may be an issue with buffer size. Try
>
> > > > > > > > import shutil
> > > > > > > > shutil.copyfileobj(request.vars.filename,open(path,'w'))
>
> > > > > > > > Massimo
>
> > > > > > > > On May 8, 2:56 pm, Hans 
> > > > > > > > wrote:
>
> > > > > > > > > There is a problem with the following code line
>
> > > > > > > > > >             
> > > > > > > > > > open(path,'w').write(request.vars.filename.file.read())
>
> > > > > > > > > It creates thefile'a_dummy_file_name.xls' but it is not the 
> > > > > > > > > same
> > > > > > > > > size as the originalfile, for example:
> > > > > > > > > 6790KB original.xls
> > > > > > > > > 6862KB a_dummy_file_name.xls
>
> > > > > > > > > If I try to open the dummyfilewith excel or open office it 
> > > > > > > > > says the
> > > > > > > > >fileis corrupt.
> > > > > > > > > I've tried to copy thefilemanually right after this code line 
> > > > > > > > > and
> > > > > > > > > continued execution from there onward...rest works nicely.
>
> > > > > > > > > I tried on windows and on ubuntu, seems the same problem.
>
> > > > > > > > > Any idea how to solve that issue with the 
> > > > > > > > > corruptfile(=getting a
> > 

[web2py:22231] Re: selection of local file

2009-05-20 Thread Hans

that did the trick.
thanks massimo!

note to myself: always append 'b' to the mode of the file open command
to make it work on all platforms (including windows).

On May 20, 6:07 pm, mdipierro  wrote:
> It works for me but I think the problem is that
>
>   shutil.copyfileobj(request.vars.filename.file,open(path,'w'))
>
> should be
>
>   shutil.copyfileobj(request.vars.filename.file,open(path,'wb'))
>
> else when you read it back some of the binary info in the file will be
> messed up.
>
> Massimo
>
> On May 20, 10:18 am, Hans 
> wrote:
>
> > could you reproduce it on your side?
>
> > On May 18, 4:34 pm, mdipierro  wrote:
>
> > > Thank you. I will look into this later today.
>
> > > On May 18, 7:35 am, Hans 
> > > wrote:
>
> > > > diff did not help since excel files are considered binary format.
> > > > the copies are bigger than the original.xls. I also tried to copy the
> > > > copy and the 2nd copy is again bigger in size than the 1st copy.
> > > > interesting is that shutil.copyfileobj() and .write(read()) generate
> > > > identical files, both corrupt for excel and bigger than the original.
>
> > > > Massimo, I sent you an email with a web2py mini app and small .xls
> > > > sample files.
> > > > can you reproduce the problem?
>
> > > > thanks,
> > > > hans
>
> > > > my test environment:
> > > > web2py 1.61.4
> > > > WinXP Pro SP3
> > > > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
> > > > (Intel)]
>
> > > > On May 13, 10:37 pm, mdipierro  wrote:
>
> > > > > from what I understood something was being removed, not added. Am I
> > > > > wrong?
>
> > > > > On May 13, 3:24 pm, Kacper Krupa  wrote:
>
> > > > > > You should try with smaller files and create diff (to check what is
> > > > > > added). It seams to be something between uploading <-> saving.
>
> > > > > > On May 13, 9:57 pm, Hans 
> > > > > > wrote:
>
> > > > > > > web2py 1.61.4
> > > > > > > WinXP Pro SP3
> > > > > > > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 
> > > > > > > bit
> > > > > > > (Intel)]
>
> > > > > > > If there is anything I can do to mail it down on my side then let 
> > > > > > > me
> > > > > > > know!
>
> > > > > > > Thanks,
> > > > > > > Hans
>
> > > > > > > On May 13, 9:40 pm, mdipierro  wrote:
>
> > > > > > > > The problem is not so much to solve it but to reproduce it.
>
> > > > > > > > what version of web2py are you running? which os? which python
> > > > > > > > version?
>
> > > > > > > > Massimo
>
> > > > > > > > On May 13, 2:32 pm, Hans 
> > > > > > > > 
> > > > > > > > wrote:
>
> > > > > > > > > bumping this one since I still could not fix that. Has anyone 
> > > > > > > > > managed
> > > > > > > > > to solve this yet?
>
> > > > > > > > > On May 9, 1:09 am, mdipierro  wrote:
>
> > > > > > > > > > My bad. This was correct:
> > > > > > > > > >  shutil.copyfileobj(request.vars.filename.file,open(path,'w'))
>
> > > > > > > > > > I am surprised you still get a corruptedfile. let me run 
> > > > > > > > > > some tests.
>
> > > > > > > > > > Massimo
>
> > > > > > > > > > On May 8, 5:05 pm, Hans 
> > > > > > > > > > 
> > > > > > > > > > wrote:
>
> > > > > > > > > > > > shutil.copyfileobj(request.vars.filename,open(path,'w'))
>
> > > > > > > > > > > raises exception: (, 
> > > > > > > > > > > AttributeError
> > > > > > > > > > > ('read',), )
>
> > > > > > > > > > > tried also
> > > > > > > > > > >    
> > > > > > > > > > > shutil.copyfileobj(request.vars.filename.file,open(path

[web2py:22220] need help with query/select

2009-05-20 Thread Hans

I need a list of
sales.product, sales.date, continent.name, sales.amount.sum()
with just one summed row per sales.product, sales.date,
continent.name !
basically a sales total per product, day and continent.

something like
Banana  20090520 Europe123
Apple 20090520 Europe234
Apple 20090520 Asia456

db.define_table('sales',
SQLField('product'),
SQLField('date'),
SQLField('country','reference country',requires=IS_IN_DB
(db,'country.id','%(name)s')),
SQLField('amount','integer'))

db.define_table('country',
SQLField('name'),
SQLField('continent','reference continent',requires=IS_IN_DB
(db,'continent.id','%(name)s')))

db.define_table('continent',
SQLField('name'))

how should the web2py query/select look like?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:22228] Re: need help with query/select

2009-05-20 Thread Hans

works nicely!

Thank you Massimo!

On May 20, 6:14 pm, mdipierro  wrote:
> ERRATA: (groupby not orderby, moreover indentation is messed up)
>
> This should do it
>
> rows=db(db.country.id==db.sales.country).select
> (db.sales.product,db.sales.date,db.country.name,db.sales.amount.sum(),
>     groupby=db.sales.product|db.product.date,db.product.country)
> for row in rows:
>     print row.sales.product, row.sales.date,
> row.country.name,row._extra[db.sales.amount.sum()]
>
> BUT 'date' is not a field name in SQL. make it 'date_of_sale' and the
> type of that field should be 'date' not string as the default.
>
> On May 20, 11:12 am, mdipierro  wrote:
>
> > This should do it
>
> > rows=db(db.country.id==db.sales.country).select
> > (db.sales.product,db.sales.date,db.country.name,db.sales.amount.sum
> > (),orderby=db.sales.product|db.product.date,db.product.country)
> > for row in rows:
> >     print row.sales.product, row.sales.date, row.country.name,
> > row._extra[db.sales.amount.sum()]
>
> > BUT 'date' is not a field name in SQL. make it 'date_of_sale' and the
> > type of that field should be 'date' not string as the default.
>
> > Massimo
>
> > On May 20, 10:59 am, Hans 
> > wrote:
>
> > > I need a list of
> > > sales.product, sales.date, continent.name, sales.amount.sum()
> > > with just one summed row per sales.product, sales.date,
> > > continent.name !
> > > basically a sales total per product, day and continent.
>
> > > something like
> > > Banana      20090520 Europe    123
> > > Apple         20090520 Europe    234
> > > Apple         20090520 Asia        456
>
> > > db.define_table('sales',
> > >     SQLField('product'),
> > >     SQLField('date'),
> > >     SQLField('country','reference country',requires=IS_IN_DB
> > > (db,'country.id','%(name)s')),
> > >     SQLField('amount','integer'))
>
> > > db.define_table('country',
> > >     SQLField('name'),
> > >     SQLField('continent','reference continent',requires=IS_IN_DB
> > > (db,'continent.id','%(name)s')))
>
> > > db.define_table('continent',
> > >     SQLField('name'))
>
> > > how should the web2py query/select look like?
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:22219] Re: selection of local file

2009-05-20 Thread Hans

could you reproduce it on your side?

On May 18, 4:34 pm, mdipierro  wrote:
> Thank you. I will look into this later today.
>
> On May 18, 7:35 am, Hans 
> wrote:
>
> > diff did not help since excel files are considered binary format.
> > the copies are bigger than the original.xls. I also tried to copy the
> > copy and the 2nd copy is again bigger in size than the 1st copy.
> > interesting is that shutil.copyfileobj() and .write(read()) generate
> > identical files, both corrupt for excel and bigger than the original.
>
> > Massimo, I sent you an email with a web2py mini app and small .xls
> > sample files.
> > can you reproduce the problem?
>
> > thanks,
> > hans
>
> > my test environment:
> > web2py 1.61.4
> > WinXP Pro SP3
> > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
> > (Intel)]
>
> > On May 13, 10:37 pm, mdipierro  wrote:
>
> > > from what I understood something was being removed, not added. Am I
> > > wrong?
>
> > > On May 13, 3:24 pm, Kacper Krupa  wrote:
>
> > > > You should try with smaller files and create diff (to check what is
> > > > added). It seams to be something between uploading <-> saving.
>
> > > > On May 13, 9:57 pm, Hans 
> > > > wrote:
>
> > > > > web2py 1.61.4
> > > > > WinXP Pro SP3
> > > > > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
> > > > > (Intel)]
>
> > > > > If there is anything I can do to mail it down on my side then let me
> > > > > know!
>
> > > > > Thanks,
> > > > > Hans
>
> > > > > On May 13, 9:40 pm, mdipierro  wrote:
>
> > > > > > The problem is not so much to solve it but to reproduce it.
>
> > > > > > what version of web2py are you running? which os? which python
> > > > > > version?
>
> > > > > > Massimo
>
> > > > > > On May 13, 2:32 pm, Hans 
> > > > > > wrote:
>
> > > > > > > bumping this one since I still could not fix that. Has anyone 
> > > > > > > managed
> > > > > > > to solve this yet?
>
> > > > > > > On May 9, 1:09 am, mdipierro  wrote:
>
> > > > > > > > My bad. This was correct:
> > > > > > > >  shutil.copyfileobj(request.vars.filename.file,open(path,'w'))
>
> > > > > > > > I am surprised you still get a corruptedfile. let me run some 
> > > > > > > > tests.
>
> > > > > > > > Massimo
>
> > > > > > > > On May 8, 5:05 pm, Hans 
> > > > > > > > wrote:
>
> > > > > > > > > > shutil.copyfileobj(request.vars.filename,open(path,'w'))
>
> > > > > > > > > raises exception: (, 
> > > > > > > > > AttributeError
> > > > > > > > > ('read',), )
>
> > > > > > > > > tried also
> > > > > > > > >    
> > > > > > > > > shutil.copyfileobj(request.vars.filename.file,open(path,'w'))
> > > > > > > > > which creates a copy, but again a corrupt copy.
>
> > > > > > > > > This tests now were done just on windows xp.
>
> > > > > > > > > Any other ideas how to solve this?
>
> > > > > > > > > Hans
>
> > > > > > > > > On May 8, 10:29 pm, mdipierro  wrote:
>
> > > > > > > > > > It may be an issue with buffer size. Try
>
> > > > > > > > > > import shutil
> > > > > > > > > > shutil.copyfileobj(request.vars.filename,open(path,'w'))
>
> > > > > > > > > > Massimo
>
> > > > > > > > > > On May 8, 2:56 pm, Hans 
> > > > > > > > > > 
> > > > > > > > > > wrote:
>
> > > > > > > > > > > There is a problem with the following code line
>
> > > > > > > > > > > >             
> > > > > > > > > > > > open(path,'w').write(request.vars.filename.file.read())
>
> > > > > > > > > > > It creates thefile'a_dummy_file_name.xls' but it is not 
&g

[web2py:22618] migrate suggestion for tools.py

2009-05-25 Thread Hans

I'm facing issues when a 'next version' of an application is moved
from one system (like development system) to another one. The unique
string in the begin of the .table files of the auth tables is making
troubles.
I think what happens is that on the new system the app gets a new
unique string, finds that the .table files for the auth table do not
exist with this new string (just the old one) and tries to create the
table -> raising a error because the table already exists.
I usually uninstall the old app version and and then load the new
version with the same name, both via admin web interface.

I attached the following solution which works for me tools.py (based
on 1.62.3). See changes of the 'migrate=True' options.

If that makes sense for others too maybe it can be integrated into one
of the next versions.

...cant attach or upload a file here...sending it to grandmaster
massimo directly ;-)

Hans
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23168] Re: windows service problem in 1.63 (source)

2009-06-02 Thread Hans Donner

see the docstring in gluon.Winservice
it needs the win32 lib, to be installed seperately.

--- Original Message ---
From: mdipierro 
To: web2py Web Framework 
Sent: 03/06/2009, 06:37:07
Subject: [web2py:23165] Re: windows service problem in 1.63 (source)

I have no idea. You may have to help me debug this.

If you start python from the web2py folder, can you do
import gluon.winservice?
If you start python from the gluon folder can you do
import winservice?
Can you edit main and at the bottom insert
print os.getcwd()
When you start web2py as service, what is the output? Is it your
web2py folder?

Massimo

On Jun 2, 10:33 pm, Philip Kilner  wrote:
> Hi Massimo,
>
> mdipierro wrote:
> > running from source or binary?
>
> Source.
>
> --
>
> Regards,
>
> PhilK
>
> 'work as if you lived in the early days of a better nation'
> - alasdair gray




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23263] SQLFORM rendering

2009-06-04 Thread Hans Donner

Currently SQLFORM renders a complete table for the fields provided (or
all) for a db.table, and does some other magic as well.

Would love to reuse the magic, but be in more control of the
rendering. Eg, would like to specify what fields are placed where, and
if they should include labels or not etc.
What fields are to be rendered where should be easiliy done form the template.

(the underlying table is quite big, and when all is listed like it is
now it's too overwhelming. A different layout makes it far more better
(esp when throwing in some ajax), eg having some sort of matrix,
having some labels only for rows and columns vs for every field)

Any suggestions?
I'm digging in the code, and find that the fields and the rendering of
the fields are glued together and not easy to seperate/re-use. Might
be that I'm missing something here.

Would like to do something like:

{{=form.start}}

header 1header 2header 3
{{=form.field['field1'].label{{=form.field['field1']{{=form.field['field2']{{=form.field['field5']


{{=form.field['field3'].label}}: {{=form.field['field3']}}


{{=form.submit}}

{{=form.end}}

where the fields have the currently shown widgets in place without the
need for me to construct these...

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23266] Re: SQLFORM rendering

2009-06-04 Thread Hans Donner

Seems to be it, thanks.

2009/6/4 David Marko :
>
> Do you mean something like this?  http://web2py.com/AlterEgo/default/show/205
>
> David
>
> On 4 čvn, 11:12, Hans Donner  wrote:
>> Currently SQLFORM renders a complete table for the fields provided (or
>> all) for a db.table, and does some other magic as well.
>>
>> Would love to reuse the magic, but be in more control of the
>> rendering. Eg, would like to specify what fields are placed where, and
>> if they should include labels or not etc.
>> What fields are to be rendered where should be easiliy done form the 
>> template.
>>
>> (the underlying table is quite big, and when all is listed like it is
>> now it's too overwhelming. A different layout makes it far more better
>> (esp when throwing in some ajax), eg having some sort of matrix,
>> having some labels only for rows and columns vs for every field)
>>
>> Any suggestions?
>> I'm digging in the code, and find that the fields and the rendering of
>> the fields are glued together and not easy to seperate/re-use. Might
>> be that I'm missing something here.
>>
>> Would like to do something like:
>>
>> {{=form.start}}
>> 
>> header 1header 2header 3
>> {{=form.field['field1'].label{{=form.field['field1']< 
>> td>{{=form.field['field2']{{=form.field['field5']
>> 
>> 
>> {{=form.field['field3'].label}}: {{=form.field['field3']}}
>> 
>> 
>> {{=form.submit}}
>> 
>> {{=form.end}}
>>
>> where the fields have the currently shown widgets in place without the
>> need for me to construct these...
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23281] Re: SQLFORM rendering

2009-06-04 Thread Hans Donner
name] = inp
+
+# if a record is provided and found, as is linkto
+# build a link
 if record and linkto:
 for (rtable, rfield) in table._referenced_by:
 query = urllib.quote(str(table._db[rtable][rfield]
@@ -405,28 +434,47 @@
 continue
 if labels and lname in labels:
 lname = labels[lname]
-xfields.append(TR('', A(lname, _class='reference',
+widget = A(lname, _class='reference',
   _href='%s/%s?query=%s' % (linkto,
-  rtable, query)), col3.get(olname, ''
+  rtable, query))
+xfields.append(TR('', widget, col3.get(olname, ''
   ), _id='%s__row' % olname.replace('.'
   , '__')))
+self.custom.linkto[olname.replace('.', '__')] = widget
+
+# when deletable, add delete? checkbox
+self.custom.deletable = ''
 if record and deletable:
+widget = INPUT(_type='checkbox', _class='delete',
+   _id='delete_record',
+   _name='delete_this_record')
 xfields.append(TR(LABEL(delete_label, _for='delete_record',
-   _id='delete_record__label'),
-   INPUT(_type='checkbox', _class='delete',
-   _id='delete_record',
-   _name='delete_this_record'),
+   _id='delete_record__label'), widget,
col3.get('delete_record', ''),
_id='delete_record__row'))
+self.custom.deletable = widget
+# when writable, add submit button
+self.custom.submit = ''
 if not readonly:
-xfields.append(TR('', INPUT(_type='submit',
-   _value=submit_button),
+widget = INPUT(_type='submit',
+   _value=submit_button)
+xfields.append(TR('', widget,
col3.get('submit_button', ''),
_id='submit_record__row'))
+self.custom.submit = widget
+# if a record is provided and found
+# make sure it's id is stored in the form
 if record:
 if not self['hidden']:
 self['hidden'] = {}
 self['hidden']['id'] = record['id']
+
+form = Storage()
+(form.start, form.close) = self._xml()
+form.start = XML("<%s %s>" % (self.tag, form.start))
+form.close = XML("%s" % (form.close, self.tag))
+self.custom.form = form
+
 self.components = [TABLE(*xfields)]

 def accepts(
@@ -579,7 +627,6 @@
 self.vars.id = self.table.insert(**fields)
 return ret

-
 class SQLTABLE(TABLE):

 """
@@ -673,7 +720,10 @@


 def form_factory(*fields, **attributes):
+"""
+generates a SQLFORM for the given fields.
+
+Internally will build a non-database based data model to hold the fileds.
+"""
 return SQLFORM(SQLDB(None).define_table('no_table', *fields),
**attributes)
-
-


2009/6/4 Hans Donner :
> Seems to be it, thanks.
>
> 2009/6/4 David Marko :
>>
>> Do you mean something like this?  http://web2py.com/AlterEgo/default/show/205
>>
>> David
>>
>> On 4 čvn, 11:12, Hans Donner  wrote:
>>> Currently SQLFORM renders a complete table for the fields provided (or
>>> all) for a db.table, and does some other magic as well.
>>>
>>> Would love to reuse the magic, but be in more control of the
>>> rendering. Eg, would like to specify what fields are placed where, and
>>> if they should include labels or not etc.
>>> What fields are to be rendered where should be easiliy done form the 
>>> template.
>>>
>>> (the underlying table is quite big, and when all is listed like it is
>>> now it's too overwhelming. A different layout makes it far more better
>>> (esp when throwing in some ajax), eg having some sort of matrix,
>>> having some labels only for rows and columns vs for every field)
>>>
>>> Any suggestions?
>>> I'm digging in the code, and find that the fields and the rendering of
>>> the fields 

[web2py:23370] Re: experimental: decimal and pickable and custom columns

2009-06-05 Thread Hans Donner

appreciate that, still learning python so I'm looking forward what I
can learn from your fix.

On Thu, Jun 4, 2009 at 11:16 PM, mdipierro wrote:
>
> I know what to do. I will fix it.
>
> On Jun 4, 3:27 pm, HansD  wrote:
>> not yet sure how to fix this, but fields of this type results in:
>>
>> class=""
>>
>> On 25 mei, 07:17, mdipierro  wrote:
>>
>> > I do not know if this is a good idea and I'd like to hear your
>> > opinions:
>> > I have added in trunk to define custom column types
>>
>> > Here is an example of usage:
>>
>> > import cPickle
>> > from gluon.sql importSQLCustomType
>> > from decimal import Decimal
>>
>> > decimal =SQLCustomType(native='NUMERIC(10,2)',decoder=(lambda x:
>> > Decimal(str(x
>>
>> > pickable =SQLCustomType(type='text',encoder=(lambda x:
>> > "'%s'"%cPickle.dumps(x).replace("'","''")),decoder=(lambda x:
>> > cPickle.loads(x)))
>>
>> > db.define_table('test',
>> >    SQLField('my_decimal',type=decimal),
>> >    SQLField('my_pickle',type=pickable))
>>
>> > theSQLCustomTypeconstructor takes the following arguments:
>> > - type indicates how web2py sqlform should treat this field
>> > - native indicates how the database should treat this field
>> > - encoder indicates how to represent (and escape) a value in SQL
>> > - decoder indicates how to process the value once it is extracted from
>> > the database
>>
>> > It seems to work well with migrations. Of course using native=
>> > makes the custom table not portable across databases.
>>
>> > The implementation is not very clean but can be improved.
>>
>> > Is this a good idea?
>>
>> > Massimo
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23372] Re: SQLFORM rendering

2009-06-05 Thread Hans Donner

the foundation of the expanded example i've provided in my posting
before the patch. feel free to update alterego (works probable even
better, because a second pair of eys/hands might fight some issues or
unclarities. :-)

On Fri, Jun 5, 2009 at 7:56 PM, DenesL wrote:
>
> Nice patch Hans.
> An example expanding AlterEgo 205 would be great too ;-)
>
> DenesL
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23384] Re: SQLFORM rendering

2009-06-05 Thread Hans Donner

yes, master :-)

i noticed there needs to be secuirty code entered
what must this be?

On Fri, Jun 5, 2009 at 8:52 PM, mdipierro wrote:
>
> Can you please update the AlterEgo entry instead?
>
> Massimo
>
> On Jun 5, 1:05 pm, Hans Donner  wrote:
>> the foundation of the expanded example i've provided in my posting
>> before the patch. feel free to update alterego (works probable even
>> better, because a second pair of eys/hands might fight some issues or
>> unclarities. :-)
>>
>> On Fri, Jun 5, 2009 at 7:56 PM, DenesL wrote:
>>
>> > Nice patch Hans.
>> > An example expanding AlterEgo 205 would be great too ;-)
>>
>> > DenesL
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23386] learning python

2009-06-05 Thread Hans Donner

could be my upbringing and my fat fingers/reliance on autocompletion,
but I see a lot of repetitive code and strings, eg
table_field = re.compile('[\w_]+\.[\w_]+') and 'keyname' etc.

like the table_field being present in multiple files, why not move
them to some shared globals and import from there?

any reason why frequently reused keynames are not provided as CONST?
Esp when used in different parts of web2py.
This might also prevent the 'Postgre' (missing s?) in sql.py

I've only been using python for a short time, so this might be the
python way to do it.

Hans

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23391] Re: learning python

2009-06-05 Thread Hans Donner

what is it you do not understand? perhaps I can exaplin it better.

Examples of 'strings'
- in PasswordWidget (sqlhtml.py) there is the default display for a
password, in FORM.accepts this is also re-used
- In the top of sql.py, when loading the drivers 'Postgre' is used as
a key, while later it looks like it is referred to as 'Postgres'

On Fri, Jun 5, 2009 at 10:29 PM, mdipierro wrote:
>
> I do not understand. I am sure it is because of lack of sleep and
> headache due to broken glasses (waiting for a replament).
>
> Massimo
>
> On Jun 5, 3:09 pm, Hans Donner  wrote:
>> could be my upbringing and my fat fingers/reliance on autocompletion,
>> but I see a lot of repetitive code and strings, eg
>> table_field = re.compile('[\w_]+\.[\w_]+') and 'keyname' etc.
>>
>> like the table_field being present in multiple files, why not move
>> them to some shared globals and import from there?
>>
>> any reason why frequently reused keynames are not provided as CONST?
>> Esp when used in different parts of web2py.
>> This might also prevent the 'Postgre' (missing s?) in sql.py
>>
>> I've only been using python for a short time, so this might be the
>> python way to do it.
>>
>> Hans
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23404] Re: learning python

2009-06-05 Thread Hans Donner

Thanks all.
I'm noot looking for a central place to store it all, or for real
inmutable constants.

For the example given:

class PasswordWidget
DEFAULT_DISPLAY = 8('*')
()

would be more than enough and in sql.py there could be things like
DAL.FIELDTYPE_STRING = 'string'

and in cache.py :
DEFAULT_TIMEEXPIRE = 300

the magic values (strings, numbers etc) are thus now a bit more
descriptive (and available for autocompletion if not using the online
environment). I'm not saying that all strings must/should be replaced
as such.



On Sat, Jun 6, 2009 at 6:37 AM, Yarko Tymciurak wrote:
> On Fri, Jun 5, 2009 at 3:46 PM, Hans Donner  wrote:
>>
>> what is it you do not understand? perhaps I can exaplin it better.
>
> Hans -
>
> I get the general idea you are trying to convey ---  for web2conf, we put
> many configuration items into 'CONSTS' (ok, variables that should not be
> changed, except in the config file) ... and we probably went too far.
>
> In general, there's a balance between readability and DRY  (e.g. avoiding
> errors).
>
> For "type" checking, tests return strings in python, and these are generally
> most readable if the tests are against strings too (too much DRY can result
> in obfuscation, readability falling).
>
>>
>> Examples of 'strings'
>> - in PasswordWidget (sqlhtml.py) there is the default display for a
>> password, in FORM.accepts this is also re-used
>
> The string '*'  I would prefer to see as that;  in all of web2py, it
> occurs only in sqlhtml.py, and only 3 times, twice to set, and once to
> test.   I suppose for errors, something like 8*('*')  might be used (matter
> of preference).
>
>>
>> - In the top of sql.py, when loading the drivers 'Postgre' is used as
>> a key, while later it looks like it is referred to as 'Postgres'
>
>
> In all of web2py source,  there is only ONE string starting with
> 'Postg.   and that is (as you point out) probably a typo; as you can
> see, drivers (the list this string is appended to) is a list of drivers
> available in your installation.  It is only used for text display at startup
> of web2py, in widget.py, in start()  for startup dialog  I don't see
> any compelling reason to change this from a string.
>
> But I think your point is well taken - it would be particularly useful for
> readability to assign regular expressions to descriptive names (regardless
> of how many times they are used)...  or even to a concatenation of readable
> chuncks.
>
> So keep looking for places to suggest readability improvements - don't be
> discouraged from your instincts - they are good!
>
> Kind regards,
> Yarko
>>
>>
>> On Fri, Jun 5, 2009 at 10:29 PM, mdipierro wrote:
>> >
>> > I do not understand. I am sure it is because of lack of sleep and
>> > headache due to broken glasses (waiting for a replament).
>> >
>> > Massimo
>> >
>> > On Jun 5, 3:09 pm, Hans Donner  wrote:
>> >> could be my upbringing and my fat fingers/reliance on autocompletion,
>> >> but I see a lot of repetitive code and strings, eg
>> >> table_field = re.compile('[\w_]+\.[\w_]+') and 'keyname' etc.
>> >>
>> >> like the table_field being present in multiple files, why not move
>> >> them to some shared globals and import from there?
>> >>
>> >> any reason why frequently reused keynames are not provided as CONST?
>> >> Esp when used in different parts of web2py.
>> >> This might also prevent the 'Postgre' (missing s?) in sql.py
>> >>
>> >> I've only been using python for a short time, so this might be the
>> >> python way to do it.
>> >>
>> >> Hans
>> > >
>> >
>>
>>
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23453] Re: experimental: decimal and pickable and custom columns

2009-06-06 Thread Hans Donner

consider it fixed.

On Sat, Jun 6, 2009 at 6:07 PM, mdipierro wrote:
>
> I think this is now fixed but I have not tried. Can you please try it?
>
> On Jun 5, 12:49 pm, Hans Donner  wrote:
>> appreciate that, still learning python so I'm looking forward what I
>> can learn from your fix.
>>
>> On Thu, Jun 4, 2009 at 11:16 PM, mdipierro wrote:
>>
>> > I know what to do. I will fix it.
>>
>> > On Jun 4, 3:27 pm, HansD  wrote:
>> >> not yet sure how to fix this, but fields of this type results in:
>>
>> >> class=""
>>
>> >> On 25 mei, 07:17, mdipierro  wrote:
>>
>> >> > I do not know if this is a good idea and I'd like to hear your
>> >> > opinions:
>> >> > I have added in trunk to define custom column types
>>
>> >> > Here is an example of usage:
>>
>> >> > import cPickle
>> >> > from gluon.sql importSQLCustomType
>> >> > from decimal import Decimal
>>
>> >> > decimal =SQLCustomType(native='NUMERIC(10,2)',decoder=(lambda x:
>> >> > Decimal(str(x
>>
>> >> > pickable =SQLCustomType(type='text',encoder=(lambda x:
>> >> > "'%s'"%cPickle.dumps(x).replace("'","''")),decoder=(lambda x:
>> >> > cPickle.loads(x)))
>>
>> >> > db.define_table('test',
>> >> >    SQLField('my_decimal',type=decimal),
>> >> >    SQLField('my_pickle',type=pickable))
>>
>> >> > theSQLCustomTypeconstructor takes the following arguments:
>> >> > - type indicates how web2py sqlform should treat this field
>> >> > - native indicates how the database should treat this field
>> >> > - encoder indicates how to represent (and escape) a value in SQL
>> >> > - decoder indicates how to process the value once it is extracted from
>> >> > the database
>>
>> >> > It seems to work well with migrations. Of course using native=
>> >> > makes the custom table not portable across databases.
>>
>> >> > The implementation is not very clean but can be improved.
>>
>> >> > Is this a good idea?
>>
>> >> > Massimo
>>
>>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23455] Re: Index Error on GAE

2009-06-06 Thread Hans Donner

running locally works fine?
did you check index.yaml?

On Sat, Jun 6, 2009 at 8:41 PM, Tito Garrido wrote:
> Hi Folks,
>
> I've been receiving Index Errors when I try to run my web2py on gae
> application:
>
> 189.115.246.131 - - [06/Jun/2009:11:37:39 -0700] "GET / HTTP/1.1" 500 251
> "http://appengine.google.com/deployment?&app_id=tito-garrido&version_id=1.330233729128519238";
> "Mozilla/5.0 (Windows; U; Windows NT 5.1; pt-BR; rv:1.9.0.10)
> Gecko/2009042316 Firefox/3.0.10,gzip(gfe)"
> "1.latest.tito-garrido.appspot.com"
>
> W 06-06 11:37AM 38.505
>
> no file locking
>
> D 06-06 11:37AM 39.045
>
> no sqlite3 or mysqlite2.dbapi2 driver
>
> D 06-06 11:37AM 39.047
>
> no MySQLdb driver
>
> D 06-06 11:37AM 39.049
>
> no psycopg2 driver
>
> D 06-06 11:37AM 39.051
>
> no cx_Oracle driver
>
> D 06-06 11:37AM 39.054
>
> no MSSQL/DB2 driver
>
> D 06-06 11:37AM 39.058
>
> no kinterbasdb driver
>
> D 06-06 11:37AM 39.062
>
> no informixdb driver
>
> D 06-06 11:37AM 39.065
>
> no zxJDBC driver
>
> W 06-06 11:37AM 39.091
>
> unable to import dbhash
>
> W 06-06 11:37AM 39.181
>
> unable to import wsgiserver
>
> E 06-06 11:37AM 39.420
>
> Traceback (most recent call last):
>   File
> "/base/data/home/apps/tito-garrido/1.334017845210245114/gluon/restricted.py",
> line 107, in restricted
> exec ccode in environment
>
>
>   File
> "/base/data/home/apps/tito-garrido/1.334017845210245114/applications/init/controllers/default.py:index",
> line 144, in 
>   File
> "/base/data/home/apps/tito-garrido/1.334017845210245114/gluon/globals.py",
> line 97, in 
>
>
> self._caller = lambda f: f()
>   File
> "/base/data/home/apps/tito-garrido/1.334017845210245114/applications/init/controllers/default.py:index",
> line 58, in index
>   File
> "/base/data/home/apps/tito-garrido/1.334017845210245114/gluon/contrib/gql.py",
> line 736, in select
>
>
> for item in items:
>   File "/base/python_lib/versions/1/google/appengine/ext/db/__init__.py",
> line 1372, in __iter__
> return self.run()
>   File "/base/python_lib/versions/1/google/appengine/ext/db/__init__.py",
> line 1360, in run
>
>
> iterator = self._get_query().Run()
>   File "/base/python_lib/versions/1/google/appengine/api/datastore.py", line
> 886, in Run
> return self._Run()
>   File "/base/python_lib/versions/1/google/appengine/api/datastore.py", line
> 913, in _Run
>
>
> str(exc) + '\nThis query needs this index:\n' + yaml)
> NeedIndexError: no matching index found.
> This query needs this index:
> - kind: product
>   properties:
>   - name: featured
>   - name: name
>
>
> direction: desc
>
> Anybody has a clue of what should I do to fix it?
>
> Thanks!
>
> Tito
>
> --
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
> Sent from Salvador, BA, Brazil
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23457] Re: web2py perfomance

2009-06-06 Thread Hans Donner

yep,
add requires=IS_NOT_IN_DB(db,db.some_table.field1)
in the SQField() statement as an argument

On Sat, Jun 6, 2009 at 9:17 PM, vihang wrote:
>
> Very interesting mod.
>
> @Massimo, as mentioned about the requires statement, is there a way to
> address the following directly in the field definition?
>
> db.some_table.field1.requires = IS_NOT_IN_DB(db,db.some_table.field1)
>
> On Jun 6, 7:51 pm, mdipierro  wrote:
>> I think it is a great idea.
>> ,
>> Anyway, I would like to remind people the following web2py command
>> line option
>>   -F PROFILER_FILENAME, --profiler=PROFILER_FILENAME
>>                         profiler filename
>>
>> Massimo
>>
>> On Jun 6, 10:17 am, DenesL  wrote:
>>
>>
>>
>>
>>
>> > Very interesting.
>> > How about creating a test case app that people could run to report
>> > performance results on different platforms and CPUs?.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23526] Re: web2py.com down?

2009-06-07 Thread Hans Donner

for me it works fine...

On Sun, Jun 7, 2009 at 10:27 PM, mdipierro wrote:
>
> Now I cannot access web2py.com either. I cannot look into this until
> tomorrow morning.
>
> Massimo
>
> On Jun 7, 3:15 pm, "mr.freeze"  wrote:
>> Yes.
>>
>> On Jun 7, 3:13 pm, mdipierro  wrote:
>>
>> > can you accesswww.cdm.depaul.edu?
>>
>> > On Jun 7, 2:47 pm, "mr.freeze"  wrote:
>>
>> > > Strange...a route trace dies at mfc-cst-bs-v841.netequip.depaul.edu
>> > > [140.192.9.177] for me.
>>
>> > > On Jun 7, 12:11 pm, mdipierro  wrote:
>>
>> > > > works for me. It must be a network problem but outside depaul.
>>
>> > > > On Jun 7, 11:13 am, Tito Garrido  wrote:
>>
>> > > > > I couldn't access jpolite...
>>
>> > > > > On Sun, Jun 7, 2009 at 12:44 PM, mdipierro  
>> > > > > wrote:
>>
>> > > > > > works for me. it is slower than usual but I cannot say if it is a
>> > > > > > network problem or not.
>>
>> > > > > > On Jun 7, 10:32 am, "mr.freeze"  wrote:
>> > > > > > > Anyone else having trouble hitting it? Trying to get my web2py 
>> > > > > > > fix for
>> > > > > > > the day.
>>
>> > > > > --
>>
>> > > > > Linux User #387870
>> > > > > .
>> > > > >  _/_õ|__|
>> > > > > ..º[ .-.___.-._| . . . .
>> > > > > .__( o)__( o).:___
>>
>>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23529] Re: Informal Poll re use of admin interface

2009-06-07 Thread Hans Donner

>> I use Eclipse/Pydev but find the admin interface handy for quick, one-
>> off changes.
> +1
+1

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23613] Re: build automation

2009-06-08 Thread Hans Donner

you might have a look at the current makefile for web2py, there you
can see how the current w2p files are generated.

On Mon, Jun 8, 2009 at 9:21 PM, Sebastian E.
Ovide wrote:
> Hi Massimo,
>
> I was wondering if there is an easy way to compile and package an
> application from command line. The question arise from the need to integrate
> a web2py project in an automated build system. It builds every night, run
> tests, and if there are not errors it deploys in the DEV environment.
>
> thanks
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23754] html.py failed doctest

2009-06-09 Thread Hans Donner

Got:

**
File "html.py", line 841, in __main__.FORM
Failed example:
form.xml()
Expected:
''
Got:
''
**
1 items had failures:
   1 of   2 in __main__.FORM
***Test Failed*** 1 failures.


assume the expected is wrong?
(if yes, I'll provide a patch including some other updates - if no
then you only get the other updates)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23761] Re: html.py failed doctest

2009-06-09 Thread Hans Donner

yep, just did a trunk upgrade

2009/6/9 mdipierro :
>
> BTW,... I am sure I fixed that a few days ago. Can you double check
> you upgraded the tests?
>
> On Jun 9, 1:23 pm, Hans Donner  wrote:
>> Got:
>>
>> **
>> File "html.py", line 841, in __main__.FORM
>> Failed example:
>>     form.xml()
>> Expected:
>>     '> method="post">'
>> Got:
>>     '> method="post">'
>> **
>> 1 items had failures:
>>    1 of   2 in __main__.FORM
>> ***Test Failed*** 1 failures.
>>
>> assume the expected is wrong?
>> (if yes, I'll provide a patch including some other updates - if no
>> then you only get the other updates)
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23763] Re: html.py failed doctest

2009-06-09 Thread Hans Donner

anyway to run all the doctests in one go?


On Tue, Jun 9, 2009 at 8:59 PM, Hans Donner wrote:
> yep, just did a trunk upgrade
>
> 2009/6/9 mdipierro :
>>
>> BTW,... I am sure I fixed that a few days ago. Can you double check
>> you upgraded the tests?
>>
>> On Jun 9, 1:23 pm, Hans Donner  wrote:
>>> Got:
>>>
>>> **
>>> File "html.py", line 841, in __main__.FORM
>>> Failed example:
>>>     form.xml()
>>> Expected:
>>>     '>> method="post">'
>>> Got:
>>>     '>> method="post">'
>>> **
>>> 1 items had failures:
>>>    1 of   2 in __main__.FORM
>>> ***Test Failed*** 1 failures.
>>>
>>> assume the expected is wrong?
>>> (if yes, I'll provide a patch including some other updates - if no
>>> then you only get the other updates)
>> >>
>>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23764] Re: web2py perfomance

2009-06-09 Thread Hans Donner

Alexey,
custom.widget is already in trunk

On Tue, Jun 9, 2009 at 2:14 PM, Alexey Nezhdanov wrote:
> Finally, I started migration (before I was just slapping sql.py, checked out
> of the trunk over my ancient 1.61.4 install).
> Migration is not easy, I've been bending source for my needs so now I have
> to port all this to 1.63.5. Massimo, do you have any objections to this
> patch? I proposed it some time ago, but you were too busy at the time.
> The purpose is - if we want custom forms instead of SQLFORM then we have to
> write our own view.html. But on the other hand - that is double work in the
> regard that we need to write down  name='nnn' /> each time while we already generated all this in controller.
> I'd really like to be able to write in my controller:
> 
> {{=form.custom.label.my_input}}
> {{=form.custom.widget.my_input}}
> 
> See attached patch.
>
> On Tue, Jun 9, 2009 at 3:14 PM, Alexey Nezhdanov  wrote:
>>
>> Forgot about patches. Here they are.
>> 'optimised inits v.2'
>> 'lazy tables' (this one is modified to be applicable to trunk version of
>> sql.py)
>>
>> On Tue, Jun 9, 2009 at 3:10 PM, Alexey Nezhdanov 
>> wrote:
>>>
>>> Results of second set of test runs:
>>>
>>> r875            45.523ms
>>> r882            20.614ms
>>> inits v.1       18.464ms
>>> inits v.2       18.677ms
>>> inits1+lazyT    15.377ms
>>> inits2+lazyT    15.280ms
>>>
>>> Observed noise was 0.502ms for slowest execution (90:1
>>> signal-to-noise) and 0.889ms for fastest execution (16:1
>>> signal-to-noise).
>>> Given than, I think it is safe enough to say that
>>> "this particular application on this particular hardware/OS
>>> combination was sped up 2.88...3.31 times".
>>>
>>> As in last case - for completeness I'm attaching full console output
>>>
>>> I think I know what I'll do. Currently I do not want to release my
>>> project as any kind of open-source. But I can
>>> 1) Strip out any code I do not use in this perfomance testing
>>> 2) rename all sensitive fieldnames/variables to something like field1,
>>> field2, var3, var4.
>>> Release resulting package. It would be useless as it is, but it will
>>> have same perfomance parameters so could be used for testing.
>>>
>>> On Tue, Jun 9, 2009 at 1:35 PM, Alexey Nezhdanov
>>> wrote:
>>> > Wrote 'optimised inits v2' patch. Tested everything.
>>> >
>>> > Once again I changed my testing pattern a bit.
>>> >
>>> > 1) I dumped my own timing tool in favor of much more standard
>>> > 'ab' (apache benchmark).
>>> >
>>> > 2) I decidedly will publish all these results in two main.
>>> > I just finished first round of testing. Here are results (reported
>>> > values are average request time in milliseconds. If anyone interested
>>> > - I'm attaching a full output from my console).
>>> > I will do all that testing again and publish same results again so
>>> > that the amount of noise in all this will be public and clearly
>>> > visible (here I'm fighting with my own temptation to rerun the tests
>>> > if timings seem to be 'too away' to me).
>>> >
>>> > First four lines share my app's db.py. Last two require a modified
>>> > db.py, but modification is cosmetical - each define_table is put into
>>> > separate function and I do db.tablename=create_table_tablename after
>>> > each function. Model init time was not measured.
>>> >
>>> > No more words. Dry figures only. Each line represents result of 10k
>>> > requests.
>>> > r875            46.025ms
>>> > r882            21.048ms
>>> > inits v.1       18.918ms
>>> > inits v.2       18.122ms
>>> > inits1+lazyT    16.032ms
>>> > inits2+lazyT    14.391ms
>>> >
>>> > P.S. I'm surprised about last line... Noise?
>>> >
>>> > On Tue, Jun 9, 2009 at 11:12 AM, Alexey Nezhdanov
>>> > wrote:
>>> >> new testing:
>>> >>
>>> >>  SERVER KERNEL 
>>> >> --prints
>>> >> r875    0.04898
>>> >> r822ini 0.03070 1.60x
>>> >> --silent
>>> >> r875    0.04914
>>> >> r822ini 0.03049 1.61x
>>> >>
>>> >> So I get much more consistent results on this hardware.
>>> >> While this is obviously not the best perfomance (my weaker box,
>>> >> with less RAM, troubled with video output 1280x1024,
>>> >> software 90deg rotation - performs BETTER), that does not matter.
>>> >> What does - is that I can now be sure that these results are
>>> >> noise-free so I can safely compare timings from various patches.
>>> >> Proceeding with writing 'inits v2'.
>>> >>
>>> >>
>>> >> On Tue, Jun 9, 2009 at 10:43 AM, Alexey Nezhdanov
>>> >> wrote:
>>> >>> Ok. Now the confusion is resolved.
>>> >>> 1) Speed improvements of 70% and up that I reported yesterday are
>>> >>> really exist. I just reproduced a 3.47 times model speedup and 2.15
>>> >>> overall speedup for my app (r875 vs r822+inits).
>>> >>> BUT this app is atypical. I have added some time measuring code there
>>> >>> so it prints out two lines per each model init. So when I am testing
>>> >>> perfomance - screen very quickly scrolls up
>>> >>>
>>> >>> 2) Simply commenting out two print statements gives me only 1.67
>>

[web2py:23767] Re: Custom Display Values

2009-06-09 Thread Hans Donner

Gary,
how dows your model look like?
And how does it show when you are just using SQLFORM?

On Tue, Jun 9, 2009 at 9:40 PM, Gary wrote:
>
> Thank you Fran and Massimo for the info.
>
> I downloaded the trunk using:
>
> bzr branch lp:~mdipierro/web2py/devel web2py-devel
>
> and installed the application.  The error message went away, but
> {{=form.custom.widget.town_id}} still displayed '1' vs. the 'lookup'
> value.  It also didn't display a checkbox where indicated.
>
> Appreciate the help.
>
>
>
> On Jun 9, 2:24 pm, mdipierro  wrote:
>> By trunk we mean "not officially released yet" and "not guaranteed to
>> work".
>>
>> Massimo
>>
>> On Jun 9, 12:41 pm, Gary  wrote:
>>
>> > I tried {{=form.custom.widget.town_id}} in 1.63.5 and got an error
>> > "AttributeError: 'NoneType' object has no attribute 'town_id'".
>> > Using {{=form.custom.inpval.town_id}} returns a '1', the value of the
>> > id in the 'Location' file pointing to the 'Town' file.
>>
>> > For clarification, does 'new trunk' mean something other than the
>> > current release?
>>
>> > Thanks.
>>
>> > On Jun 9, 12:38 pm, mdipierro  wrote:
>>
>> > > with the new trunk you can do
>>
>> > > {{=form.custom.widget.fieldname}}
>>
>> > > On Jun 9, 11:06 am, Gary  wrote:
>>
>> > > > I'm using crud to interact with a custom view.
>> > > > form.custom.inpval.fieldname and form.custom.dspval.fieldname display
>> > > > the proper value for most field types, but not files, select boxes and
>> > > > checkboxes.  The download easily fixes the file display, but I've been
>> > > > unable to find a similar solution to displaying the 'lookup' value of
>> > > > the select rather than the 'id' of the target?  Ditto for the checkbox
>> > > > rather that 'True/False'.
>>
>> > > > Thanks in advance for any help.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23769] Re: table/sqltable helper post-production

2009-06-09 Thread Hans Donner

3) provide a patch, so it might end up in SQLTABLE ?

On Tue, Jun 9, 2009 at 6:57 PM, mdipierro wrote:
>
> There is no may to make a SQLTABLE taht fits everybody's taste and
> needs. I think you should
>
> 1) define your own SQLTABLE2, or
> 2) loop over rows explicitly
>
> Massimo
>
> On Jun 9, 11:50 am, AchipA  wrote:
>> Just been through some TABLE() and SQLTABLE() work and could not find
>> a way (I was satisfied with) to change output results of particular
>> columns. For example, I have an sql column that is a color code and
>> I'd like to put in a css element with that color. The hard way is
>> obviously foregoing the {{=table}} and looping through all the
>> components, changing the ones you need, but this produces mighty ugly
>> views. Is there a more intelligent/recommended way of doing this ?
>>
>> If not, I'd like to suggest something like a per-column map function,
>> similar to what we have for upload columns now. For example
>>
>> SQLTABLE(result=result, map={'colorcol': mycolorfunc, 'linkcol' :
>> lambda x: A(_href=x), 'bigfloatcol' : lambda x: "%.2f" % x} )
>>
>> The same could work for TABLE() if they have a header row to identify
>> columns.
>> This could be also useful for views, too, imagine:
>>
>> {{table.map['badlyformattedcol'] = goodformatfunc}}
>> {{=table}}
>>
>> Comments, suggestions, recommendations ?
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23805] Re: response.flash upgrade

2009-06-09 Thread Hans Donner

Maybe somebody can make an example page displaying the various pickers
out there with some descriptions etc.

On Wed, Jun 10, 2009 at 2:27 AM, DenesL wrote:
>
> OK, but I am not the only one overlooking features ;-)
>
> There is a new version of www.dynarch.com/projects/calendar/
> with a demo at www.dynarch.com/static/JSCal2/index.html
>
> It can even select multiple dates, something the other one can't do.
>
> Anyway, I agree with Massimo on minimizing the JS load,
> you can always add plugins as you need them.
>
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23816] Re: getHelperById ?

2009-06-10 Thread Hans Donner

Not quite, but has the same effect (hence the copy)

for every component processed, it 'adds' the child components to the
end of the processing que.
So it searches layer by layer

On Wed, Jun 10, 2009 at 10:29 AM, AchipA wrote:
>
> @massimo: thanks for the clarification, I just remember seeing
> copy.copy-s there which mislead me. But does it work recursively ?
>
> @johnmc: I'm talking about server-side helpers, not browser-side html
> elements
>
> On Jun 10, 3:21 am, JohnMc  wrote:
>> If form --
>>
>> $('form').find('#whatever')
>>
>> works as well, though slower
>>
>> On Jun 9, 5:48 pm, mdipierro  wrote:
>>
>> > it returns the actual helper, not a copy.
>>
>> > On Jun 9, 4:41 pm, AchipA  wrote:
>>
>> > > Err... I was under the impression div.element only works on direct
>> > > child nodes and even there it returns just a copy on the helper (not
>> > > the reference to the actual one). Been quite a while since I looked in
>> > > html.py, so I might be wrong, though...
>>
>> > > On Jun 9, 10:33 pm, mdipierro  wrote:
>>
>> > > > It is there already:
>>
>> > > > form.element(_id='something')['_class']='red'
>>
>> > > > On Jun 9, 2:58 pm, AchipA  wrote:
>>
>> > > > > Another idea while I wait for some of my computations to finish.
>> > > > > Javascript can access HTML elements in different ways. With web2py
>> > > > > helpers, this can get a bit cumbersome. How about a generic
>> > > > > getHelperById method for the base helper class so it goes through 
>> > > > > it's
>> > > > > components and fetches the helper with the required id, saving us
>> > > > > plenty of for cycles/recursion and introspection ? It might 
>> > > > > especially
>> > > > > be useful adressing stuff like FORMs (like getting a particular INPUT
>> > > > > element which might be embedded into layers and layers of helpers
>> > > > > inside that FORM).
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23867] Re: Custom Display Values

2009-06-10 Thread Hans Donner

> You only need widgets
>
> 
> {{=form.custom.widget.field1}}
> {{=form.custom.widget.field2}}
> {{=form.custom.widget.field3}}
> 
> {{=form.hidden_fields()}}
> 

better is to use {{=form.start}} in stead of , this will take
over any actions/methods etc that are used in the SQLFORM,
and for now {{=form.close}} and  are the same unless I can
figure out how to include the {{=form.hidden_fields()}} properly in
{{=form.close}}

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23871] Re: Custom Display Values

2009-06-10 Thread Hans Donner

Nice,

> 

can be done with
{{=form.custom.submit}}

and if you want to add the delete? checkbox
{{=form.custom.deletable}}

On Thu, Jun 11, 2009 at 7:12 AM, mdipierro wrote:
>
> done but it is now
>
> {{=form.custom.form.begin}}
> {{=form.custom.widget.field1}}
> {{=form.custom.widget.field2}}
> {{=form.custom.widget.field3}}
> 
> {{=form.custom.form.end}} includes hidden fields!
>
> Massimo
>
> On Jun 10, 11:27 pm, Hans Donner  wrote:
>> > You only need widgets
>>
>> > 
>> > {{=form.custom.widget.field1}}
>> > {{=form.custom.widget.field2}}
>> > {{=form.custom.widget.field3}}
>> > 
>> > {{=form.hidden_fields()}}
>> > 
>>
>> better is to use {{=form.start}} in stead of , this will take
>> over any actions/methods etc that are used in the SQLFORM,
>> and for now {{=form.close}} and  are the same unless I can
>> figure out how to include the {{=form.hidden_fields()}} properly in
>> {{=form.close}}
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23928] Re: web2py 1.64.0 posted

2009-06-11 Thread Hans Donner

Error codes are from our performance man!

On Thu, Jun 11, 2009 at 5:27 PM, mdipierro wrote:
>
> Please check it out!
>
> - Models are much faster ~ 2.5x times (thanks Alexey)
> - fully works on Jython without tweaks (sqlite and postgresql with
> zxjdbc)
> - custom forms and better error codes (thanks Hans)
> - better LDAP support (thanks Fran and Mr. Freeze)
>
> Massimo
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24032] aplliances in a version control system

2009-06-12 Thread Hans Donner

Hi,

is the sourcecode for the web2py.com/appliances also available in a
verison control system like web2py itself?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24071] readonly fields dont validate on form level

2009-06-13 Thread Hans Donner

db.define_table(
'test',
SQLField('unique', 'string', unique = True,
requires = IS_NOT_IN_DB(db, 'test.unique')),
)


def pseudo():
   db.table.field.writable = False
   db.table.field = 'some invalid value for the requires[]'
   form = crud.create(db.table)

the form doesn't run the validators for the non-writable field, and
when you are on GAE the uniqueness is not enforced on db level (and
DAL does not make up for this).

When I have the following:
def pseudo():
   db.table.field = 'some invalid value for the requires[]'
   form = crud.create(db.table)
   form.custom.widget.jaar.update(**dict(_disabled = True))

the value is non-editable by the user, it is validated but the value is removed

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24076] Re: readonly fields dont validate on form level

2009-06-13 Thread Hans Donner

sorry, should be db.table.field.default = ''

On Sat, Jun 13, 2009 at 3:54 PM, mdipierro wrote:
>
> I am not what you mean by:
>
> db.table.field = 'some invalid value for the requires[]'
>
> It seems to be redefining the field. It should give an error.
>
> On Jun 13, 8:28 am, Hans Donner  wrote:
>> db.define_table(
>>     'test',
>>     SQLField('unique', 'string', unique = True,
>>         requires = IS_NOT_IN_DB(db, 'test.unique')),
>>     )
>>
>> def pseudo():
>>    db.table.field.writable = False
>>    db.table.field = 'some invalid value for the requires[]'
>>    form = crud.create(db.table)
>>
>> the form doesn't run the validators for the non-writable field, and
>> when you are on GAE the uniqueness is not enforced on db level (and
>> DAL does not make up for this).
>>
>> When I have the following:
>> def pseudo():
>>    db.table.field = 'some invalid value for the requires[]'
>>    form = crud.create(db.table)
>>    form.custom.widget.jaar.update(**dict(_disabled = True))
>>
>> the value is non-editable by the user, it is validated but the value is 
>> removed
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24088] Re: readonly fields dont validate on form level

2009-06-13 Thread Hans Donner

Well, depends what you call 'inserted by the visitor'. In this case
I'm prepopulating the form, some fields are not editable, but the user
should submit these values as well.
Guess I have to use onvalidate then to make sure all is ok.

The second remark in my original posting: the 'unique' should somehow
be supported by DAL, or warnings should be submitted that it is
unsupported.

On Sat, Jun 13, 2009 at 4:39 PM, mdipierro wrote:
>
> back to the original question. Should they validate? If they are
> readonly it means they are not inserted by the visitor. We only
> validate visitor provided input.
>
> Massimo
>
> On Jun 13, 9:02 am, Hans Donner  wrote:
>> sorry, should be db.table.field.default = ''
>>
>> On Sat, Jun 13, 2009 at 3:54 PM, mdipierro wrote:
>>
>> > I am not what you mean by:
>>
>> > db.table.field = 'some invalid value for the requires[]'
>>
>> > It seems to be redefining the field. It should give an error.
>>
>> > On Jun 13, 8:28 am, Hans Donner  wrote:
>> >> db.define_table(
>> >>     'test',
>> >>     SQLField('unique', 'string', unique = True,
>> >>         requires = IS_NOT_IN_DB(db, 'test.unique')),
>> >>     )
>>
>> >> def pseudo():
>> >>    db.table.field.writable = False
>> >>    db.table.field = 'some invalid value for the requires[]'
>> >>    form = crud.create(db.table)
>>
>> >> the form doesn't run the validators for the non-writable field, and
>> >> when you are on GAE the uniqueness is not enforced on db level (and
>> >> DAL does not make up for this).
>>
>> >> When I have the following:
>> >> def pseudo():
>> >>    db.table.field = 'some invalid value for the requires[]'
>> >>    form = crud.create(db.table)
>> >>    form.custom.widget.jaar.update(**dict(_disabled = True))
>>
>> >> the value is non-editable by the user, it is validated but the value is 
>> >> removed
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24096] Re: How to modify SQLRows

2009-06-13 Thread Hans Donner

def as_list(self,
compact=True,
storage_to_dict=True,
datetime_to_str=True):

so you can prevent the conversion by providing the datetime_to_str = False

On Sat, Jun 13, 2009 at 5:57 PM, weheh wrote:
>
> Massimo, this is great and it works. Thank you. However, caveat emptor
> to others who follow this thread. The as_list() function turns
> datetime fields into strings, so you may have to convert them back to
> datetimes. It feels a little kludgey, but it does work.
>
> On Jun 12, 11:42 pm, mdipierro  wrote:
>> No it does not work.
>>
>> You have to do:
>>
>> x=x.as_list()
>> for y in x:
>>     y['field']='value'
>>
>> You cannot modify records in a SQLRows object because they are
>> computed when requested. This will change in the new DAL.
>>
>> Massimo
>>
>> On Jun 12, 10:30 pm, weheh  wrote:
>>
>>
>>
>> > DenesL: I tried exactly that, but somehow, it didn't seem to work.
>> > I'll try again. Thanks for your response!
>>
>> > On Jun 12, 4:54 pm, DenesL  wrote:
>>
>> > > y['field1'] = 'new name'- Hide quoted text -
>>
>> - Show quoted text -
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



  1   2   3   >