[web2py] Nice web plugin, like jQZoom

2010-05-26 Thread KMax
http://www.professorcloud.com/mainsite/cloud-zoom.htm

Looks great.


[web2py] FORM with CHEKCBOX and IS_IN_DB

2010-07-26 Thread KMax
Hello
I had table defined:
db.define_table('papers',
Field('printdate','date'),
Field('printout','boolean',default=False))

So I need FORM with checkboxes for each printdate, but if printout for
particular date gets 'True' (mean to app user 'CLOSED FOR ACCEPT NEW
POST' ) error message printed.

def test2():
chkposts=[]
posts=db(db.papers.id > 0).select()
for pst in posts:
 
chkposts.append(DIV(INPUT(_type='checkbox',_name='pst_'+str(pst.id),requires=IS_IN_DB(db((db.papers.id
==MY_QUESTION  )&(db.papers.printout == False)),'papers.id','%
(name)s',error_message=T('CLOSED FOR ACCEPT NEW
POST'))),str(pst.printdate)))
chkposts.append(INPUT(_type='submit',_value='SUBMIT'))
form=FORM(*[chkposts[num] for num in
range(len(chkposts))],_name="adcr")
if form.accepts(request.vars, session):
response.flash = 'form accepted'
return dict(form=form)

What should I put instead MY_QUESTION to IS_IN_DB get work? I want
alert on checkbox who corresponding to records with
db.papers.printout==True
But checkbox return "on" value and I need name of checked checkbox
modifyed by .split('_')[-1] -ed

Please advise.

Thank you.
--
Maxim


[web2py] Re: FORM with CHEKCBOX and IS_IN_DB

2010-07-27 Thread KMax
Thank you for promt responce,
Sorry for my dumpness, and possible quite barbarism, but
how it should work?
requires=condition and writable=condition give error NameError: global
name 'condition' is not defined
Where is writable(id) called? and what for it?
condition = not posts.find(lambda r: r.id==id).printout give error
AttributeError: 'Rows' object has no attribute 'printout'
So main idea is use self_made validator?

On 27 июл, 14:06, mdipierro  wrote:
> Try this:
>
> def test2():
>     posts=db(db.papers.id > 0).select()
>     def writable(id):
>          condition = not posts.find(lambda r: r.id==id).printout
>     chkposts=[Field('pst_
> %s'%pst.id,requires=condition,label=pst.printdate, writable=condition)
> for pst in posts]
>     form=SQLFORM.factory(*chkposts)
>     if form.accepts(request.vars, session):
>         response.flash = 'form accepted'
>     return dict(form=form)


On 27 июл, 07:06, mdipierro  wrote:
> Try this:
>
> def test2():
>     posts=db(db.papers.id > 0).select()
>     def writable(id):
>          condition = not posts.find(lambda r: r.id==id).printout
>     chkposts=[Field('pst_
> %s'%pst.id,requires=condition,label=pst.printdate, writable=condition)
> for pst in posts]
>     form=SQLFORM.factory(*chkposts)
>     if form.accepts(request.vars, session):
>         response.flash = 'form accepted'
>     return dict(form=form)
>
> On Jul 26, 1:09 pm, KMax  wrote:
>
> > Hello
> > I had table defined:
> > db.define_table('papers',
> >     Field('printdate','date'),
> >     Field('printout','boolean',default=False))
>
> > So I need FORM with checkboxes for each printdate, but if printout for
> > particular date gets 'True' (mean to app user 'CLOSED FOR ACCEPT NEW
> > POST' ) error message printed.
>
> > def test2():
> >     chkposts=[]
> >     posts=db(db.papers.id > 0).select()
> >     for pst in posts:
>
> > chkposts.append(DIV(INPUT(_type='checkbox',_name='pst_'+str(pst.id),requires=IS_IN_DB(db((db.papers.id
> > ==MY_QUESTION  )&(db.papers.printout == False)),'papers.id','%
> > (name)s',error_message=T('CLOSED FOR ACCEPT NEW
> > POST'))),str(pst.printdate)))
> >     chkposts.append(INPUT(_type='submit',_value='SUBMIT'))
> >     form=FORM(*[chkposts[num] for num in
> > range(len(chkposts))],_name="adcr")
> >     if form.accepts(request.vars, session):
> >         response.flash = 'form accepted'
> >     return dict(form=form)
>
> > What should I put instead MY_QUESTION to IS_IN_DB get work? I want
> > alert on checkbox who corresponding to records with
> > db.papers.printout==True
> > But checkbox return "on" value and I need name of checked checkbox
> > modifyed by .split('_')[-1] -ed
>
> > Please advise.
>
> > Thank you.
> > --
> > Maxim


[web2py] Re: FORM with CHEKCBOX and IS_IN_DB

2010-07-27 Thread KMax
I just solve this by using

db.define_table('papers',
Field('printdate','date'),
Field('printout','boolean',default=False),
Field('oncheck','string',default='on')) # this field for checkbox
value = 'on'

def test1():
chkposts=[]
posts=db(db.papers.id > 0).select()
for pst in posts:
 
chkposts.append(DIV(INPUT(_type='checkbox',_name='pst_'+str(pst.id),requires=IS_NULL_OR(IS_IN_DB(db((db.papers.id
== pst.id ) & (db.papers.printout ==
False)),'papers.oncheck','',error_message=T('ALERT',str(pst.printdate)))
# IS_NULL_OR for unchecked field which are not need to be
validated.
chkposts.append(INPUT(_type='submit',_value='SUBMIT'))
form=FORM(*[chkposts[num] for num in
range(len(chkposts))],_name="adcr")
if form.accepts(request.vars, session):
response.flash = 'form accepted'
return dict(form=form)

Thanks
issue resolve (not quite pure solution, but i am satisfied)


[web2py] Re: multiple checkboxes

2010-07-27 Thread KMax
> But after 
> reading:http://groups.google.com/group/web2py/browse_thread/thread/401b4c1928...,
> I don't think sqlform.factory is able to do what I want it to do.  I
> want to basically display ALL rows of a table given this database so
Actualy FORM(and sqlform.factory i guess) could do any form with any
date, but pesponce should be processed manualy.
Good side of using FORM is native web2py validators for any type form
input.
Thanks.


[web2py] performance issue select().first()

2010-08-02 Thread KMax
Hello
 I have situation when .select() give lots of rows select().first()
start consume lots of cpu.
 I work around this by changing  query to minimize answer of select().
 LOGGING = True gives this in profile.log
   ncalls  tottime  percall  cumtime  percall
filename:lineno(function)
32.1100.7035.3971.799 sql.py:3146(parse)


 I guess something could be done to avoid workaround by sql-query,
sorry if i am lame :)
Thank you.


[web2py] Re: performance issue select().first()

2010-08-02 Thread KMax
Thank you.

Some code with .first() for newbies

nextpaper_id=db(db.papers.id >
paper_id).select(limitby=(0,1),orderby=db.papers.id).first().id
prevpaper_id=db(db.papers.id <
paper_id).select(limitby=(0,1),orderby=~db.papers.id).last().id

I guess .first=.last while limitby=(0,1)

On 2 авг, 17:37, mdipierro  wrote:
> use
>
> select(limitby=(0,1)).first()
>
> On Aug 2, 4:22 am, KMax  wrote:
>
>
>
> > Hello
> >  I have situation when .select() give lots of rows select().first()
> > start consume lots of cpu.
> >  I work around this by changing  query to minimize answer of select().
> >  LOGGING = True gives this in profile.log
> >    ncalls  tottime  percall  cumtime  percall
> > filename:lineno(function)
> >         3    2.110    0.703    5.397    1.799 sql.py:3146(parse)
>
> >  I guess something could be done to avoid workaround by sql-query,
> > sorry if i am lame :)
> > Thank you.


[web2py] IS_IN_DB issue in FORM data

2010-08-11 Thread KMax
Hello
I have following cut of code:
db.define_table('papers',
Field('printdate','date'),
Field('printout','boolean',default=False),
Field('globnum','integer'),
Field('locnum','integer'),
 
Field('oncheck','string',default='on',readable=False,writable=False))
conntroller
posts = db(db.papers.printout ==
False).select(limitby=(0,16),orderby=db.papers.id)
for pst in posts:
 
chkposts.append(TD(INPUT(_type='checkbox',_name='pst_'+str(pst.id),
requires=IS_NULL_OR(IS_IN_DB(db(db.papers.id ==
pst.id ),'papers.oncheck','',error_message=T('CLOSED FOR
ACCEPT!'))),value=paperprint),str(pst.printdate.strftime("%d/%m/
%y"

So, if db.papers.printout gets False this entry disappeared from FORM,
so validator IS_IN_DB even does not get used and checkbox value
accepted.
Is there the way to save 'posts' for the first time FORM loaded. And
then only saved result use for 'for pst in posts:'
Thank you.


[web2py] Re: IS_IN_DB issue in FORM data

2010-08-11 Thread KMax
According to http://web2py.com/book/default/docstring/cache

Ram based caching

This is implemented as global (per process, shared by all threads)
dictionary. A mutex-lock mechanism avoid conflicts.
As long as it shared by threads and not process, it look like roulete
with chance of 1/processes.

Is it possible to save 'posts.id' array in session or something?
In this case i could update it on GET and use saved on POST

Thank you.

On 11 авг, 20:12, mdipierro  wrote:
> posts = db(db.papers.printout ==
> False).select(limitby=(0,16),orderby=db.papers.id,cache=(cache.ram,None))
>
> and
>
> posts = db(db.papers.printout ==
> False).select(limitby=(0,16),orderby=db.papers.id,cache=(cache.ram,0))
>
> to force a refresh
>
> On Aug 11, 2:00 am, KMax  wrote:
>
>
>
> > Hello
> > I have following cut of code:
> > db.define_table('papers',
> >     Field('printdate','date'),
> >     Field('printout','boolean',default=False),
> >     Field('globnum','integer'),
> >     Field('locnum','integer'),
>
> > Field('oncheck','string',default='on',readable=False,writable=False))
> > conntroller
> >     posts = db(db.papers.printout ==
> > False).select(limitby=(0,16),orderby=db.papers.id)
> >     for pst in posts:
>
> > chkposts.append(TD(INPUT(_type='checkbox',_name='pst_'+str(pst.id),
> >             requires=IS_NULL_OR(IS_IN_DB(db(db.papers.id ==
> > pst.id ),'papers.oncheck','',error_message=T('CLOSED FOR
> > ACCEPT!'))),value=paperprint),str(pst.printdate.strftime("%d/%m/
> > %y"
>
> > So, if db.papers.printout gets False this entry disappeared from FORM,
> > so validator IS_IN_DB even does not get used and checkbox value
> > accepted.
> > Is there the way to save 'posts' for the first time FORM loaded. And
> > then only saved result use for 'for pst in posts:'
> > Thank you.


[web2py] Re: IS_IN_DB issue in FORM data

2010-08-11 Thread KMax
Look like this should help.
http://web2py.com/book/default/chapter/04?search=session#session

Thank you.


[web2py] Re: IS_IN_DB issue in FORM data

2010-08-11 Thread KMax
As second thought, Pickle and put as hidden post element, this should
prevent from overwrite session in case few forms opened in tabs.

On 11 авг, 22:00, KMax  wrote:
> Look like this should 
> help.http://web2py.com/book/default/chapter/04?search=session#session
>
> Thank you.


[web2py] Re: Typo in cron..

2010-02-10 Thread KMax
Please note:
gluon/contrib/cron.py has
self.cronmaster = crondance(self.path, 'soft', starup = True)
but should be (I guess)
self.cronmaster = crondance(self.path, 'soft', startup = True)

Thanks
On Feb 7, 12:57 am, Thadeus Burgess  wrote:
> How do these make it into the commit ?
>
> Also, why is softcron executing when running on mod_wsgi ?
>
> Traceback (most recent call last):
> [Sat Feb 06 18:54:13 2010] [error] [client]   File
> "gluon/contrib/wsgihooks.py", line 37, in close
> [Sat Feb 06 18:54:13 2010] [error] [client]     
> self.__callback(self.__environ)
> [Sat Feb 06 18:54:13 2010] [error] [client]   File
> "gluon/contrib/wsgihooks.py", line 91, in callback
> [Sat Feb 06 18:54:13 2010] [error] [client]     scron =
> gluon.contrib.cron.softcron(env)
> [Sat Feb 06 18:54:13 2010] [error] [client]   File
> "gluon/contrib/cron.py", line 65, in __init__
> [Sat Feb 06 18:54:13 2010] [error] [client]    
> self.cronmaster=crondance(self.path, 'soft', starup =True)
> [Sat Feb 06 18:54:13 2010] [error] [client] TypeError:crondance() got
> an unexpected keyword argument 'starup'
>
> -Thadeus

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: How much memory does web2py need on Unix

2010-02-11 Thread KMax
Look like OpenVZ container. I play with this a lot.
First of all memory size, not always limits your need.
64M - to low. Hardly to run static serve apache. (moderate load).
VZ container also has limits for (sample from my server)
   100:  kmemsize23782914102256 2147483647
2147483647  0
lockedpages   0  0256
256  0
privvmpages   21128 102598 131072
131072  0
shmpages 16   1024  21504
21504  0
dummy 0  0  0
0  0
numproc  23 40240
240  0
physpages  1743  53890  0
2147483647  0
vmguarpages   0  0  65536
65536  0
oomguarpages   5184  54115  26112
2147483647  0
numtcpsock6 73  1
1  0
numflock  1  3188
206  0
numpty0  1 16
16  0
numsiginfo0 10256
256  0
tcpsndbuf 5376025894402589488
3589488272
tcprcvbuf 9830425972482589488
3589488   6505
othersockbuf   8960  375042589488
3589488  0
dgramrcvbuf   0  12160 262144
262144  0
numothersock 22 36  1
1  0
dcachesize89250 1307253409920
3624960  0
numfile 663996   9312
9312  0
numiptent14 14128
128  0
=
Last columns show how many times, processes in vz were limited by
corresponding resource.
Since this my out server with my own container, I try to set maximum,
but even this high sometimes not enough.

So I am not recommend use business critical application in vz for this
reason. Or try to get more resources.

On 11 фев, 09:06, raven  wrote:
> Here are the details of memory usage when web2py is NOT running
>
> top - 21:58:38 up 11:57,  2 users,  load average: 0.00, 0.00, 0.00
> Tasks:  10 total,   1 running,   9 sleeping,   0 stopped,   0 zombie
> Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,
> 0.0%si,  0.0%st
> Mem:     65536k total,    13320k used,    52216k free,        0k
> buffers
> Swap:        0k total,        0k used,        0k free,        0k
> cached

> > > > On Wed, Feb 10, 2010 at 9:40 AM, raven  wrote:
> > > > > web2py is working very well for me on my MSWINDOWS desktop.
>
> > > > > I am ready to deploy my first application on a virtual private server
> > > > > running Ubuntu with 64K of guaranteed RAM
>
> > > > > I loaded the web2py source and typed
>
> > > > > python2.5 web2py.py
>
> > > > > and immediatly ran out of memory.
This often happens when process try to allocate memory with margin.
I had cases when something allocate 4G on machine with 1G ram.
And it works because, linux has ability to promise this allocation in
future.
In vz container this case would lead to killed or hang app.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: Alert when email not sent sucessfully !

2010-02-12 Thread KMax
I could sudjest to use mail-hooks in two ways.
1. cron check mailbox for bouce messages and get invalid mails from
there
2.use /etc/aliases (linux at least) and add there '|/opt/mysqcript'
for email address which used to sent mail from.
both types I get from RequestTracker  http://bestpractical.com/rt/

I belive without outside code this could not be resolved.

On 27 янв, 07:30, Thadeus Burgess  wrote:
> mail.send only fails if there was an authentication error or it was an
> invalid formed email... if you send to idontex...@example.com mail.send will
> still return True.
>
> -Thadeus
>
> On Tue, Jan 26, 2010 at 7:02 PM, hamdy.a.farag wrote:
>
> > Hi Yannic
>
> > I'm not sure whether this what you want or not, but the mail.send()
> > function itself returns True or false , so you could just do :
>
> > if not mail.send(to=.., subject=,) :
> >     response.flash = "Message was not sent"
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "web2py-users" group.
> > To post to this group, send email to web...@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.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: web2py 1.75.5 is OUT

2010-02-26 Thread KMax


On 26 фев, 12:09, mdipierro  wrote:
> Changelog #1.75.5
>
> fixed behaviour with languages.py, thanks Iceberg
I had an issue with shifting translation.
a=a
b=b
c=c
become
a=a
b=c
c=
Does this issue fixed or something else?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: Redefining db types without patching sql.py

2010-03-03 Thread KMax
Thank you for example,
sure it works for most cases, but what could be done with id of rows?
They are not defined explicity, and changes in sql.by were enought for
defining table i need.
Let me explain my idea.
 Let see sql.py from 1.76.1 release at position of
SQL_DIALECTS = {
.skipped...
'postgres': {
'boolean': 'CHAR(1)',
'string': 'VARCHAR(%(length)s)',
'text': 'TEXT',
'password': 'VARCHAR(%(length)s)',
'blob': 'BYTEA',
'upload': 'VARCHAR(%(length)s)',
'integer': 'INTEGER',
'double': 'FLOAT8',
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
'date': 'DATE',
'time': 'TIME',
'datetime': 'TIMESTAMP',
'id': 'SERIAL PRIMARY KEY',
'reference': 'INTEGER REFERENCES %(foreign_key)s ON DELETE %
(on_delete_action)s',
'lower': 'LOWER(%(field)s)',
'upper': 'UPPER(%(field)s)',
'is null': 'IS NULL',
'is not null': 'IS NOT NULL',
'extract': 'EXTRACT(%(name)s FROM %(field)s)',
'left join': 'LEFT JOIN',
'random': 'RANDOM()',
'notnull': 'NOT NULL DEFAULT %(default)s',
'substring': 'SUBSTR(%(field)s,%(pos)s,%(length)s)',
},
--
How ugly will be aproach where are at db.py top the code
SQL_DIALECTS = {
'postgres': {
'boolean': 'CHAR(1)',
'string': 'VARCHAR(%(length)s)',
'text': 'TEXT',
'password': 'VARCHAR(%(length)s)',
'blob': 'BYTEA',
'upload': 'VARCHAR(%(length)s)',
'integer': 'BIGINT',
'double': 'FLOAT8',
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
'date': 'DATE',
'time': 'TIME',
'datetime': 'TIMESTAMP WITH TIME ZONE',
'id': 'BIGSERIAL PRIMARY KEY',
'reference': 'BIGINT REFERENCES %(foreign_key)s ON DELETE %
(on_delete_action)s',
'lower': 'LOWER(%(field)s)',
'upper': 'UPPER(%(field)s)',
'is null': 'IS NULL',
'is not null': 'IS NOT NULL',
'extract': 'EXTRACT(%(name)s FROM %(field)s)',
'left join': 'LEFT JOIN',
'random': 'RANDOM()',
'notnull': 'NOT NULL DEFAULT %(default)s',
'substring': 'SUBSTR(%(field)s,%(pos)s,%(length)s)',
},
}
---end of code
This does not work, web2py use code from sql.py anyway...
QUESTION:
So, is it possible to redefine SQL_DIALECTS before tables defined and
in db.py ?

I guess here required knowledge of internal process - how it works.

I am sorry if question like sphere-horse model in vacuum.

On 2 мар, 18:27, mdipierro  wrote:
> You can do for example:
>
>         mydt =
> SQLCustomType(
>             type
> =datetime',
>             native ='TIMESTAMP WITH TIME
> ZONE',
>             encoder = ... ,
>             decoder = ... )
>             )
>
> db.define_table(
>
> 'example',
>             Field('value',
> type=mydt)
>             )
>
> type =datetime' is the web2py
> representation
> native ='TIMESTAMP WITH TIME ZONE' is the SQL
> representation
> encoder is a function that that gives you the SQL representation (must
> escape ' into '' for strings)
> decoder does the oppotsite.
>
> On Mar 2, 1:07 am, KMax  wrote:
>
> > Hello
> >  I create db schema at postgres db and then start to move it to db.py
> > definition.
> >  But get the issue with data types. For example: I use bigserial while
> > web2py use simple serial type.
> > I use TIMESTAMP WITH TIME ZONE (to support winter and summer time)
> > while web2py use TIMESTAMP (and postgres treat it as TIMESTAMP WITHOUT
> > TIME ZONE).
> >  I solve this issue by editing sql.py and dal.py and all gets fine,
> > but it make me force to apply this changes every web2py release.
> >  THE QUESTION:
> >  Could I redefine something in my db.py for avoid edition sql.py ?
> >  Please provide short example of it (I guess there difference in
> > sql.py and dal.py)
>
> > Thank you.
> > Maxim

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: how to troubleshoot admin errors?

2010-03-21 Thread KMax
Hello
  My web2py instalation (1.73 and newer) was affected by the same
issue.
  Running on debian by wsgi apache2. Installed by unzipping
web2py_src.zip in to fresh folder and coping parameters_443.py.
  Creation of new application give an error flash "unable to create
application."

  Workaround was found accidently.
  Starting web2py.by at console ( typing pass and quit ) solve issue
at apache.

Thank you.
On 3 мар, 00:13, snfctech  wrote:
> Fedora10 web2py1.76.1 apache2/mod_wsgi
>
> I thought all errors generated tickets?  When I try tocreatean app
> via the admin over HTTPS on a LAN all I get is an error flash "unable
> tocreateapplication."  It's not an apache permission issue because
> it does the same thing if all my files and dirs have 777 permissions.
> I don't get any apache errors in the error log and the only funny
> thing I get in the access log is a 303 code from the POST request to
> admin/default/site.  Something must not be working out with
> gluon.admin.app_create.
>
> How should I troubleshoot this type of error, or does anybody have an
> idea what's going on?
>
> I'm going to start dissecting the app_create function - but my python
> skills are still pretty weak and I was hoping there would just be a
> good error log somewhere...
>
> Thanks in advance for any tips.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: web2py russian group

2010-08-19 Thread KMax
Thank you professor for announce.

Добро пожаловать в группу.

On 20 авг, 09:24, mdipierro  wrote:
> There is a web2py group in russian.
>
> http://groups.google.ru/group/web2py_russian
>
> If you are the owner please let me know and I will be happy to link it
> from web2py.com


[web2py] oposite to XML operation or how to escape string

2010-08-19 Thread KMax
Hello
 I have a string with '&&' which must be replaced by 
 If I change all && with  and XML it, it could miss other html
tag in a string
 I could join  ''.join(DIV(substr)), but I do not need div tag
in output.

 So how to escaped string without DIV or other HTML helper?

 I look at web2py source, but miss that thing.

Thank you.


[web2py] Re: oposite to XML operation or how to escape string

2010-08-20 Thread KMax
Yes, thanks.
xmlescape(s)  - makes tags safe

On 20 авг, 17:16, mdipierro  wrote:
> something like this?
>
> ''.join(xmlescape(s) for s in t.split('&&'))
>
> On Aug 19, 11:25 pm, KMax  wrote:
>
>
>
> > Hello
> >  I have a string with '&&' which must be replaced by 
> >  If I change all && with  and XML it, it could miss other html
> > tag in a string
> >  I could join  ''.join(DIV(substr)), but I do not need div tag
> > in output.
>
> >  So how to escaped string without DIV or other HTML helper?
>
> >  I look at web2py source, but miss that thing.
>
> > Thank you.


[web2py] Re: integrate editarea in application

2010-08-20 Thread KMax
What does mean 'without going through the admin interface' ?
Try search TEXTAREA in book?
On 20 авг, 23:12, Cory Coager  wrote:
> How would I integrate editarea in my application without going through
> the admin interface?


[web2py] ajax post before ajax reload

2010-08-22 Thread KMax
Hello
 So we have a list of posts, which are need to be moderated. Each post
is a link which load crud.update on the particular post.
 I plan to update the list to reflect crud.update changes.
 So I put into crud form:
form.element(_type='submit')['_onclick'] =
XML("ajax('"+str(URL(r=request,f='export.load',args=[request.args(1),request.args(2)]))
+"',['rub_"+str(request.args(1))+"'], 'content');" )

 This works but, crud.update changes applyed after list reloaded. So
next reload shows changes.
Question: How to make form.submit via ajax before ajax reload? (in my
terms)
I try to make POST in onclick action, but failed due to lack of
parameters for ajax call (this ajax load crud form), but how to get it
known in _onclick definition?


[web2py] Re: ajax post before ajax reload

2010-08-22 Thread KMax
Thank for this, but it works opposite.

This does not POST, but reload content. My current situation POST
after reload (so next reload reflect POST).
How to POST and then reload?
I gues need to be done:
web2py_ajax_page('post',action,form.serialize(),target); (from
web2py_ajax.html)
But how to get known which target (it random I guess), form and action
need to be used?

On 22 авг, 23:23, mdipierro  wrote:
> If I understand
>
> form.element(_type='submit')['_onclick'] =
> XML("ajax('"+str(URL(r=request,f='export.load',args=[request.args(1),reques 
> t.args(2)]))
> +"',['rub_"+str(request.args(1))+"'], 'content'); return false;" )
>
> or simpler:
>
> form.element(_type='submit')['_onclick'] ="ajax('%s',['rub_%s'],
> 'content');retrun false" % (
> URL('export.load',args=[request.args(1),request.args(2)]),request.args(1))
>
> return false; should do what you ask.
>
> On Aug 22, 10:52 am, KMax  wrote:
>
>
>
> > Hello
> >  So we have a list of posts, which are need to be moderated. Each post
> > is a link which load crud.update on the particular post.
> >  I plan to update the list to reflect crud.update changes.
> >  So I put into crud form:
> > form.element(_type='submit')['_onclick'] =
> > XML("ajax('"+str(URL(r=request,f='export.load',args=[request.args(1),reques 
> > t.args(2)]))
> > +"',['rub_"+str(request.args(1))+"'], 'content');" )
>
> >  This works but, crud.update changes applyed after list reloaded. So
> > next reload shows changes.
> > Question: How to make form.submit via ajax before ajax reload? (in my
> > terms)
> > I try to make POST in onclick action, but failed due to lack of
> > parameters for ajax call (this ajax load crud form), but how to get it
> > known in _onclick definition?


[web2py] Re: ajax post before ajax reload

2010-08-22 Thread KMax
return false; - helps avoid moving page at top, and now ajax
crud.update appears like it hided.

On 22 авг, 23:23, mdipierro  wrote:
> return false; should do what you ask.


[web2py] Re: ajax post before ajax reload

2010-08-22 Thread KMax
Ok, the problem from other side:

On page via ajax loading the list.
Each list is a link to load via ajax a form.
I need to reload the list whan form is submitted.
1. ajax form reload 2.then ajax list reload with updated data from the
form
---
I guess workaround for this issue could be following:
page with list should contain hided forms for each item, then
submittig of any of form should reload the list. ( no ajax inside ajax
anymore )
PS I just tryed this workaround -  same issue.
I'l going to make test app for catch the root of the issue.

Thanks.


On 23 авг, 08:19, mdipierro  wrote:
> I think I need more explanation, a practical example of usage and an
> example of code. I do not understand.
>
> On Aug 22, 11:39 am, KMax  wrote:
>
>
>
> > Thank for this, but it works opposite.
>
> > This does not POST, but reload content. My current situation POST
> > after reload (so next reload reflect POST).
> > How to POST and then reload?
> > I gues need to be done:
> > web2py_ajax_page('post',action,form.serialize(),target); (from
> > web2py_ajax.html)
> > But how to get known which target (it random I guess), form and action
> > need to be used?
>
> > On 22 авг, 23:23, mdipierro  wrote:
>
> > > If I understand
>
> > > form.element(_type='submit')['_onclick'] =
> > > XML("ajax('"+str(URL(r=request,f='export.load',args=[request.args(1),reques
> > >  t.args(2)]))
> > > +"',['rub_"+str(request.args(1))+"'], 'content'); return false;" )
>
> > > or simpler:
>
> > > form.element(_type='submit')['_onclick'] ="ajax('%s',['rub_%s'],
> > > 'content');retrun false" % (
> > > URL('export.load',args=[request.args(1),request.args(2)]),request.args(1))
>
> > > return false; should do what you ask.
>
> > > On Aug 22, 10:52 am, KMax  wrote:
>
> > > > Hello
> > > >  So we have a list of posts, which are need to be moderated. Each post
> > > > is a link which load crud.update on the particular post.
> > > >  I plan to update the list to reflect crud.update changes.
> > > >  So I put into crud form:
> > > > form.element(_type='submit')['_onclick'] =
> > > > XML("ajax('"+str(URL(r=request,f='export.load',args=[request.args(1),reques
> > > >  t.args(2)]))
> > > > +"',['rub_"+str(request.args(1))+"'], 'content');" )
>
> > > >  This works but, crud.update changes applyed after list reloaded. So
> > > > next reload shows changes.
> > > > Question: How to make form.submit via ajax before ajax reload? (in my
> > > > terms)
> > > > I try to make POST in onclick action, but failed due to lack of
> > > > parameters for ajax call (this ajax load crud form), but how to get it
> > > > known in _onclick definition?


[web2py] Re: ajax post before ajax reload

2010-08-22 Thread KMax
## to db.py added
db.define_table('mytable',Field('myfield','string'))
## controllers/default.py
def index():
"""
example action using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html
"""
onclick =
XML( "ajax('"+str(URL(r=request,f='loadlist.load',args=[]))+"',
['test'], 'content');return false;" )
linkdiv=DIV(DIV(A('show me',_href='#',
_onclick=onclick)),DIV(_id='content'))
return dict(linkdiv=linkdiv)

def loadlist():
return dict()

def list():
result = []
for i in db(db.mytable.id > 0).select():
onclick=XML( "jQuery('#form"+str(i.id)
+"').slideToggle();return false;" )
 
form=crud.update(db.mytable,i.id,onaccept=crud.archive,deletable=False)
 
result.append(DIV(DIV(A(XML(i.myfield),_href='#',_onclick=onclick)),
DIV(form,_id = 'form'+str(i.id),_class = 'hidden')))
return dict(results=result)

## views/default/list.load
{{response.headers['Content-Type']='text/
html';response.headers['web2py-response-flash']=response.flash}}

{{for result in results:}}{{ =TR(TD(result))}}{{pass}}

## views/default/loadlist.load
{{response.headers['Content-Type']='text/
html';response.headers['web2py-response-flash']=response.flash}}
{{=LOAD ('default','list.load',args=[],ajax=True)}}

-
Adding to mytables some strings to see the list of them in example
code.
Clicking on 'show me' give a list of table rows.
Clicking on any of row shows form for string update.
But if you submit changes, they does not reflect in list of items (but
the same time db table row was updated)
Next time submit updates the list of items was made last time.

Question: how to make update of db table before updating list of item
of the same table?

On 23 авг, 08:19, mdipierro  wrote:
> I think I need more explanation, a practical example of usage and an
> example of code. I do not understand.


[web2py] Re: ajax post before ajax reload

2010-08-23 Thread KMax
This is link to example
http://web2py.ru/test
Click on 'show me' then on any in link of list and update. Second
update will reflect changes in first time
On 23 авг, 11:52, KMax  wrote:
> ## to db.py added
> db.define_table('mytable',Field('myfield','string'))
> ## controllers/default.py
> def index():
>     """
>     example action using the internationalization operator T and flash
>     rendered by views/default/index.html or views/generic.html
>     """
>     onclick =
> XML( "ajax('"+str(URL(r=request,f='loadlist.load',args=[]))+"',
> ['test'], 'content');return false;" )
>     linkdiv=DIV(DIV(A('show me',_href='#',
> _onclick=onclick)),DIV(_id='content'))
>     return dict(linkdiv=linkdiv)
>
> def loadlist():
>     return dict()
>
> def list():
>     result = []
>     for i in db(db.mytable.id > 0).select():
>         onclick=XML( "jQuery('#form"+str(i.id)
> +"').slideToggle();return false;" )
>
> form=crud.update(db.mytable,i.id,onaccept=crud.archive,deletable=False)
>
> result.append(DIV(DIV(A(XML(i.myfield),_href='#',_onclick=onclick)),
>         DIV(form,_id = 'form'+str(i.id),_class = 'hidden')))
>     return dict(results=result)
>
> ## views/default/list.load
> {{response.headers['Content-Type']='text/
> html';response.headers['web2py-response-flash']=response.flash}}
> 
> {{for result in results:}}{{ =TR(TD(result))}}{{pass}}
> 
> ## views/default/loadlist.load
> {{response.headers['Content-Type']='text/
> html';response.headers['web2py-response-flash']=response.flash}}
> {{=LOAD ('default','list.load',args=[],ajax=True)}}
>
> -
> Adding to mytables some strings to see the list of them in example
> code.
> Clicking on 'show me' give a list of table rows.
> Clicking on any of row shows form for string update.
> But if you submit changes, they does not reflect in list of items (but
> the same time db table row was updated)
> Next time submit updates the list of items was made last time.
>
> Question: how to make update of db table before updating list of item
> of the same table?
>
> On 23 авг, 08:19, mdipierro  wrote:
>
>
>
> > I think I need more explanation, a practical example of usage and an
> > example of code. I do not understand.


[web2py] Re: ajax post before ajax reload

2010-08-24 Thread KMax
I am glad you writing poems, but it is not the wall for comments :)
This is for issue invetigation.

On 24 авг, 07:33, KMax  wrote:
> This is link to examplehttp://web2py.ru/test
> Click on 'show me' then on any in link of list and update. Second
> update will reflect changes in first time
> On 23 авг, 11:52, KMax  wrote:
>
>
>
> > ## to db.py added
> > db.define_table('mytable',Field('myfield','string'))
> > ## controllers/default.py
> > def index():
> >     """
> >     example action using the internationalization operator T and flash
> >     rendered by views/default/index.html or views/generic.html
> >     """
> >     onclick =
> > XML( "ajax('"+str(URL(r=request,f='loadlist.load',args=[]))+"',
> > ['test'], 'content');return false;" )
> >     linkdiv=DIV(DIV(A('show me',_href='#',
> > _onclick=onclick)),DIV(_id='content'))
> >     return dict(linkdiv=linkdiv)
>
> > def loadlist():
> >     return dict()
>
> > def list():
> >     result = []
> >     for i in db(db.mytable.id > 0).select():
> >         onclick=XML( "jQuery('#form"+str(i.id)
> > +"').slideToggle();return false;" )
>
> > form=crud.update(db.mytable,i.id,onaccept=crud.archive,deletable=False)
>
> > result.append(DIV(DIV(A(XML(i.myfield),_href='#',_onclick=onclick)),
> >         DIV(form,_id = 'form'+str(i.id),_class = 'hidden')))
> >     return dict(results=result)
>
> > ## views/default/list.load
> > {{response.headers['Content-Type']='text/
> > html';response.headers['web2py-response-flash']=response.flash}}
> > 
> > {{for result in results:}}{{ =TR(TD(result))}}{{pass}}
> > 
> > ## views/default/loadlist.load
> > {{response.headers['Content-Type']='text/
> > html';response.headers['web2py-response-flash']=response.flash}}
> > {{=LOAD ('default','list.load',args=[],ajax=True)}}
>
> > -
> > Adding to mytables some strings to see the list of them in example
> > code.
> > Clicking on 'show me' give a list of table rows.
> > Clicking on any of row shows form for string update.
> > But if you submit changes, they does not reflect in list of items (but
> > the same time db table row was updated)
> > Next time submit updates the list of items was made last time.
>
> > Question: how to make update of db table before updating list of item
> > of the same table?
>
> > On 23 авг, 08:19, mdipierro  wrote:
>
> > > I think I need more explanation, a practical example of usage and an
> > > example of code. I do not understand.


[web2py] Re: ajax post before ajax reload

2010-08-24 Thread KMax
Issue too obvious,

In function definition, select goes before crud.update, so before new
data updated old data selected.

Thank you.

for i in db(db.mytable.id > 0).select():
onclick=XML( "jQuery('#form"+str(i.id)
+"').slideToggle();return false;" )
 
form=crud.update(db.mytable,i.id,onaccept=crud.archive,deletable=False)
 
result.append(DIV(DIV(A(XML(db.mytable[i.id].myfield),_href='#',_onclick=onclick)),

## db.mytable[i.id].myfield - force to reread data from table.
# two days of brain breaking :)
On 24 авг, 21:30, KMax  wrote:
> I am glad you writing poems, but it is not the wall for comments :)
> This is for issue invetigation.
>
> On 24 авг, 07:33, KMax  wrote:
>
>
>
> > This is link to examplehttp://web2py.ru/test
> > Click on 'show me' then on any in link of list and update. Second
> > update will reflect changes in first time
> > On 23 авг, 11:52, KMax  wrote:
>
> > > ## to db.py added
> > > db.define_table('mytable',Field('myfield','string'))
> > > ## controllers/default.py
> > > def index():
> > >     """
> > >     example action using the internationalization operator T and flash
> > >     rendered by views/default/index.html or views/generic.html
> > >     """
> > >     onclick =
> > > XML( "ajax('"+str(URL(r=request,f='loadlist.load',args=[]))+"',
> > > ['test'], 'content');return false;" )
> > >     linkdiv=DIV(DIV(A('show me',_href='#',
> > > _onclick=onclick)),DIV(_id='content'))
> > >     return dict(linkdiv=linkdiv)
>
> > > def loadlist():
> > >     return dict()
>
> > > def list():
> > >     result = []
> > >     for i in db(db.mytable.id > 0).select():
> > >         onclick=XML( "jQuery('#form"+str(i.id)
> > > +"').slideToggle();return false;" )
>
> > > form=crud.update(db.mytable,i.id,onaccept=crud.archive,deletable=False)
>
> > > result.append(DIV(DIV(A(XML(i.myfield),_href='#',_onclick=onclick)),
> > >         DIV(form,_id = 'form'+str(i.id),_class = 'hidden')))
> > >     return dict(results=result)
>
> > > ## views/default/list.load
> > > {{response.headers['Content-Type']='text/
> > > html';response.headers['web2py-response-flash']=response.flash}}
> > > 
> > > {{for result in results:}}{{ =TR(TD(result))}}{{pass}}
> > > 
> > > ## views/default/loadlist.load
> > > {{response.headers['Content-Type']='text/
> > > html';response.headers['web2py-response-flash']=response.flash}}
> > > {{=LOAD ('default','list.load',args=[],ajax=True)}}
>
> > > -
> > > Adding to mytables some strings to see the list of them in example
> > > code.
> > > Clicking on 'show me' give a list of table rows.
> > > Clicking on any of row shows form for string update.
> > > But if you submit changes, they does not reflect in list of items (but
> > > the same time db table row was updated)
> > > Next time submit updates the list of items was made last time.
>
> > > Question: how to make update of db table before updating list of item
> > > of the same table?
>
> > > On 23 авг, 08:19, mdipierro  wrote:
>
> > > > I think I need more explanation, a practical example of usage and an
> > > > example of code. I do not understand.


[web2py] Re: Suggestions for the Basic Authentications

2010-09-19 Thread KMax
I guess, this is still actual.
And some thought on profile remove feature.
If some posts or any other records are referenced to the profile, is
it good idea to drop them in cascade? I guess not. The obly way is
mark profile as removed (or might empty all fields), and process this
flag in app.

Cross auth is more instresting feature. I move forward and ask:
Is there the way to have (for expl) two sites with own users and
groups, both managed by different people.
User get logged on one site and ajaxing the page from another site,
but restrict this ajaxing by groups on first one.(I am making both
sides)
Maybe func on second site which should be ajaxed, will ask for
permission at first site?
Is it possible to use onAuth for this?

Sorry if so complicated.
On 17 авг, 01:32, mdipierro  wrote:
> b) a new version of the CAS appliances based onAuth
>
> b - is in the todo list


On 17 авг, 05:34, mdipierro  wrote:
> I understand now.
>
> > This action is like "completly remove my account from the website" ==>
> > the opposite of "register".
>
> This should be easy to do. I am traveling this week but I can do it
> the next. Please remind me.


[web2py] Re: AJAX issue with '#' in URL

2010-09-20 Thread KMax
Did you check errors in admin page?
 Ajax errors not easy to catch due their hideness.
 Try FireBug or other simular tools (Google chrome & IE8 has own build-
in)

On 13 сен, 10:40, weheh  wrote:
> Sorry, I don't think I was very clear in my last message. I tried
> Massimo's suggestion but did the AJAX call still fails. I don't
> understand the new failure, yet, or whether it is the same as the old
> failure. I am investigating.


[web2py] Re: postgresql 9

2010-09-20 Thread KMax
Hot-backup and other HA features make me excited!

On 21 сен, 01:06, mdipierro  wrote:
> http://www.postgresql.org/about/news.1235


[web2py] Re: Suggestions for the Basic Authentications

2010-09-23 Thread KMax
reminding if actual

> On 17 авг, 05:34, mdipierro  wrote:
 This should be easy to do. I am traveling this week but I can do it
 the next. Please remind me.


[web2py] Re: nginx with bultin uwsgi module

2010-09-30 Thread KMax
Glad you note this, but no documentaions on top.
I like nginx , but apache-wsgi is more documented so used.
If any one have links to nginx-wsgi docs please share.

On 30 сен, 19:12, elffikk  wrote:
> http://nginx.org/


[web2py] How cache in db().select() works

2010-10-05 Thread KMax
Hello
  In trying to optimize db selects I get start to use cache=(cache.ram,
10), but performance does not changed.
  So, I start to figure out how cache works.
  As I underdestand each process (or tread) has own cache in ram.
  If I get db(db.auth_user.id==1).select(cache.ram,600), then this
request will be cached for 10 minutes.
  What happen on this db(db.auth_user.id==2).select(cache.ram,600) ?

Both selects will be cached, or second will push out first one? Does
cache keep results with query as key? Where are some docs about that?

I have select from table with lots of refences, and for each I get
value from ref table.
Like
*table of name
*table of secondname
*table(ref_name,ref_secondname)
List of 100 records will generate 200 select on reference table.

My problem is how to avoid useless selects.

Thank you


[web2py] Re: How cache in db().select() works

2010-10-05 Thread KMax
Yes, multi table select could be used, but I make some data processing
before paging (like name+' '+secondname ), and some other more.

My question is how to cache select depend on query? (make bigger
cache?)
Cache stat shows 70-80% hits (it shows stat of random thread ), but
each search ( page with search func ) run equal time. (if cache works,
first one should run longer then second, in case search made in same
thread of webserver)
I checked my postgres - yes, there lot of select-queryes on each page
request.

On 5 окт, 15:59, ron_m  wrote:
> Would it work for you to do a 3 table JOIN and then it would be one
> select?
>
> You put the ON clauses in the same place as the WHERE clause with &
> between e.g.
>
> db((db.name.id==db.ref_table.name_id) &
> (db.secondname.id==db.ref_table.secondname_id)).select(.
>
> where ref_table is your third table in your model description.
>
> On Oct 5, 12:15 am, KMax  wrote:
>
>
>
> > Hello
> >   In trying to optimize db selects I get start to use cache=(cache.ram,
> > 10), but performance does not changed.
> >   So, I start to figure out how cache works.
> >   As I underdestand each process (or tread) has own cache in ram.
> >   If I get db(db.auth_user.id==1).select(cache.ram,600), then this
> > request will be cached for 10 minutes.
> >   What happen on this db(db.auth_user.id==2).select(cache.ram,600) ?
>
> > Both selects will be cached, or second will push out first one? Does
> > cache keep results with query as key? Where are some docs about that?
>
> > I have select from table with lots of refences, and for each I get
> > value from ref table.
> > Like
> > *table of name
> > *table of secondname
> > *table(ref_name,ref_secondname)
> > List of 100 records will generate 200 select on reference table.
>
> > My problem is how to avoid useless selects.
>
> > Thank you


[web2py] Propose to add case-independ like

2010-10-05 Thread KMax
Hello
  Postgres has ILIKE where clawse, but it postgres specific extention.
  Is there way to add .ilike to gluon of web2py DAL ?
  Or is there the way to add .ilike to dal at model initialisation.

  I know that .lower could be used to workaround case sensity, but I
have cyrillic chars and .lower() works on them only
with .decode('utf-8').lower().encode('utf-8') and more over, does not
work in dal-query at all.

  So, please advise.


[web2py] Re: "unable to create application" on Ubuntu 10.04 LTS

2010-10-05 Thread KMax
Maybe not the same issue. But I do following:
sudo su - www-data
or to user which selected in wsgi settings.
And do
cd 'web2py installation dir' #put your path
python web2py.py
Set the password and then stop it (Ctrl-C).
Restart apache and try to create new application complete with
success.

ps. make move parameters_8080.py to parameters_443.py to have my
password at appadmin.


[web2py] Re: prefork or worker mpm for apache embedded mode

2010-11-01 Thread KMax
I guess DAL threadsafe.

Worker is better for mod_wsgi, it could use multithreads, while
prefork is not.

What is 'embedded mode' ?

On 1 ноя, 10:26, Sujan Shakya  wrote:
> The preferred apache configuration for mod_wsgi applications is to run
> in daemon mode.
> But if the application is to be run in embedded mode, which one is
> preferred: prefork mpm or worker mpm ?
> And, is DAL threadsafe ?


[web2py] Re: Component updating too quickly

2010-11-01 Thread KMax
I have same issue recently.
 Even give access to the app with demonstration...

Solution were too oblevious.

insert were after select, so only next select shows all data (with
recently inserted row)

On 1 ноя, 03:10, Luther Goh Lu Feng  wrote:
> In my action, I would like to update a component if the form is
> accepted. The component is a comments list and the form is a comment
> creation form. The problem is, the component does update, but does not
> show the new comment created. I suspect that the component is updating
> too quickly. I know this for sure as in the background I am updating
> the comments component at regular intervals. So the component gets
> updated on the next background refresh.
>
> #process form create comments
> if comments_form.accepts(request.vars, session):
>      response.flash = 'Comment created'
>      response.js = "web2py_component('/roverus/comment/read.load?
> current_conversation=1');"


[web2py] Re: PostgreSQL super slowdowns

2010-11-01 Thread KMax
Please check .first() or .last() usage.
With Postgres for some reason, all data are transfered to DAL, and on
w2p side first or last recored selected.

Solution also are easy use:
.select(limitby=(0,1)).first()
or
select(limitby=(0,1),orderby=~db.papers.id).first()
or
.select(limitby=(0,1),orderby=db.papers.id).first().

orderby=~ and orderby= will give you last or first for .first()
and .last() - since only one record are returned from db.

Hope I score.

On 29 окт, 12:53, Chris  wrote:
> Hey,
>
> I've noticed some serious slowdowns ever since I switched from SQLite
> to Postgres. Pages will take MINUTES to load - it's kind of
> fascinating.
>
> I don't have the full explanation for what's going on yet but I do
> have some clues. I've noticed it happens locally, and in a specific
> way:
>
> 1) I load the page up in one browser and it loads and reloads fine.
> 2) When I open the page up in another browser or in an incognito
> session on the same machine, the page request hangs, usually for
> longer than two minutes.
>
> I don't know for sure that it's Postgres related, but I don't remember
> seeing this on SQLite.
>
> This is something I really need to fix! Can anyone reproduce this? Are
> there profilers or particular places in the code I can tag?
>
> Thanks! - Chris


[web2py:36070] Re: expire login when browser closes

2009-11-27 Thread KMax
logout ?

On 27 ноя, 00:54, vince  wrote:
> it will expire when browser close on firefox/safari. however, if you
> just close the tab the session won't expire. is there any workaround
> for this problem?

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:37578] restore db tcp connection

2009-12-19 Thread KMax
Hello
 Unable to find solution here, so i am asking.
 Is there any way to avoid Internal error on losing connection to db?
 At this moment I have to restart apache to restore connection.
 Apache2 and postgres8.3 run on separate linux workstations.
Thanks in advice.

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:37586] Re: restore db tcp connection

2009-12-20 Thread KMax
db = DAL('postgres://web2py:web2p...@db.host.local/web2py',
pool_size=10)
Direct tcp connection. If db.host.local restarted or postgres
restarted. No way to restore connection unless restart apache who host
web2py.

On 20 дек, 12:22, mdipierro  wrote:
> I think I need to know more about settings. Who is losing connections
> to the db? Is there a ssh tunnel connection the two machines? Do you
> use connection pooling and one of the threads in the pool loses the
> connection? Is this a problem without connection pooling?

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:37599] Re: restore db tcp connection

2009-12-20 Thread KMax
I'l update this tread.
Thank you for your attention.

On 20 дек, 23:25, mdipierro  wrote:
>  Please remind me
> when the new DAL is out (in 2-3 weeks) so you test it.

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:37794] Re: Postgresql-types limited by web2py :(

2009-12-23 Thread KMax
+1
For now in may project, tables with inet types is out of web2py table
definition, and live with their own life.
Maybe some kind plugin could make this feature works in main
application?
On 24 дек, 00:01, Thadeus Burgess  wrote:
> I am also curious about using the postgresql inet type.

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:37826] Re: Postgresql-types limited by web2py :(

2009-12-25 Thread KMax
Sorry for linking:

http://www.postgresql.org/docs/current/static/datatype-net-types.html

Maybe in some way inet/cidr types could be released using
SQLCustomType

On 24 дек, 10:20, mdipierro  wrote:
> what is the inet type?

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:37834] Re: Happy Holidays

2009-12-25 Thread KMax
Warm wishes from cold Russia!

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38046] Re: Postgresql-types limited by web2py :(

2009-12-29 Thread KMax
Please advise.

Error traceback

Traceback (most recent call last):
  File "gluon/restricted.py", line 173, in restricted
exec ccode in environment
  File "/home/web2py/applications/test/models/db.py", line 12, in

SQLField('network',type=cidr))
  File "gluon/sql.py", line 1249, in define_table
t._create(migrate=migrate, fake_migrate=fake_migrate)
  File "gluon/sql.py", line 1600, in _create
(field.type, field.name)
SyntaxError: Field: unknown field type: string for network



In file: /home/web2py/applications/test/models/db.py

from gluon.dal import SQLCustomType

inet = SQLCustomType ( type='string', native='inet')

cidr = SQLCustomType ( type='string', native='cidr')

macaddr = SQLCustomType ( type='string', native='macaddr')

db = DAL('postgres://web2py:web...@localhost/test1', pool_size=10)

db.define_table('firewall',
SQLField('network',type=cidr))

On Dec 25, 9:15 pm, mdipierro  wrote:
> yes this is definitively possible. I would try
>
>         inet = SQLCustomType
> (
>             type
> ='string',
>             native
> ='inet'))
>
>         db.define_table
> (
>
> 'example',
>             Field('value',
> type=inet)
>             )
>
> Massimo

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38054] Re: Postgresql-types limited by web2py :(

2009-12-29 Thread KMax
This code start to work
===
from gluon.sql import SQLCustomType

db = DAL('postgres://web2py:gfhj...@db.sibnet.su/test1',
pool_size=10)
inet = SQLCustomType ( type='string',native='inet')

db.define_table('firewall',
SQLField('network',type=inet))
===
Look like
==from gluon.dal import SQLCustomType
was not good idea.
BUT
Inserting or updating using web2py db admin
Shows following:
---
Traceback (most recent call last):
  File "gluon/restricted.py", line 173, in restricted
exec ccode in environment
  File "/home/web2py/applications/test/controllers/appadmin.py", line
304, in 
  File "gluon/globals.py", line 96, in 
self._caller = lambda f: f()
  File "/home/web2py/applications/test/controllers/appadmin.py", line
286, in update
if form.accepts(request.vars, session):
  File "gluon/sqlhtml.py", line 896, in accepts
self.table._db(self.table.id == self.record.id).update(**fields)
  File "gluon/sql.py", line 3151, in update
self._db._execute(query)
  File "gluon/sql.py", line 952, in 
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
ProgrammingError: syntax error at or near ".3"
LINE 1: UPDATE firewall SET network=1.2.3.5 WHERE firewall.id=1;
===
Traceback (most recent call last):
  File "gluon/restricted.py", line 173, in restricted
exec ccode in environment
  File "/home/web2py/applications/test/controllers/appadmin.py", line
304, in 
  File "gluon/globals.py", line 96, in 
self._caller = lambda f: f()
  File "/home/web2py/applications/test/controllers/appadmin.py", line
124, in insert
if form.accepts(request.vars, session):
  File "gluon/sqlhtml.py", line 898, in accepts
self.vars.id = self.table.insert(**fields)
  File "gluon/sql.py", line 1844, in insert
self._db._execute(query)
  File "gluon/sql.py", line 952, in 
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
ProgrammingError: syntax error at or near ".1"
LINE 1: INSERT INTO firewall(network) VALUES (1.1.1.2);

Thank you for your helping
On Dec 30, 12:31 pm, mdipierro  wrote:
> I need your help debugging this... the relevant code in sql.py is
>
>             if isinstance(field.type,SQLCustomType):
>                 ftype = field.type.native or field.type.type
>             elif ...
>             elif not field.type in self._db._translator:
>                 raise SyntaxError, 'Field: unknown field type: %s for %s' % \
>                     (field.type, field.name)
>
> You get error on the last line but given the code you show me, it
> should never get there. The first if should be true because field.type
> should be cidr which is SQLCustomType.
>
> Try add some print statements and see what happens.

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38198] Look like http://www.web2py.com/ is DOWN

2010-01-02 Thread KMax
URL reply with:
Service Temporarily Unavailable

The server is temporarily unable to service your request due to
maintenance downtime or capacity problems. Please try again later.
Apache/2.2.9 (Ubuntu) mod_ssl/2.2.9 OpenSSL/0.9.8g Server at www.web2py.com
Port 80

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38204] membership manager plugin

2010-01-02 Thread KMax
Hello
  Im working on plugin to manage group membership. Main idea is
following:
Some kind of view loading the manager (i guess this way):
=LOAD('plugin_membershipmanager',args=Group_id,ajax=True)

Plugin gets all members of group with id=Group_id, and gets all users
are not in group.
Im easyly show this lists by plugin.
def index():
group_id=request.args(0)
group=db.auth_group[group_id] # group chouse table
members = db(db.auth_membership.group_id ==
group.id).auth_membership.select(db.auth_membership.user_id)
notmembers = db(db.auth_membership.group_id !=
group.id).auth_membership.select(db.auth_membership.user_id)
return DIV(members,notmembers).xml()

In some way I need to make each users as url in both of list one with
'remove' vars and second with 'add' vars.
So, clicking on names and logins will add and remove respectively.
(that the plan at least), I tryed to make this by view, BUT view in
plugin are ignored.

Now the question:
   How to from members.select() result, return table of urls A(str
(db.auth_user[member.user_id].first_name)+' '+str(db.auth_user
[member.user_id].last_name),URL
(c='plugin_membershipmanager',f='index',args=group_id, vars=
{'action':'remove'})

Thank you, for advise. Sorry if this is too newbe, but I failed to
find sample code or manual. Hope this code will be universal to post
as a slice.

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38242] Re: membership manager plugin

2010-01-03 Thread KMax
I have some progress here. Code might looks ugly, please excuse my
newbie try.
As you can see I use raw sql query to my postgress, since I fail to
make same by web2py dal
--begin of plugin controller--
def index():
group_id=request.args(0)
if IS_IN_DB(db(db.auth_user.id==request.vars.id),db.auth_user.id):
if request.vars.action == 'del':
if db((db.auth_membership.user_id == request.vars.id) &
(db.auth_membership.group_id == group_id)).select():
auth.del_membership(group_id,request.vars.id)
if request.vars.action == 'add':
if db((db.auth_membership.user_id == request.vars.id) &
(db.auth_membership.group_id == group_id)).select():
pass
else:
auth.add_membership(group_id,request.vars.id)
group=db.auth_group[group_id] or redirect(URL
(request.application,'roles','groups'))
members = db(db.auth_membership.group_id == group_id).select
(db.auth_membership.user_id)
query = 'SELECT auth_user.id FROM auth_user,auth_membership where
auth_user.id>0 and auth_user.id not in (select auth_membership.user_id
from auth_membership where auth_membership.group_id='+str(group_id)+')
group by auth_user.id'
notmembers = db.executesql(query)
return dict
(members=members,notmembers=notmembers,group_id=group_id)
---end of controller--
---begin view---



  {{=T('Members')}}{{=T('Action')}}



{{for member in members:}}

   {{=A(str(db.auth_user[member.user_id].first_name)+' '+str
(db.auth_user[member.user_id].last_name)+' login:'+str(db.auth_user
[member.user_id].email),_href=URL
(r=request,c='plugin_groups',f='index',args=group_id,vars=
{'action':'del','id':member.user_id}))}}
   {{=SPAN('[',A('remove',_href=URL
(r=request,c='plugin_groups',f='index',args=group_id,vars=
{'action':'del','id':member.user_id})),']')}}

{{pass}}

 {{=T('NotMembers')}}{{=T('Action')}}

{{for member in notmembers:}}
{{notmember=member[0]}}

   {{=A(str(db.auth_user[notmember].first_name) + ' ' + str
(db.auth_user[notmember].last_name) + ' ' + str(db.auth_user
[notmember].email),_href=URL
(r=request,c='plugin_groups',f='index',args=group_id,vars=
{'action':'add','id':notmember}))}}
   {{=SPAN('[',A('add',_href=URL
(r=request,c='plugin_groups',f='index',args=group_id,vars=
{'action':'add','id':notmember})),']')}}

{{pass}}


--end of view---
Now loading the plugin at main-application
/welcome/default/index.html:

{{extend 'layout.html'}}
{{=T('Add/remove users for group:')}}{{=db.auth_group[request.args
(0)].role}}
{{=LOAD('plugin_groups',args=[request.args(0)],ajax=True)}}

First of all(as small bug report?, i do not need this functuanality):
{{=LOAD('plugin_groups',f='index',args=[request.args(0)],ajax=True)}}
Shows error: TypeError: __call__() got an unexpected keyword argument
'f'
on line: response.write(LOAD('plugin_groups',f='index',args=
[request.args(0)],ajax=True))
Second one (more important for me):
I use http://vimeo.com/7182692 as a manual
And if I add or remove on page: which loads plugins, link does not
update internal area, but follow to /welcome/plugin_groups/index/1
(/1 - group_id)
I realy want to make cool ajax page, but failed. Please point to
possibly other approach to web2py ajax sollution.

Thank you, for your attention.

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38256] Re: membership manager plugin

2010-01-03 Thread KMax
Thank you for comments.
I was looking to .belongs side, but did not find correct one query.

Searching for documentation make me think that all plugin_* stuff are
not so complicatated.
Just admin Plugins division. All my creating could be done using usual
controller with corresponding view. Is not it?

The issue is: links inside ajax loaded content on click does not
update ajax loaded data, but sent browser to /welcome/plugin_groups/
index/1
I guess only 'post' are modified to ajax compatible way, but not 'get'
links.
On 3 янв, 22:00, mdipierro  wrote:
> A couple of things:
>
>  query = 'SELECT auth_user.id FROM auth_user,auth_membership where
> auth_user.id>0 and auth_user.id not in (select auth_membership.user_id
> from auth_membership where auth_membership.group_id='+str(group_id)+')
> group by auth_user.id'
> rows = db.executesql(query)

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38287] Re: membership manager plugin

2010-01-03 Thread KMax
The issue is: links inside ajax loaded content on click does not
update ajax loaded data, but sent browser to /welcome/plugin_groups/
index/1
# correct and about this guess?
I guess only 'post' are modified to ajax compatible way, but not 'get'
links.

On 4 янв, 00:21, mdipierro  wrote:
> correct

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38317] Re: membership manager plugin

2010-01-04 Thread KMax
I get understand following things:
 I am too week with js
 GroupMembershipManager may be usual function from any controller with
corresponding view.
 To use ajax features, I need make all get links as post (due to lack
of js knowledge) OR
 Use http://code.google.com/p/jquery-hijack/ with Jquery UI 1.7 tabs
(should have nice look).
 I was trying to adapt web2py_ajax.html or jquery-hijack but have no
luck.
On 4 янв, 14:36, mdipierro  wrote:
> Yes. If you want to capture links you would have to modify code in
> web2py_ajax.html.

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38376] make web2py_ajax.html support A links

2010-01-05 Thread KMax
Hello
  I've done small modification to web2py_ajax.html (to function
web2py_trap_form precisely)  to support not only forms but A links
also.

#function web2py_trap_form(action,target) {
#   jQuery('#'+target+' form').each(function(i){
#  var form=jQuery(this);
#  jQuery(':submit,.submit',this).click(function(){
# jQuery('.flash').hide().html('');
# web2py_ajax_page('post',action,form.serialize(),target);
# return false;
#  });
#   });
   jQuery('#'+target+' a').each(function(i){
$(this).click(function(){
jQuery('.flash').hide().html('');
web2py_ajax_page('get',$(this).attr('href'),null,target);
 return false;
  });
   });
#}
This work as magic. Not sure how. Can't say should i leave " jQuery
('.flash').hide().html('');" or remove it.
Please criticize.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38382] Re: membership manager plugin

2010-01-05 Thread KMax
And finaly membership manager was done.
You could download it from following link (should be active for month)
http://files.mail.ru/73S2GE or http://files.mail.ru/QXD2TK
Just unpack (tar.bz2 and rar variant provided) in to your application
( aware web2py_ajax.html will be overwriten)
Create at least one user and then you may try roles view to check the
plugin.
Create group on group menu and click on group to manage user
membership.

This plugin was provided as is. No warrany, please use it for your own
risk for no charge.
I have plans to make user membership manager - to manage groups of
particular user.

Thank you.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38423] Re: make web2py_ajax.html support A links

2010-01-05 Thread KMax
I believe this code trap only links inside .ajax loaded page.
At least my plugin works well with this patch.

Thank you for checking this.
On 6 янв, 02:42, mdipierro  wrote:
> This is useful but I am not convinced it should be the default.
> Perhaps we can capture only links of class "trapped".
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38468] Re: template, static files, routes.py

2010-01-06 Thread KMax
I just check layout.html and found there place for menu.
So it should not be the issue to plase at layout.html code like
{{=myhead()}} and only issue will be valid return of myhead().
is it?
On 6 янв, 21:36, mdipierro  wrote:
> Yes and no. the web2py template language is very different from
> Django's because everything inside {{...}} is pure python. This means
> there is no concept of blocks but in python you have function calls.
>
> You can do
>
> #based.html
> {{def something()}}text goes here{{return}}
> {{extend 'layout.html'}}
> Hello world
>
> #layout.html
> 
> {{something()}}
> {{include}}
> 
>
> The def defines a funciton that you can use as a block.
>
> On Jan 6, 6:13 am, Sujan Shakya  wrote:
>
> > I have some questions that I have not understood.
>
> > In layout.html, I found only one {{include}}.
> > Is it possible to use more {{include}} in layout.html so that we can
> > achieve equivalent of the following:
> > {% block head %}{% endblock %}
> > {% block content %}{% endblock %}
> > {% block col3 %}{% endblock %}
>
> > How are the static files served in production servers? Are they served
> > thru apache/lighttpd or web2py itself ?
>
> > And why is it that the use of routes.py not preferred?
>
> > Thanks.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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:38483] [bug?] [ update all languages ] mix translation

2010-01-06 Thread KMax
Hello
  I have broke my translation file for second time while 'update all
languages'
 Most translation are shifted to up heighbour. And at the and there
are 3-4 steps different: like

# coding: utf8 at the begining all fine
{
'"update" is an optional expression like "field1=\'newvalue\'". You
cannot update or delete the results of a JOIN':
'"\xd0\x98\xd0\xb7\xd0\xbc\xd0\xb5\xd0\xbd\xd0\xb8\xd1\x82\xd1\x8c" -
\xd0\xbd\xd0\xb5\xd0\x
'%Y-%m-%d': '%d-%m-%Y',
'%Y-%m-%d %H:%M:%S': '%d-%m-%Y %H:%M:%S',
---skip---
'record': 'record id',
'record does not exist': 'register',
'record id': 'remove from group',
'register': 'selected',
'remove from group': 'state',
'selected': '\xd1\x82\xd0\xb0\xd0\xb1\xd0\xbb
\xd0\xb8\xd1\x86\xd0\xb0',
'state': 'unable to parse csv file',
'table': '',
'unable to parse csv file': '',
}
#at the and
You can see translation for 'parse' are 2 steps away.

Please advise, what can I do to hunt down the bug.
Usualy update all language works just fine.

Thank you
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: mix translation

2010-01-06 Thread KMax
The lastest version.
On 7 янв, 05:31, mdipierro  wrote:
> Which web2py version?

I made some patches to sql.py and dal.py ( timestamp->timestamp with
time zone, integer -> bigint, serial->bigserial), hardly belielive
this is cause.
Maybe ru locale is the reason? Webserver locale?
Did anyone with ru language has same issues?

I'L  try to debug this, but first I have to find out how.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: new in trunk RFC

2010-01-11 Thread KMax
few questions bellow:
On 10 янв, 21:38, mdipierro  wrote:
> There are two new features in trunk. One will probably stay, the other
> I do not know:
>
> 1) Before you could do
>
>     db.define_table('person',Field('name'),format='%(name)s')
>     db.define_table('dog',Field('name'),Field('owner',db.dog))
db.dog.owner refs to ?! self
>
> now you can also have things like
>
>     format=lambda person: person.name.capitalize()
What is the person is? db.person[id] or id of a row?
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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] Why id=0 is not assessible by [0]

2010-01-16 Thread KMax
Hello
 Lets define at db.py
db.define_table ('a',
SQLField('a'))

And lets insert to this table (not by web2py admin panel)
sqlite> insert into a values(0,0);

And then
def test():
 return dict(message=db.a[0].a)
---
Will give:
Traceback (most recent call last):
  File "gluon/restricted.py", line 173, in restricted
  File "C:/!Work/web2py/applications/test/controllers/default.py",
line 51, in 
  File "gluon/globals.py", line 96, in 
  File "C:/!Work/web2py/applications/test/controllers/default.py",
line 13, in test
AttributeError: 'NoneType' object has no attribute 'a'

While asking db.a[1].a have no such error
Please tell, why 0 as id is so special?
I just use 0 for some default values, in mind they are not used yet
and ref to [0] annoing with error above.
Should I refuse use id=0 rows OR, could be some other way

Thank you for time.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: Why id=0 is not assessible by [0]

2010-01-16 Thread KMax
So, I make a resume. Using zero id was bad idea.
Thank you.

On 16 янв, 23:16, mdipierro  wrote:
> id starts counting a zero. It is not a rule but a convention in SQL.
> web2py makes sure it is followed.
>
> Massimo
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: Why id=0 is not assessible by [0]

2010-01-16 Thread KMax
I note about force id value on insert:
sqlite> insert into a values(0,0);
Yes, it is hack. Yes, I was trying to cheat with id for my own
reasons.
And then I was surprised that db.a[0].a does not exist while db.a[1].a
is.
Looking in to the sourcecode does not give me the answer 'Why'
due to luck of knowledge. Never the less, I made [1] as default to
undefined references.

On 17 янв, 02:31, mdipierro  wrote:
> The fact is you should not be able to choose the value of the ID of a
> new record. if you an auto increment fiels starting at 1 (which is the
> default for many SQL implementations).
>
> Massimo
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: restore db tcp connection

2010-01-16 Thread KMax
remider

> On 20 дек, 23:25, mdipierro  wrote:
>
> >  Please remind me
> > when the new DAL is out (in 2-3 weeks) so you test it.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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] format = lambda ... give error

2010-01-17 Thread KMax
Please find test code below
If i remove format = lambda x: from defining db.a, no error appears

Error traceback
Traceback (most recent call last):
  File "gluon/restricted.py", line 171, in restricted
  File "C:/!Work/web2py/applications/test/models/db.py", line 9
format = '%(a)s')
 ^
SyntaxError: invalid syntax


In file: C:\!Work\web2py\applications\test/models/db.py
db = DAL('sqlite://storage.sqlite')   # if not, use SQLite or
other DB

db.define_table ('a',
SQLField('a'),
format = lambda x: "%s" % (x.a))

db.define_table ('b',
SQLField('a',db.a)
format = '%(a)s')


I guess there is some semantic issue. Please help.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: format = lambda ... give error

2010-01-17 Thread KMax
my fall,
I'l make better samble (missed ",")

On 17 янв, 18:45, KMax  wrote:
> Please find test code below
> If i remove format = lambda x: from defining db.a, no error appears
> 
> Error traceback
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 171, in restricted
>   File "C:/!Work/web2py/applications/test/models/db.py", line 9
>     format = '%(a)s')
>          ^
> SyntaxError: invalid syntax
>
> In file: C:\!Work\web2py\applications\test/models/db.py
> db = DAL('sqlite://storage.sqlite')       # if not, use SQLite or
> other DB
>
> db.define_table ('a',
>     SQLField('a'),
>     format = lambda x: "%s" % (x.a))
>
> db.define_table ('b',
>     SQLField('a',db.a)
>     format = '%(a)s')
>
> 
> I guess there is some semantic issue. Please help.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: format = lambda ... give error

2010-01-17 Thread KMax
Ok!

1.74.6 helps.

My linux instalation was not updated, while windows is update date
which confuse me.

On 17 янв, 19:02, KMax  wrote:
> my fall,
> I'l make better samble (missed ",")
>
> On 17 янв, 18:45, KMax  wrote:
>
> > Please find test code below
> > If i remove format = lambda x: from defining db.a, no error appears
> > 
> > Error traceback
> > Traceback (most recent call last):
> >   File "gluon/restricted.py", line 171, in restricted
> >   File "C:/!Work/web2py/applications/test/models/db.py", line 9
> >     format = '%(a)s')
> >          ^
> > SyntaxError: invalid syntax
>
> > In file: C:\!Work\web2py\applications\test/models/db.py
> > db = DAL('sqlite://storage.sqlite')       # if not, use SQLite or
> > other DB
>
> > db.define_table ('a',
> >     SQLField('a'),
> >     format = lambda x: "%s" % (x.a))
>
> > db.define_table ('b',
> >     SQLField('a',db.a)
> >     format = '%(a)s')
>
> > 
> > I guess there is some semantic issue. Please help.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: Table id referenced to another table error?

2010-01-17 Thread KMax
On 18 янв, 08:20, Gibran Rodriguez  wrote:
> db.define_table('Activity',
>                 Field('type',length=45),
>                 Field('start_date','date'),
>                 Field('end_date','date'),
>                 Field('money',length=45),
>                 Field('price','double'),
>                 Field('person_id',db.Person.id))
Try Field('person_id',db.Person)
Remove ".id"-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: showcase

2010-01-18 Thread KMax
Error: Not Found
The requested URL / was not found on this server.

On 18 янв, 20:19, Chris  wrote:
> Hello,
> I am newbie in python and web2py. This is my first 
> app.http://genille.vievox.com
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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: LIKE case sensitivity: Postgres differs to MySQL => DAL not portable

2011-01-28 Thread KMax


On 7 дек 2010, 00:31, Fran  wrote:
> - minimally it should be in a FAQ (ideally in the next Book) & ideally
> we could have a case_sensitive=True option for the DAL like()
> operator...to ensure that both pgsql & mysql/sqlite existing apps
> didn't break, it could default differently depending on the db type?

+1 vote
sqlite has some issue with not ascii chars compare, but work in
progress
pgsql has ilike which works like mysql like (fix me)

I' just patch dal to use ilike in .like() query for postgres, but it
more cheat then solution.


[web2py] Re: LIKE case sensitivity: Postgres differs to MySQL => DAL not portable

2011-01-28 Thread KMax
On 29 янв, 05:39, Bernd Rothert  wrote:
> On 28 Jan., 16:46, Thadeus Burgess  wrote:
>
> > Case sensitive search is one of the benefits of using postgres instead of
> > mysql!
>
> As Fran wrote case insensitive LIKE is just a default for MySQL and
> sqlite. MySQL supports case sensitive search:
This make .like() for mysql work not same as PG, etc...
>
> # SELECT * FROM person WHERE name LIKE BINARY '%Pi%';
>
> sqlite3's LIKE can be configured with "PRAGMA
> case_sensitive_like=yes".

Is't a way to add .ilike() for case insensitive select?
Anyway .like() for mysql should be adjusted to be case sensitive,
if .ilike() will be implemented.
Is'nt it?


[web2py] pg8000 '%' not supported in quoted string

2012-07-16 Thread KMax
Hello,
 Seems like an issue for me, pg8000 cant insert into db char '%'.
 As a result inserting string = 'We did it for 100%' throw an exception.
 
 '%'' not 
supported in quoted string

 pg8000 checks for '%' in an arguments, so...

Thank you.
--
Maxim


[web2py] Re: pg8000 '%' not supported in quoted string

2012-07-16 Thread KMax
Ок. I will post it here.

вторник, 17 июля 2012 г., 3:36:09 UTC+7 пользователь Derek написал:
>
> So escape it. In Python, % usually refers to a variable that follows the 
> string. If you want a literal percent sign, then you need to double it. %%.
> Seems like gluon is not escaping it properly. If you can post your whole 
> traceback, I could help you to find out what file you need to add the extra 
> escaping.
>
> On Monday, July 16, 2012 4:34:07 AM UTC-7, KMax wrote:
>>
>> Hello,
>>  Seems like an issue for me, pg8000 cant insert into db char '%'.
>>  As a result inserting string = 'We did it for 100%' throw an exception.
>>  
>>  '%'' not 
>> supported in quoted string
>>
>>  pg8000 checks for '%' in an argument, so...
>>
>> Thank you.
>> --
>> Maxim
>>
>

-- 





[web2py] virtual fields book example

2012-09-12 Thread KMax

Hello,
I was looking the book  http://www.web2py.com/books/default/chapter/29/06
And intrested with:

New style virtual fields (experimental)


Create model.db with:

db.define_table('item',
   Field('unit_price','double'),
   Field('quantity','integer'))
db.item.total_price = Field.Virtual(lambda row: row.unit_price*row.quantity)

Open database admin and insert some numbers
but the table view gives only flash with:

'Row' object has no attribute 'unit_price'

and no data.

Please correct my mistake, 
I think I missed something.

Thanks,
Maxim

-- 





[web2py] Re: virtual fields book example

2012-09-12 Thread KMax
Thanks,
That works!

среда, 12 сентября 2012 г., 23:24:01 UTC+7 пользователь Massimo Di Pierro 
написал:
>
> I think it should be
>
> db.item.total_price = Field.Virtual(lambda row: row.item.unit_price*row
> .item.quantity)
>
> This was an experimental feature and it may be wrong in the book.
>
>
> On Wednesday, 12 September 2012 11:21:10 UTC-5, KMax wrote:
>>
>>
>> Hello,
>> I was looking the book  http://www.web2py.com/books/default/chapter/29/06
>> And intrested with:
>>
>> New style virtual fields (experimental)
>>
>>
>> Create model.db with:
>>
>> db.define_table('item',
>>Field('unit_price','double'),
>>Field('quantity','integer'))
>> db.item.total_price = Field.Virtual(lambda row: row.unit_price*row.quantity)
>>
>> Open database admin and insert some numbers
>> but the table view gives only flash with:
>>
>> 'Row' object has no attribute 'unit_price'
>>
>> and no data.
>>
>> Please correct my mistake, 
>> I think I missed something.
>>
>> Thanks,
>> Maxim
>>
>

-- 





[web2py] bug? MSSQL query where date compares - Fails

2012-09-19 Thread KMax
Hello,
 DAL with MSSQL
 Query like:
 db(db.mytable.date>now()).select()
 Gives error:
 ('22007', '[22007] [FreeTDS][SQL 
Server]Conversion failed when converting character string to smalldatetime 
data type. (295) (SQLExecDirectW)')

now() -> translated into:
 '2012-09-19 23:22:56.977817') 

Running select using  '2012-09-19 23:22:56.977817' from MS SQL Studio gives 
same error,
BUT
if I use shorter time:
 '2012-09-19 23:22:56.977')  - this works.

Please let me know how to workaround this?
Search gave nothing useful.

-- 





[web2py] select * from table_name where id IN (1,2,3,4,5,6) Using DAL ?

2012-07-04 Thread KMax
Hello,
 Is any way to query subj with DAL sintax?
 I am using two databases, and I want select from second one few rows 
according to result of select from first database.

 I think this will not work.
db1(db1.tablename.id==db2.tablename.id).select()

Thanks in advance
--
Maxim


Re: [web2py] select * from table_name where id IN (1,2,3,4,5,6) Using DAL ?

2012-07-04 Thread KMax
My goal to do
select * from table_name where id IN (1,2,3,4,5,6)


The sample shows what I need to do. Sure code is invalid.
(1,2,3,4,5,6) - is a list from first DB.

For now I am building in a loop huge where clause
(id =1 ) OR (id=2) OR  OR (id=100500)

среда, 4 июля 2012 г., 17:38:28 UTC+7 пользователь Marin Pranjić написал:
>
> You cannot join tables that are not in the same database.
>
> You can do:
>
> list_of_ids = db1(...).select(db1.tablename.id).as_list()
>
> db2(db2.tablename.id.belongs(list_of_ids)).select()
>
>
> Marin
>
> On Wed, Jul 4, 2012 at 12:28 PM, KMax  wrote:
>
>> Hello,
>>  Is any way to query subj with DAL sintax?
>>  I am using two databases, and I want select from second one few rows 
>> according to result of select from first database.
>>
>>  I think this will not work.
>> db1(db1.tablename.id==db2.tablename.id).select()
>>
>> Thanks in advance
>> --
>> Maxim
>>
>
>

Re: [web2py] select * from table_name where id IN (1,2,3,4,5,6) Using DAL ?

2012-07-04 Thread KMax
*belongs* - indeed!

Thank you all for working samples.

среда, 4 июля 2012 г., 19:53:50 UTC+7 пользователь Anthony написал:
>
> list_of_ids = db1(...).select(db1.tablename.id).as_list()
>>
>
> That will yield a list of dictionaries. Instead, you can do:
>
> list_of_ids = [r.id for r in db1(...).select(db1.tablename.id)]
>
> Anthony
>


[web2py] Re: MS SQL server

2012-11-04 Thread KMax
Have you checked here: 
https://web2py.com/books/
?
1 - not really true.
2 - save as with usuall PK
3 - There are a lot of in the boot and in the other sites noted 
here

суббота, 3 ноября 2012 г., 18:13:17 UTC+7 пользователь Jscriptor09 написал:
>
> Hi
>  
> I am new to web2py and and just recieved Web2Py app dev cookbook.
>  
> Currently I use SQL server a lot.
>  
> Need to creat an app that tab into the MS sql server, a via a user 
> interface, allow the user to review records and update couple of fields in 
> selected records.
>  
> The PK for the DB is compound PK (key is made by combining 3 fields).
>  
> Questions:
> 1- I read that Web2py can only accept or work with DBs that has auto 
> increment PK ... is this correct?
> 2- If one is try, how do folks use web2py to update a DB with a compounf PK
> 3- Is there a sample app or exmaples out there in the nature of the app I 
> need to create.
>  
> Many thanks in advance.
> Mike
>  
>

-- 





[web2py] widgets.checkboxes.widget INPUT inside LABLE

2012-12-20 Thread KMax
Hello,

  Using this widget=SQLFORM.widgets.checkboxes.widget for list of values 
gives the following html code:


Option1


Option2

While if INPUT reside inside LABLE it looks better (imho)

  Option1
 


  Option2


Same time this change might broke some compatibility. Maybe this behavior 
was made for some reason.
Community, please share your opinion.

Thanks,

-- 





[web2py] Re: widgets.checkboxes.widget INPUT inside LABLE

2012-12-24 Thread KMax
checkbox widget has styles divs,ul,table
So may be new style which will give input inside label would work?

Thanks,

пятница, 21 декабря 2012 г., 3:58:00 UTC+7 пользователь Anthony написал:
>
> Good point. It will probably have to depend on the formstyle used.
>
> Anthony
>
> On Thursday, December 20, 2012 1:57:16 PM UTC-5, Paolo Caruccio wrote:
>>
>> For completeness:
>>
>> wrapping the input controls with label should be avoided when for the 
>> layout is used a table. In such case the label goes in one TD and the 
>> associated control in another TD.
>> Bootstrap, indeed, doesn't use table layout for the forms.
>>
>>
>> Il giorno giovedì 20 dicembre 2012 16:50:47 UTC+1, Paolo Caruccio ha 
>> scritto:
>>>
>>> I think as Massimo said, but  W3C raccomandation on 
>>> forms<http://www.w3.org/TR/html5/forms.html#forms>
>>>  tells:
>>>
>>> "To label a control, the label element is used; the label text and the 
>>> control itself go inside the label element."
>>>
>>> So KMax request should be acceptable
>>>
>>>
>>>
>>> Il giorno giovedì 20 dicembre 2012 15:57:03 UTC+1, Massimo Di Pierro ha 
>>> scritto:
>>>>
>>>> I am not convinced this is the right fix. Does bootstrap suggest this? 
>>>> I do not think the input should be in the label. Perhaps there is an 
>>>> alternative fix using css?
>>>>
>>>> On Thursday, 20 December 2012 03:08:01 UTC-6, KMax wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>>   Using this widget=SQLFORM.widgets.checkboxes.widget for list of 
>>>>> values gives the following html code:
>>>>>
>>>>> 
>>>>> Option1
>>>>>
>>>>> 
>>>>> Option2
>>>>>
>>>>> While if INPUT reside inside LABLE it looks better (imho)
>>>>> 
>>>>>  Option1
>>>>>  
>>>>>
>>>>> 
>>>>>  Option2
>>>>> 
>>>>>
>>>>> Same time this change might broke some compatibility. Maybe this 
>>>>> behavior was made for some reason.
>>>>> Community, please share your opinion.
>>>>>
>>>>> Thanks,
>>>>>
>>>>>

-- 





[web2py] Re: Script to generate schema (models) from mysql

2012-02-09 Thread KMax
Hi
I was trying to create model/db.py for RequestTracker mysql schema, and was 
fail.
I found quite good plugin_legacymysql and fixed for my needs 

   - added few types
   - remove 'SET' lines same as remarks
   - mysql data types without params (like text,)
   - import form_factory from sqlhtml

Please find fixed py attached.

Thanks
'''
Create the web2py code needed to access your mysql legacy db.

To make this work all the legacy tables you want to access need to have an "id" field.

This plugin needs:
mysql
mysqldump
installed and globally available.

Under Windows you will probably need to add the mysql executable directory to the PATH variable,
you will also need to modify mysql to mysql.exe and mysqldump to mysqldump.exe below.
Just guessing here :)

Access your tables with:
legacy_db(legacy_db.mytable.id>0).select()

If the script crashes this is might be due to that fact that the data_type_map dictionary below is incomplete.
Please complete it, improve it and continue.

Created by Falko Krause
'''
from gluon.sqlhtml  import form_factory
import subprocess
import re
data_type_map = dict(
varchar = 'string',
int = 'integer',
tinyint = 'integer',
smallint = 'integer',
mediumint = 'integer',
binary = 'text',
varbinary = 'text',
text = 'text',
longtext = 'text',
date = 'date',
float = 'double',
char = 'string',
decimal = 'integer',
timestamp = 'datetime',
datetime = 'datetime',
blob = 'text',
longblob = 'text',
	)

def index():
table2sql = ''
if not request.vars.database_name:
form = form_factory(
Field('database_name', requires = IS_NOT_EMPTY()),
Field('user_name', requires = IS_NOT_EMPTY()),
Field('password', requires = IS_NOT_EMPTY()),
)
else:
p = subprocess.Popen(['mysql','--user=%s'%request.vars.user_name, '--password=%s'%request.vars.password, '--execute=show tables;', request.vars.database_name],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
sql_showtables, stderr = p.communicate()
form = form_factory(
Field('database_name', requires = IS_NOT_EMPTY(), default = request.vars.database_name),
Field('user_name', requires = IS_NOT_EMPTY(), default = request.vars.user_name),
Field('password', requires = IS_NOT_EMPTY(), default = request.vars.password),
Field('write_to', default = 'db_legacymysql.py', requires = IS_NOT_EMPTY()),
Field('write', 'boolean', default = False),
Field('tables', requires = IS_IN_SET([re.sub('\|\s+([^\|*])\s+.*', '\1', x) for x in sql_showtables.split()[1:]], multiple = True)),
)
if form.accepts(request.vars, session, keepvalues = True):
#
#get a list of tables that should be copied
connection_string = "legacy_db = DAL('mysql://%s:%s@localhost/%s')"%(form.vars.user_name, form.vars.password, form.vars.database_name)
table2sql = {'connection string': CODE(connection_string)}
legacy_db_table_web2py_code = []
for table_name in form.vars.tables:
#
#get the sql create statement
p = subprocess.Popen(['mysqldump','--user=%s'%form.vars.user_name, '--password=%s'%form.vars.password, '--skip-add-drop-table', '--no-data', form.vars.database_name, table_name],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
sql_create_stmnt,stderr = p.communicate()
if stderr:
table2sql[table_name] = stderr
if 'CREATE' in sql_create_stmnt:#check if the table exists
#table2sql[table_name] = stdout if stdout else stderr #DEBUG
#
#remove garbage lines from sql statement
sql_lines = sql_create_stmnt.split('\n') 
sql_lines = [x for x in sql_lines if not(x.startswith('--') or x.startswith('/*') or x =='' or x.startswith('SET'))]
table2sql[table_name] = XML(''.join(sql_lines) ) #DEBUG
#generate the web2py code from the create statement
web2py_table_code = ''
table_name = re.search('CREATE TABLE .(\S+). \(', sql_lines[0]).group(1)
fields = []
for line in sql_lines[1:-1]:
if re.search('KEY', line) or re.search('PRIMARY', line) or re.search(' ID', line) or line.startswith(')'):
continue
hit = re.search('(\S+) (\S+) .*', re.sub(',',' ',line))
name, d_type = hit.group(1), hit.group(2)
 

[web2py] Re: Subdomain based on blog users in routes.py

2011-10-01 Thread KMax
Have you looked in apache2/nginx redirect engine?

On 2 окт, 05:23, Jonathan Lundell  wrote:
> On Oct 1, 2011, at 3:13 PM, Jonathan Lundell wrote:
>
> > On Oct 1, 2011, at 2:13 PM, Farsheed Ashouri wrote:
>
> >> I think i have no problem with DNS. cause i put a * value in subdomain 
> >> setting of DNS and now i have access to any sub-domain i want.
> >> So you say there is no way to solve this in routes.py?
>
> > With the regex mode, perhaps.
>
> On second thought, I *think* that the regex router doesn't give you access to 
> the query string. So you might have to make the user part of the arg string 
> (part of the URL path) in order for the router to work for you.


[web2py] xml view of dict() with attributes

2011-10-23 Thread KMax
Hello,
  Please help with exporting some dict to .xml view with attributes
inside tags.

Like:




   Title
   Value


I am talking about "hello='world'" in the itemtitle tag.
I know, I could do it with TAG, but how to make it using regular
dict() return?
i mean:
def myxml():
return dict(itemtitle='Title',itemvalue='Value)

I fail tring to get it works with attribute inside the tag.

Any Ideas?

Thanks in advance.
--
Maxim Kostrikin


[web2py] Re: xml view of dict() with attributes

2011-10-23 Thread KMax
So, with return dict() and generic.xml view is impossible to produce
attribute in a xml tag?
Just to stop looking in this way for solution.

Thanks Massimo.

On 23 окт, 22:53, Massimo Di Pierro 
wrote:
> You can make a myxml.html view that contains:
>
> 
> 
>    {{=itemtitle}}
>    {{=itemvalue}}
> 
>
> On Oct 23, 5:09 am, KMax  wrote:
>
> > Hello,
> >   Please help with exporting some dict to .xml view with attributes
> > inside tags.
>
> > Like:
>
> > 
> > 
> >    Title
> >    Value
> > 
>
> > I am talking about "hello='world'" in the itemtitle tag.
> > I know, I could do it with TAG, but how to make it using regular
> > dict() return?
> > i mean:
> > def myxml():
> >     return dict(itemtitle='Title',itemvalue='Value)
>
> > I fail tring to get it works with attribute inside the tag.
>
> > Any Ideas?
>
> > Thanks in advance.
> > --
> > Maxim Kostrikin


[web2py] Re: xml view of dict() with attributes

2011-10-24 Thread KMax
my solution:

def myxml():
..
return '' +
str(TAG.response(TAG.result('0'),
*[TAG[parameter](request.get_vars[parameter])
for parameter in request.get_vars]))

So, anyone could customize it on their needs.

Thanks Massimo.

On 24 окт, 21:15, Massimo Di Pierro 
wrote:
> Yes. You need to implement your own XML serializer. You can use
> helpers too for this purpose. It really depends on how your output
> should look like.
>
> On Oct 23, 11:07 pm, KMax  wrote:
>
>
>
>
>
>
>
> > So, with return dict() and generic.xml view is impossible to produce
> > attribute in a xml tag?
> > Just to stop looking in this way for solution.
>
> > Thanks Massimo.
>
> > On 23 ÏËÔ, 22:53, Massimo Di Pierro 
> > wrote:
>
> > > You can make a myxml.html view that contains:
>
> > > 
> > > 
> > > š š{{=itemtitle}}
> > > š š{{=itemvalue}}
> > > 
>
> > > On Oct 23, 5:09šam, KMax  wrote:
>
> > > > Hello,
> > > > š Please help with exporting some dict to .xml view with attributes
> > > > inside tags.
>
> > > > Like:
>
> > > > 
> > > > 
> > > > š šTitle
> > > > š šValue
> > > > 
>
> > > > I am talking about "hello='world'" in the itemtitle tag.
> > > > I know, I could do it with TAG, but how to make it using regular
> > > > dict() return?
> > > > i mean:
> > > > def myxml():
> > > > š š return dict(itemtitle='Title',itemvalue='Value)
>
> > > > I fail tring to get it works with attribute inside the tag.
>
> > > > Any Ideas?
>
> > > > Thanks in advance.
> > > > --
> > > > Maxim Kostrikin


[web2py] Re: xml view of dict() with attributes

2011-10-25 Thread KMax
I am sure for complicated response lxml is the best. But for simple
response is TAG.

On 24 окт, 23:16, Richard Vézina  wrote:
> lxml is pretty nice lib for the task...
>
> Richard
>
> On Mon, Oct 24, 2011 at 11:57 AM, KMax  wrote:
> > my solution:
>
> > def myxml():
> >    ..
> >    return '' +
> > str(TAG.response(TAG.result('0'),
> >                        *[TAG[parameter](request.get_vars[parameter])
> > for parameter in request.get_vars]))
>
> > So, anyone could customize it on their needs.
>
> > Thanks Massimo.
>
> > On 24 окт, 21:15, Massimo Di Pierro 
> > wrote:
> > > Yes. You need to implement your own XML serializer. You can use
> > > helpers too for this purpose. It really depends on how your output
> > > should look like.
>
> > > On Oct 23, 11:07 pm, KMax  wrote:
>
> > > > So, with return dict() and generic.xml view is impossible to produce
> > > > attribute in a xml tag?
> > > > Just to stop looking in this way for solution.
>
> > > > Thanks Massimo.
>
> > > > On 23 ÏËÔ, 22:53, Massimo Di Pierro 
> > > > wrote:
>
> > > > > You can make a myxml.html view that contains:
>
> > > > > 
> > > > > 
> > > > > š š{{=itemtitle}}
> > > > > š š{{=itemvalue}}
> > > > > 
>
> > > > > On Oct 23, 5:09šam, KMax  wrote:
>
> > > > > > Hello,
> > > > > > š Please help with exporting some dict to .xml view with attributes
> > > > > > inside tags.
>
> > > > > > Like:
>
> > > > > > 
> > > > > > 
> > > > > > š šTitle
> > > > > > š šValue
> > > > > > 
>
> > > > > > I am talking about "hello='world'" in the itemtitle tag.
> > > > > > I know, I could do it with TAG, but how to make it using regular
> > > > > > dict() return?
> > > > > > i mean:
> > > > > > def myxml():
> > > > > > š š return dict(itemtitle='Title',itemvalue='Value)
>
> > > > > > I fail tring to get it works with attribute inside the tag.
>
> > > > > > Any Ideas?
>
> > > > > > Thanks in advance.
> > > > > > --
> > > > > > Maxim Kostrikin


[web2py] Re: app slow to death (sorry double post because empyt object)

2011-12-01 Thread KMax
How you have tested the load?
What is your CPU/RAM ?
How did you configure tread/process of wsgi ?

I have a case when all slow down was on .first() or .last() ofter db
was populated

On 1 дек, 22:44, Richard Vézina  wrote:
> Use top, iotop, itop and screen so I can switch between those top...
>
> I tried what preibt suggest on other thread (same thread double post one
> without object) and replace Apache and wsgi by nginx and uwsgi... No much
> difference and still the 45% 100%... But it sometime goes over 45%. For
> those second test I had a dev virtual machine with 2 cpu (only have 1 cpu
> the first time on staging vm).
>
> I read the scale section in the book and there is many thing I can try...
> For now I will try to refactor my app since it seems to come from there. I
> have long models and controller files so I will try to split them off a bit
> to see if I can improve speed this way.
>
> Thanks for help Chris!
>
> Richard
>
> On Wed, Nov 30, 2011 at 10:27 PM, Christopher Steel
> wrote:
>
>
>
>
>
>
>
> > That sound peculiar Richard. Could we get a little more info on your load
> > test? Where are you getting the 45% and 100% figures from, the Gnome
> > monitoring applet? If it is an app you can share, I could try the same
> > setup on a similar system for you.
>
> > Chris


[web2py] Re: Returning the Row after insert;

2011-02-01 Thread KMax
Actualy do the same action, but select allow to choose columns

On 1 фев, 05:36, Vasile Ermicioi  wrote:
> db(db.auth_user.id=id).select() will give you a list of rows (of one element
> :) )
>
> easier is
>
> row = db.auth_user[form.vars.id]


[web2py] Re: Support for Drizzle in web2py

2011-02-02 Thread KMax

http://wiki.drizzle.org/FAQ
Can I run a website with this?
No. We are still making incompatible changes, and certainly do not
believe the code is production quality. Right now we are defaulting
many configure operations to generate debugging code for us so our
binaries are not optimal. Therefore, do not go out and benchmark this
and expect it to be one way or the other. We are currently only doing
benchmarks where it makes sense for us to determine where bottlenecks
are.


On 2 фев, 11:57, Rahul  wrote:
> Hi All,
>        http://drizzle.org/Home.html
>        Not really sure if web2py should support Drizzle (opensource
> MYSQL forked Database). Will pymysql work with Drizzle? What do you
> think? Also is MySQL free for professional development now? or we need
> to pay a fee. Oracle - MySQL site does show us license fees etc.
>
> Rahul


[web2py] Re: Mixing/supporting CMS with Web2py

2011-02-02 Thread KMax
Once I have idea for seamless moving from joomla for web2py.
Stoped on attaching to joomla users table and joomla coocke of
loggined in.

Maing goal was to use links in joomla site to web2py functions which
should use user auth from joomla.
And with several steps move completely to web2py or share functions
along two application (joomla and web2py part)

On 2 фев, 18:46, Carl  wrote:
> has anyone direct experience of using Wordpress, SquareSpace or
> similar solution alongside Web2py?
>
> These solutions appeal for their maturity and I'd like to use one to
> do the "donkey" work and fall back to Web2py to do my site's specific
> functionality.
>
> Without them I feel like I'm reinventing needlessly.


[web2py] Re: LIKE case sensitivity: Postgres differs to MySQL => DAL not portable

2011-02-04 Thread KMax
On 29 янв, 04:53, Thadeus Burgess  wrote:
> IMHO This breaks backwards compatibility...
If .like() should match case-insensitive then this is bug fix.

At http://web2py.com/book/ this does not specified explicitly.

PS. .ilike for case insensitive? I think the question is, to make it
available for all supported databases.


[web2py] Re: drop support for python 2.4?

2011-02-11 Thread KMax
Just make Latest python2.4 compatible web2py_src.zip
What something new, upgrade python, hosting or something else.
If not, use lastest web2py_src for 2.4

Reasonable?

On 5 фев, 02:37, Massimo Di Pierro  wrote:
> @web2py-developers we have discussing the possibility of dropping
> support for Python 2.4. So far we have put a great effor t in having
> web2py run on 2.4 because this is the default python version on CentOS
> for shared hosts. Yet by dropping support we could improve the code
> base, make it more readable and expose new syntax to users.
>
> Who strongly opposes? Make your case.


[web2py] Re: mod_pagespeed

2011-02-15 Thread KMax
Does not use it. But read 
http://code.google.com/intl/ru-RU/speed/page-speed/docs/module.html
Resolution, this module used to optimize traffic (fix me) by filtering
out useless spaces, and etc.
This does not speed up web2py any kind, due to it works with generated
htmls.
This job do gzip module very well.

IMHO, this module does not give any visible speed gains for web2py
application.

Caching definately will give much more effect.

On 14 фев, 02:06, "ma...@rockiger.com" 
wrote:
> Did somebody of you guys ever uses the mod_pagespeed for Apache?
>
> Did it work well with web2py? How were the speed gains?


[web2py] Re: VirtualFields are really slow with large datasets

2011-02-16 Thread KMax
I guess, virtualfield items gets their value by dedicated select,
which give so much overheat.


[web2py] Re: Async http request in web2py

2011-02-18 Thread KMax
asynchronous http and synchronous http
What the difference ?
On 18 фев, 10:37, Dane  wrote:
> Hi,
>
> I need to make an asynchronous http request to one of my controller
> functions in order to some lightweight background processing
> (refreshing some cached objects). I came upon this thread:
>
> http://groups.google.com/group/web2py/browse_thread/thread/bbe66f1084...
>
> But the link to the "lola" function posted post by Massimo is broken.
> Can anyone supply a new link or explain a simple way to make async,
> ajax-like requests from within web2py? Thanks.
>
> -Dane


  1   2   >