[web2py] Re: a couple of related questions

2011-10-23 Thread ニコノコ
Even if I'm logged in, I couldn't view a record when I click the
parent record. The parent field is a clickable representation viewable
in a grid.

re [2]
the relevant portion is the links parameter where I create a new
button. I want to create an icon for that button.


On Oct 23, 12:53 pm, Massimo Di Pierro 
wrote:
> About [1] the user_signature=True is default but the signature only
> works if you are logged in.
>
> I do not understand [2]
>
> On Oct 20, 9:40 pm, niknok  wrote:
>
>
>
>
>
>
>
> > I have a person table[1] with a parent field with a clickable
> > representation view of the record. If I put this on a grid and click on
> > the link, I get a "not authorized" error message. I thought I need to
> > pass the signature so I can make it viewable. (This works fine if
> > parameter user_signature=False)
>
> > Also, I have defined a default representation for the person table but
> > in my validation statement, note that I had to specify the same format
> > again. I'm wondering if there's a way to tell the validator to use the
> > default representation of the person (which I thought was web2py's
> > default behavior.)
>
> > In my grid, I specified a new button [2] in the links parameter, how do
> > I specificy an icon for this button? For example I want to use what's
> > already in base.css (book, heart, cross etc.)
>
> > /r
> > Nik
>
> > [1]
> > db.define_table('person'
> >                 ,Field('birth_date', 'date', requires=IS_DATE())
> >                 ,Field('last_name', notnull=True)
> >                 ,Field('given_name', notnull=True)
> >                 ,Field('parent', 'list:reference person'
> >                                 ,requires=IS_EMPTY_OR(IS_IN_DB(db, 
> > 'person.id'
> >                                               ,'%(last_name)s,
> > %(given_name)s [%(birth_date)s]'
> >                                               ,multiple=True
> >                                               ,zero=T('pick one')))
> >                                 ,represent =  lambda value, row: [A(' ▸'+
> > db.person[v].given_name , _href = URL('index/view/person', args=[v]))
> > for v in value])
> >                 ,auth.signature
> >                 ,format='%(last_name)s, %(given_name)s [%(birth_date)s]'
> >                 )
>
> > [2]
> >  form=SQLFORM.grid( db.person
> >                       ,fields=[db.person.id, db.person.last_name,
> > db.person.given_name
> >                                     ,db.person.middle_name,
> > db.person.gender, db.person.birth_date, db.person.parent]
> >                       ,showbuttontext=False
> >                       ,sorter_icons=('[▴]','[▾]')
> >                       ,onvalidation=person_processing
> >                       ,links = [lambda row: A('X',
> > _href=URL(args=["view", db.person, row.id] ))]
> >                       )


[web2py] Re: web2py on GAE and supplementary package usage

2011-10-23 Thread Minocha
Thanks alot :)

On Oct 16, 12:54 am, Massimo Di Pierro 
wrote:
> You should not use local_import. It is deprecated and anyway not
> designed for this.
>
> Just put the packages in site-packages, and use normal import. site-
> packages is in sys.path.
>
> On Oct 15, 8:54 pm, Minocha  wrote:
>
>
>
>
>
>
>
> > I used the local_import function after copy-pasting the module
> > directory into the [application-name]/packages/ folder but even then i
> > get an error.
> > Please help
>
> > On Oct 15, 4:57 pm, Minocha  wrote:
>
> > > i'm new in deploying applications on the GAE using the web2py.
> > > I wanted to ask what is the procedure to make available external
> > > libraries for python controllers in web2py on platforms - GAE and also
> > > on external server where i would like to host a website.


[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] Minor Cosmetic Issue

2011-10-23 Thread horridohobbyist
This is a minor cosmetic issue, but cosmetics do matter in a
professional/commercial website. The login nav looks like this after
login:

Welcome Richard [ logout | profile | password]

There should be a space between 'password' and ']', just as there is a
space between 'lost password?' and ']'.

I can't correct this because I don't have access to the core source
code in my web2py installation.

Richard


Re: [web2py][GAE]BadValueError: Incomplete key found for reference property

2011-10-23 Thread Phyo Arkar
any idea?

On 10/23/11, Phyo Arkar  wrote:
> I am using 1.98.2
>
> here is my model :
>
> db.define_table("item",
>   SQLField("name", "text", length=512, notnull=True, default=None),
>   SQLField("base_price", "integer", notnull=True, default=None),
>   SQLField("price", "integer", notnull=True, default=None)
>   )
>
>
> """
> Table definition
> """
> from datetime import date
> import time
>
> db.define_table("sale",
>   SQLField("id_items", db.item),
>   SQLField("date", "date", notnull=True, default=date.today()),
>   SQLField("sale_time", "datetime", notnull=True, default=request.now),
>   SQLField("total_items", "integer", notnull=True, default=None),
>   SQLField("description", "text", notnull=False, default=None))
>
> On Sun, Oct 23, 2011 at 5:43 AM, howesc  wrote:
>
>> what's the model?
>>
>> what version of web2py are you using?
>>
>


Re: [web2py] Re: Qooxdoo + Web2py Based AJAX POS system, Released!

2011-10-23 Thread Phyo Arkar
Hello Massimo!

the demo is now avaliable at :

http://herspos.appspot.com/HersPOS

On GAE tho , joining tables not working so the main table , Sales
table having error with Too many Tables selected.

Can you show me how can i fix it?

I am totally new to GAE.
Thanks,

Phyo.
On 10/20/11, Massimo Di Pierro  wrote:
>
> Where can we see it in action?
>
> On Oct 19, 5:24 pm, Phyo Arkar  wrote:
>> Hello Web2py.
>>
>> As a practice for integrating Qooxdoo and web2py. I had created a
>> Point of Sales system for my wife's sushi shop.
>>
>> All people who have trouble integrating Qooxdoo, can base on my code.
>> It used multiple Qooxdoo features .
>>
>> - Tables
>> - Folder Trees
>> - Events
>> - Event Bubbling
>> - Delegates
>> - Custom Class
>> - AJAX
>> - Datastore and controllers
>> - Remote Table
>>
>> Now i decided to release it as opensource. Please check :
>>
>> http://code.google.com/p/herspos/
>> ---
>>
>> HersPOS
>>
>> Web2py + Qooxdoo based resturant POS . Feel feel to use and contribute!
>> Started for my wife's Sushi Restaurant, and as a practice for Qooxdoo
>> framework , integrating with web2py.Now avaliable for everyone.This
>> project is not completed yet, but mostly functional.
>>
>> Features :
>>
>> - Full application UI powered by Qooxdoo
>>
>> - AJAX View of item records using Qooxdoo table.
>>
>> - AJAX View of sales records.
>>
>> - Add new sales record.
>>
>> - Add new items.
>>
>> - Totals summary.
>>
>> Todo :
>>
>> - Sorting
>>
>> - Filter by date (Clicking on left tree)
>>
>> - Filtering by items (Clicking on left tree)
>>
>> - Editing records


[web2py] Re: HersPOS - New Version released 0.03 Web2py + Qooxdoo POS

2011-10-23 Thread Phyo Arkar
i also released w2p appliance , can you guys check it out if it works or not?

Please note if you install w2p appliance application name needs to be
changed to HersPOS (Case Sensitive)

Thanks.

Phyo.

On 10/23/11, Phyo Arkar  wrote:
> Link : http://code.google.com/p/herspos
> Demo : http://herspos.appspot.com/HersPOS
>
> On 10/23/11, Phyo Arkar  wrote:
>> New Features :
>>
>> -FIltering by date
>> -Added tabs and seperated items tables / Sales table.
>> -Demo avaliable on Gae , partially workling (No Sales Table working
>> but Item table works).
>> Due to no join avaliable , please suggest me a work around.
>>
>> Thanks
>>
>> Phyo.
>>
>


[web2py] Re: DAL total record count

2011-10-23 Thread lucas
thank you to both of you. i am learning this stuff and i always have
to start at the base.  lucas


[web2py] Re: Minor Cosmetic Issue

2011-10-23 Thread horridohobbyist
I'm using the latest stable version, 1.99.2.

R

On Oct 23, 9:17 am, Anthony  wrote:
> What version are you using? I think this has been fixed.


[web2py] Re: Minor Cosmetic Issue

2011-10-23 Thread Anthony
What version are you using? I think this has been fixed.

[web2py] Re: Web2py and Rest

2011-10-23 Thread Anthony
This will be in the updated book soon, but for now:
http://www.reddit.com/r/programming/comments/g5hxq/web2py_trunk_has_a_new_restful_api_that_writes_db/c1l2ykg
http://vimeo.com/21133657

On Friday, October 21, 2011 3:53:34 PM UTC-4, BrendanC wrote:
>
> I know this has probably come up before, but I'd like to get my head around 
> the options to use Restful URLs with Web2py.  
>
> Are there any (recent) docs I can reference? I know there are some old 
> threads, but would like to get an idea where things stand currently.
>
> (BTW - I'm not totally sold on rest, but restful url design seems to have 
> captured a lot of mindshare with developers (possibly due to rails support) 
> and seems to be a potential issue when choosing a webframework for a new 
> project. 
>
> Maybe this is something that could be added to the faq. 
>
> Brendan
>
>
>
>
>

[web2py] Re: Minor Cosmetic Issue

2011-10-23 Thread Anthony
I see -- the pre-login navbar was fixed, but still a missing space in the 
post-login version. I submitted a patch to fix it.

Anthony

On Sunday, October 23, 2011 9:19:49 AM UTC-4, horridohobbyist wrote:
>
> I'm using the latest stable version, 1.99.2. 
>
> R 
>
> On Oct 23, 9:17 am, Anthony  wrote: 
> > What version are you using? I think this has been fixed.



[web2py] auth_user

2011-10-23 Thread lucas
hello one and all,

playing with auth_user.  trying to follow the manual with a bit of
modification, thinking:

auth = Auth(db)# authentication/
authorization
auth.settings.extra_fields['auth_user'] = [
Field('prefix_title', length=12, comment='Enter your Name
Prefix'),
Field('professional_title', length=12, comment='if you have one,
Enter your Professinal Title'),
Field('mailing_address', length=1024, comment='Full Mailing
Address including Street, City, State, Zip/Postal, and Country'),
Field('Telephone', length=32, comment='include Area Code or
Country Code if outside the USA')]
db.auth_user.prefix_title.requires =
IS_IN_SET(('Mr.','Ms.','Mrs.','Dr.','Rev.','Hon.'))
db.auth_user.professional_title.requires =
IS_IN_SET(('','Ph.D.','M.D.','Ed.D.','M.B.A.','C.P.A.','P.A.','M.S.','M.A.'))
auth.define_tables()

but the bottom two requires to fill the lists are bugging out.
suggestions on this modify?  i don't need a custom auth_user so that
is why i am trying to modify the default one.

also, i would like to change to field order.  how can i do that also?

thank you in advance and have a great day.  lucas


Re: [web2py] web3py & lifetime of web2py

2011-10-23 Thread Ovidio Marinho
  I believe that there will be versions of web2py with python 3, so far the
project had been with python web2py 2.xx. There is nothing to fear as the
founder of Masimonot discontinue web2py.


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



2011/10/23 Gour 

> There is some talk that web3py will probably become 'new' product and
> not just python-3 upgrade.
>
> Otoh, I'm considering to buy paperback versions of Web2py's 4th ed as well
> as
> the upcoming Packt book, but wonder how much would the skills acquired by
> learning web2py be relevant for web3py, iow, what is the estimated lifetime
> for
> web2py before some important work on web3py is underwent?
>
>
> Sincerely,
> Gour
>
>
> --
> In the material world, one who is unaffected by whatever good
> or evil he may obtain, neither praising it nor despising it,
> is firmly fixed in perfect knowledge.
>
> http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810
>


[web2py] Re: auth_user

2011-10-23 Thread Anthony
On Sunday, October 23, 2011 9:33:34 AM UTC-4, lucas wrote:
>
> hello one and all, 
>
> playing with auth_user.  trying to follow the manual with a bit of 
> modification, thinking: 
>
> auth = Auth(db)# authentication/ 
> authorization 
> auth.settings.extra_fields['auth_user'] = [ 
> Field('prefix_title', length=12, comment='Enter your Name 
> Prefix'), 
> Field('professional_title', length=12, comment='if you have one, 
> Enter your Professinal Title'), 
> Field('mailing_address', length=1024, comment='Full Mailing 
> Address including Street, City, State, Zip/Postal, and Country'), 
> Field('Telephone', length=32, comment='include Area Code or 
> Country Code if outside the USA')] 
> db.auth_user.prefix_title.requires = 
> IS_IN_SET(('Mr.','Ms.','Mrs.','Dr.','Rev.','Hon.')) 
> db.auth_user.professional_title.requires = 
> IS_IN_SET(('','Ph.D.','M.D.','Ed.D.','M.B.A.','C.P.A.','P.A.','M.S.','M.A.')) 
>
> auth.define_tables() 
>
> but the bottom two requires to fill the lists are bugging out. 
> suggestions on this modify?


The auth_user table doesn't exist until you call auth.define_tables(), so 
either move the 'requires' into the Field() definitions, or move those lines 
after auth.define_tables():

Field('prefix_title', ..., requires=IS_IN_SET(...))

also, i would like to change to field order.  how can i do that also? 
>

I don't think you can do that (easily) without defining the whole table from 
scratch. If you just want to control the display of the registration/profile 
forms, you can create custom forms and specify the order of the fields 
however you want.

Anthony



[web2py] web2py crud and dealing with input

2011-10-23 Thread Jimmy Stewpot
Hello,

I am new to web2py. I just started a new app to become more familiar
with the technology. So far I have the following.

# controller
def index():
form, rows = crud.select(db.domains,
query=(db.domains.created_by==auth.user_id))
return dict(rows=rows)

# view
{{extend 'layout.html'}}
Manage your domain names
[ {{=A('search', _href=URL('search'))}} ]
{{response.write(rows)}}
{{for name in rows:}}
 {{=LI(A(name[1], _href=URL('domain_show', args=name[4])))}}
{{pass}}
[ {{=A('create domain', _href=URL('domain_add'))}} ]


The problem is that it dynamically generates the args=name[4] as 
name[4] . in the browser.

I've been so far unable to find any tidy was so that I can only show
the domains for the particular user and pass those variables around to
show, edit, delete etc.

As an example here is what I have in my domain_show controller

@auth.requires_login()
def domain_show():
 "shows a domain name"
 domain_name = db.domains(request.args(0),created_by=auth.user_id)
or redirect(URL('index'))
 db.domains.id.default = domain_name.id
 form = crud.create(db.domains) if auth.user else None
 return dict(domain_name=domain_name, form=form)

and the view

{{extend 'layout.html'}}
{{=domain_name.name}}
{{=form}}

I would love to know if there is a better way to do this stuff. Any
advice would be really appreciated.

Regards,

Jimmy.




[web2py] Re: auth_user

2011-10-23 Thread lucas
yes, putting the requires under the field worked great, thanx.

well, i tried to just change the natural/ordinal order of the columns/
fields in the database (postgresql in my case) but that didn't work.

how can i direct the register/profile of auth to another view and how
do i customize that view?

thanx in advance, lucas


[web2py] Re: Looking for people to help test web2py support in New Relic.

2011-10-23 Thread Massimo Di Pierro
Hello Graham,

This is exciting. Hope other users can jump in and help more.

It think what you may be looking for is in

   {{=response.toolbar}}

which displays among other things:

   db._timings

This variable stores each SQL query and the time in seconds to
completion.

Massimo


On Oct 21, 8:34 pm, Graham Dumpleton 
wrote:
> I tweeted about this already recently, but got no response.
>
> I am looking for people who want to take the opportunity while New
> Relic Python agent is in beta, to test out the web2py support we
> provide. I had someone try a long long time back but we had issues. We
> worked out since then that it was likely a uWSGI issue, but haven't
> had anyone step up since who was interested in using New Relic with
> web2py.
>
> For those those who don't know what New Relic is, it is a production
> web application performance monitoring system. The easiest way to see
> what it can do is browser through New Relic page at:
>
>  http://newrelic.com/features/performance-analytics
>
> I have though also stuck up some specific screen shots of what a
> web2py application being monitored by it using our Python agent looks
> like at:
>
>  http://dl.dropbox.com/u/22571016/FirefoxScreenSnapz004.gif
>  http://dl.dropbox.com/u/22571016/FirefoxScreenSnapz005.gif
>  http://dl.dropbox.com/u/22571016/FirefoxScreenSnapz006.gif
>  http://dl.dropbox.com/u/22571016/FirefoxScreenSnapz007.gif
>
> If you have ever used Django debug toolbar, it has overlapping
> features, but with the big difference being that New Relic can be
> deployed to your production application where as Django debug toolbar
> is for development systems only.
>
> Would be really nice to get the support for web2py checked out by
> actual users of web2py and to work out what would be better things to
> track or what else we can provide so we can include this with the
> product when fully launched.
>
> Right now we don't for example track time in DAL except as may be
> picked up if running on top of a database such as PostgreSQL, MySQL or
> SQLite. So don't see database breakout when DAL just using file
> system. Also still need to work out what is required in web2py to
> support end user monitoring support. Finally, not showing any
> structure within templates either such as template blocks, within
> transaction traces. As an example of what we could do there, have a
> look at what we currently do for Django at:
>
>  http://dl.dropbox.com/u/22571016/SafariScreenSnapz094.gif
>
> The roadblock for adding more support is simply don't understand the
> web2py internals enough to know where should monkey patch in to get
> what we need.
>
> Hopefully some of you will be interested in what we are doing and will
> be interested in participating. I would also like to hope my prior
> work in writing Apache/mod_wsgi puts me in good enough standing such
> that you might at least give New Relic at least a quick once over to
> learn what it is about. I know I am excited on working on this stuff
> as it brings something to the Python web community which simply
> doesn't exist and could be so beneficial to those who are serious
> about wanting to deploy a well run production web site.
>
> Just for the record. New Relic is a paid subscription service. For
> access to all features will therefore cost money. When you signup and
> deploy it you will get an initial Pro trial period of all features.
> When that finishes it drops back to free Lite subscription level which
> still gives you access to lots of useful features at no cost.
>
> For more information on the Python agent for New Relic see:
>
>  https://support.newrelic.com/help/kb/python/new-relic-for-python
>  https://support.newrelic.com/help/kb/python/python-agent-and-web2py
>
> The Python agent package for New Relic is available via the Python
> package index or from New Relic site once you have created your
> account.
>
> I monitor new deployments so will keep an eye out for anyone deploying
> with web2py. If you have problems you can create a ticket at:
>
>  http://support.newrelic.com
>
> and I will get back to you.
>
> Feedback almost most welcome. Would be good to try and get the level
> of support for we2py up to the same sort of depth as we do for Django
> but really need your help to get it there.
>
> Thanks.
>
> Graham Dumpleton


[web2py] Re: Alternative to Transactions

2011-10-23 Thread Massimo Di Pierro
If you run on GAE you need to explicitly  import and call
run_in_transactions if you want to use GAE transactions.

On Oct 21, 10:56 pm, Sathvik Ponangi  wrote:
> Hello,
>
>  I'm using web2py on Google AppEngine (SDK v1.5.5) and I'm trying to port a
> script here which uses 'transactions'.
> In what way can I effectively emulate *db.run_in_transaction(func1, params)*
> * *on Web2py?
> Will I need to manually run that function (func1) every-time I update the
> database?
> Thank you in advance.
>
> With Regards,
> Sathvik
>
> --
> Sathvik Ponangi


[web2py] Re: CouchDB & NoSQLAdapter.represent for datetime

2011-10-23 Thread Massimo Di Pierro
This is very helpful. I was expecting this problem. How are datetimes
supposed to be stores in CouchDB?

On Oct 22, 3:13 am, "H.C. v. Stockhausen"  wrote:
> Hi
>
> I am just testing the CouchDB Adapter and it fails when registering a
> new user. I tired both w2py's default auth and janrain. The problem
> appears to be the time_stamp field.
>
> - w2py Version 1.99.2 (2011-09-26 06:55:33) stable
> - driver CouchDB-0.8-py2.6.egg
>
> Traceback
> 
>   File "/home/hcvst/web2py/gluon/dal.py", line 3510, in insert
>     ctable.save(values)
>   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> couchdb/client.py", line 407, in save
>     _, _, data = func(body=doc, **options)
>   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> couchdb/http.py", line 405, in put_json
>     status, headers, data = self.put(*a, **k)
>   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> couchdb/http.py", line 384, in put
>     return self._request('PUT', path, body=body, headers=headers,
> **params)
>   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> couchdb/http.py", line 419, in _request
>     credentials=self.credentials)
>   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> couchdb/http.py", line 239, in request
>     resp = _try_request_with_retries(iter(self.retry_delays))
>   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> couchdb/http.py", line 196, in _try_request_with_retries
>     return _try_request()
>   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> couchdb/http.py", line 222, in _try_request
>     chunk = body.read(CHUNK_SIZE)
> AttributeError: 'dict' object has no attribute 'read'
>
> DAL CODE (dal.py at line 3510)
> =
> def insert(self,table,fields):
>         id = uuid2int(web2py_uuid())
>         ctable = self.connection[table._tablename]
>         values = dict((k.name,NoSQLAdapter.represent(self,v,k.type))
> for k,v in fields)
>         values['_id'] = str(id)
>         ctable.save(values) # line 3510
>
> DRIVER CODE (..egg/couchdb/http.py in _try_request at line 222)
> 
>                 if body is not None:
>                     if isinstance(body, str):
>                         conn.sock.sendall(body)
>                     else: # assume a file-like object and send in
> chunks
>                         while 1:
>                             chunk = body.read(CHUNK_SIZE) # line 222
>
> BODY VARIABLE
> ==
> {'_id': '156782505411822007491552899341462059095', 'client_ip':
> u'127.0.0.1', 'description': u'Group
> 128304130898558275345572010972780625739 created', 'origin': u'auth',
> 'time_stamp': datetime.datetime(2011, 10, 22, 3, 48, 48, 413381),
> 'user_id': None}
>
> The problem is probably that the BODY time_stamp attribute of type
> datetime cannot be JSON serialized but I don't know dal.py well enough
> to say what NoSQLAdapter.represent should return.
>
> Best regards,
> HC


[web2py] Re: dal aggregation sum fields None

2011-10-23 Thread Massimo Di Pierro
lines[cash_price]=lines(cash_price) or 0 

On Oct 22, 7:50 am, Anthony  wrote:
> On Saturday, October 22, 2011 7:47:08 AM UTC-4, apple wrote:
>
> > I am summing some data using the DAL:
> >       cash_price = db.orderline.cash_price.sum()
> >       lines = db(db.orderline.order_ == id).select(cash_price).first()
>
> > However if there are no lines then lines[cash_price] is "None". So I
> > added:
> >        lines[cash_price]=lines[cash_price] or 0
>
> But this does not work either. You have to do:
>
> >        lines[cash_price]=lines._extra[cash_price] or 0
>
> > This is OK as it works. But wouldn't it be better if the sum were "0"
> > in the first place? Or if there is some logical reason for it to
> > "None" then one should to be able to say:
> >        lines[cash_price]=lines[cash_price] or 0
>
> I don't think you necessarily want it to default to 0 whenever no records
> are found, as you might want to distinguish between that case (None) and
> when there are records but the sum is truly 0. However, it would be nice if
> the assignment above worked without needing to refer to _extra.
>
> Anthony


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

2011-10-23 Thread Massimo Di Pierro
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: web3py & lifetime of web2py

2011-10-23 Thread Massimo Di Pierro
We do not have a web2py roadmap but you can assume the basic logic
will stay the same. Dal and templates will stay the same.
helpers will stay the same. Forms and form handling we do not know.
Bottom line: very relevant.


On Oct 23, 1:50 am, Gour  wrote:
> There is some talk that web3py will probably become 'new' product and
> not just python-3 upgrade.
>
> Otoh, I'm considering to buy paperback versions of Web2py's 4th ed as well as
> the upcoming Packt book, but wonder how much would the skills acquired by
> learning web2py be relevant for web3py, iow, what is the estimated lifetime 
> for
> web2py before some important work on web3py is underwent?
>
> Sincerely,
> Gour
>
> --
> In the material world, one who is unaffected by whatever good
> or evil he may obtain, neither praising it nor despising it,
> is firmly fixed in perfect knowledge.
>
> http://atmarama.net| Hlapicina (Croatia) | GPG: 52B5C810
>
>  signature.asc
> < 1KViewDownload


[web2py] Re: web2py crud and dealing with input

2011-10-23 Thread Massimo Di Pierro
Now sure I fully understand the pproblem but your first controller/
view should probably be:

# controller
def index():
rows = db(db.domains.created_by==auth.user_id).select()
return dict(rows=rows)

# view
{{extend 'layout.html'}}
Manage your domain names
{{for row in rows:}}
 {{=LI(A(row.title, _href=URL('domain_show', args=row.id)))}}
{{pass}}
[ {{=A('create domain', _href=URL('domain_add'))}} ]

So add search add your own form = SQLFORM.factory(Field('key')) and
use the value to do db.domains.title.like(form.vars.key)

On Oct 23, 2:23 am, Jimmy Stewpot  wrote:
> Hello,
>
> I am new to web2py. I just started a new app to become more familiar
> with the technology. So far I have the following.
>
> # controller
> def index():
>     form, rows = crud.select(db.domains,
> query=(db.domains.created_by==auth.user_id))
>     return dict(rows=rows)
>
> # view
> {{extend 'layout.html'}}
> Manage your domain names
> [ {{=A('search', _href=URL('search'))}} ]
> {{response.write(rows)}}
> {{for name in rows:}}
>      {{=LI(A(name[1], _href=URL('domain_show', args=name[4])))}}
> {{pass}}
> [ {{=A('create domain', _href=URL('domain_add'))}} ]
>
> The problem is that it dynamically generates the args=name[4] as 
> name[4] . in the browser.
>
> I've been so far unable to find any tidy was so that I can only show
> the domains for the particular user and pass those variables around to
> show, edit, delete etc.
>
> As an example here is what I have in my domain_show controller
>
> @auth.requires_login()
> def domain_show():
>      "shows a domain name"
>      domain_name = db.domains(request.args(0),created_by=auth.user_id)
> or redirect(URL('index'))
>      db.domains.id.default = domain_name.id
>      form = crud.create(db.domains) if auth.user else None
>      return dict(domain_name=domain_name, form=form)
>
> and the view
>
> {{extend 'layout.html'}}
> {{=domain_name.name}}
> {{=form}}
>
> I would love to know if there is a better way to do this stuff. Any
> advice would be really appreciated.
>
> Regards,
>
> Jimmy.


[web2py] Re: dal aggregation sum fields None

2011-10-23 Thread Anthony
On Sunday, October 23, 2011 11:49:31 AM UTC-4, Massimo Di Pierro wrote:
>
> lines[cash_price]=lines(cash_price) or 0  
>

I don't think that will solve the problem. That will add a new 
'SUM(orderline.cash_price)' key to lines rather than updating 
lines._extra['SUM(orderline.cash_price)']. However, when you subsequently do 
lines[cash_price], it will pull the old value from 
lines._extra['SUM(orderline.cash_price)'] and ignore the new value stored in 
the new key. This is because Row.__getitem__ always gets the value stored in 
_extra when the key is in _extra (
http://code.google.com/p/web2py/source/browse/gluon/dal.py#3888). To enable 
the assignment, I guess you'd have to update Row.__setitem__ so it would 
update _extra when the key is in _extra (though not sure if there are any 
downsides to that).

Anthony


[web2py] Re: auth_user

2011-10-23 Thread Anthony
On Sunday, October 23, 2011 11:20:40 AM UTC-4, lucas wrote:
>
> yes, putting the requires under the field worked great, thanx. 
>
> well, i tried to just change the natural/ordinal order of the columns/ 
> fields in the database (postgresql in my case) but that didn't work.
>

Right. The forms will be based on the web2py model (i.e., the DAL table 
definition), not what's in the DB.
 

>
> how can i direct the register/profile of auth to another view and how 
> do i customize that view?
>

Several options. The simplest is just to add some logic directly to the 
existing user view:

{{if request.args(0) == 'register':}}
[custom register form code goes here]
{{pass}}

You can also create a separate register view and add logic to the user() 
function to switch to that view:

def user():
if request.args(0) == 'register':
response.view = 'default/register.html'
return dict(form=auth())

Finally, you can define a completely separate register function:

def register():
return dict(form=auth.register())

As for creating a custom form, 
see http://web2py.com/book/default/chapter/07#Custom-forms.

Anthony



Re: [web2py][GAE]BadValueError: Incomplete key found for reference property

2011-10-23 Thread Phyo Arkar
Massimo , can you check is that a bug of web2py?

I got BadValueError , using 1.98.2 version on GAE

Controller is very simple :

def get_items():
response.generic_patterns = ['json']
query=(db.item.id>=0)
return response.json(db(query).select(db.item.id,db.item.name))

Thats it.

Regards

Phyo.
On 10/23/11, Phyo Arkar  wrote:
> any idea?
>
> On 10/23/11, Phyo Arkar  wrote:
>> I am using 1.98.2
>>
>> here is my model :
>>
>> db.define_table("item",
>>   SQLField("name", "text", length=512, notnull=True, default=None),
>>   SQLField("base_price", "integer", notnull=True, default=None),
>>   SQLField("price", "integer", notnull=True, default=None)
>>   )
>>
>>
>> """
>> Table definition
>> """
>> from datetime import date
>> import time
>>
>> db.define_table("sale",
>>   SQLField("id_items", db.item),
>>   SQLField("date", "date", notnull=True, default=date.today()),
>>   SQLField("sale_time", "datetime", notnull=True,
>> default=request.now),
>>   SQLField("total_items", "integer", notnull=True, default=None),
>>   SQLField("description", "text", notnull=False, default=None))
>>
>> On Sun, Oct 23, 2011 at 5:43 AM, howesc  wrote:
>>
>>> what's the model?
>>>
>>> what version of web2py are you using?
>>>
>>
>


[web2py] Re: dal aggregation sum fields None

2011-10-23 Thread Massimo Di Pierro
You are right. I misunderstood the issue.

On Oct 23, 11:21 am, Anthony  wrote:
> On Sunday, October 23, 2011 11:49:31 AM UTC-4, Massimo Di Pierro wrote:
>
> > lines[cash_price]=lines(cash_price) or 0  
>
> I don't think that will solve the problem. That will add a new
> 'SUM(orderline.cash_price)' key to lines rather than updating
> lines._extra['SUM(orderline.cash_price)']. However, when you subsequently do
> lines[cash_price], it will pull the old value from
> lines._extra['SUM(orderline.cash_price)'] and ignore the new value stored in
> the new key. This is because Row.__getitem__ always gets the value stored in
> _extra when the key is in _extra 
> (http://code.google.com/p/web2py/source/browse/gluon/dal.py#3888). To enable
> the assignment, I guess you'd have to update Row.__setitem__ so it would
> update _extra when the key is in _extra (though not sure if there are any
> downsides to that).
>
> Anthony


[web2py] Re: [GAE]BadValueError: Incomplete key found for reference property

2011-10-23 Thread Massimo Di Pierro
Before we spend time in something that may have been fixed already.
Can you try the latest web2py? can you also remove the list of fields
in select(...) since GAE does not support that?

On Oct 23, 12:20 pm, Phyo Arkar  wrote:
> Massimo , can you check is that a bug of web2py?
>
> I got BadValueError , using 1.98.2 version on GAE
>
> Controller is very simple :
>
> def get_items():
>         response.generic_patterns = ['json']
>         query=(db.item.id>=0)
>         return response.json(db(query).select(db.item.id,db.item.name))
>
> Thats it.
>
> Regards
>
> Phyo.
> On 10/23/11, Phyo Arkar  wrote:
>
>
>
>
>
>
>
> > any idea?
>
> > On 10/23/11, Phyo Arkar  wrote:
> >> I am using 1.98.2
>
> >> here is my model :
>
> >> db.define_table("item",
> >>       SQLField("name", "text", length=512, notnull=True, default=None),
> >>       SQLField("base_price", "integer", notnull=True, default=None),
> >>       SQLField("price", "integer", notnull=True, default=None)
> >>       )
>
> >> """
> >> Table definition
> >> """
> >> from datetime import date
> >> import time
>
> >> db.define_table("sale",
> >>       SQLField("id_items", db.item),
> >>       SQLField("date", "date", notnull=True, default=date.today()),
> >>       SQLField("sale_time", "datetime", notnull=True,
> >> default=request.now),
> >>       SQLField("total_items", "integer", notnull=True, default=None),
> >>       SQLField("description", "text", notnull=False, default=None))
>
> >> On Sun, Oct 23, 2011 at 5:43 AM, howesc  wrote:
>
> >>> what's the model?
>
> >>> what version of web2py are you using?


[web2py] Re: dal aggregation sum fields None

2011-10-23 Thread Anthony
On Sunday, October 23, 2011 3:16:56 PM UTC-4, Massimo Di Pierro wrote:
>
> You are right. I misunderstood the issue.
>

Do you think assignments to _extra should be enabled (transparently, not by 
directly hacking the _extra dictionary), or should _extra remain read-only? 
The current behavior is a bit mysterious -- you can seemingly make an 
assignment to links[cash_price] without receiving an error, but when you try 
to retrieve the new value, it's not there.

Anthony


[web2py] Complex CRUD Forms Examples with Web2py?

2011-10-23 Thread BrendanC
Hi
Some time ago I developed a CRUD demo app in Django that used some some 
complex forms. Here's an example:

http://theludditegeek.com/prescreen/1

I'd like to convert this to web2py. AFAIK the standard web2py forms/SQLform 
features (and related error handling) are based on the use of a single data 
element per row layout - which is very wasteful of screen real estate - 
especially if the form has a series of checkboxes for data input.  Are there 
any features in Web2py that help build more complex forms with non standard 
layouts (I'm thinking about possible error handling/error display issues 
here - I know I need to build the custom templates by hand).

Interested to hear any comments/feedback as the only form  examples I can 
find are very basic (not real world).

TIA,
BrendanC



[web2py] Re: web3py & lifetime of web2py

2011-10-23 Thread Gour
On Sun, 23 Oct 2011 08:55:42 -0700 (PDT)
Massimo Di Pierro
 wrote:

> We do not have a web2py roadmap but you can assume the basic logic
> will stay the same. 

:-)

> Dal and templates will stay the same.

:-))

> helpers will stay the same. 

:-)))

> Forms and form handling we do not know.

OK.

> Bottom line: very relevant.

Thanks a lot, Massimo.

Now we can safely pre-order Packt book and wait release of 4th ed of Web2py 
book. ;)


Sincerely,
Gour


-- 
In this endeavor there is no loss or diminution, 
and a little advancement on this path can protect 
one from the most dangerous type of fear.

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810


signature.asc
Description: PGP signature


Re: [web2py] Re: web3py & lifetime of web2py

2011-10-23 Thread Ovidio Marinho
  Massimo , this means that one version may be next Web3py ?

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



2011/10/23 Massimo Di Pierro 

> We do not have a web2py roadmap but you can assume the basic logic
> will stay the same. Dal and templates will stay the same.
> helpers will stay the same. Forms and form handling we do not know.
> Bottom line: very relevant.
>
>
> On Oct 23, 1:50 am, Gour  wrote:
> > There is some talk that web3py will probably become 'new' product and
> > not just python-3 upgrade.
> >
> > Otoh, I'm considering to buy paperback versions of Web2py's 4th ed as
> well as
> > the upcoming Packt book, but wonder how much would the skills acquired by
> > learning web2py be relevant for web3py, iow, what is the estimated
> lifetime for
> > web2py before some important work on web3py is underwent?
> >
> > Sincerely,
> > Gour
> >
> > --
> > In the material world, one who is unaffected by whatever good
> > or evil he may obtain, neither praising it nor despising it,
> > is firmly fixed in perfect knowledge.
> >
> > http://atmarama.net| Hlapicina (Croatia) | GPG: 52B5C810
> >
> >  signature.asc
> > < 1KViewDownload


[web2py] Re: dal aggregation sum fields None

2011-10-23 Thread Massimo Di Pierro
I am not happy with extra.

Currently we have three mechanisms to deal with "extra" fields.
table._extra, lazy virtual fields, links in grid/smartgrid. None of
them are undocumented in the book which means that for none of them we
promise backward compatibility.


Massimo

On Oct 23, 2:27 pm, Anthony  wrote:
> On Sunday, October 23, 2011 3:16:56 PM UTC-4, Massimo Di Pierro wrote:
>
> > You are right. I misunderstood the issue.
>
> Do you think assignments to _extra should be enabled (transparently, not by
> directly hacking the _extra dictionary), or should _extra remain read-only?
> The current behavior is a bit mysterious -- you can seemingly make an
> assignment to links[cash_price] without receiving an error, but when you try
> to retrieve the new value, it's not there.
>
> Anthony


[web2py] Re: Help making nav menu work please!

2011-10-23 Thread Christopher Steel
Are you looking to generate navigation menu's using table data? 

If so, you can try a search for web2py "generate menu". Make sure to check 
out the web2pyslices as well, I think one of the very first slices was 
related to creating dynamic menus.






[web2py] Exceeding memory limits in webfaction

2011-10-23 Thread Jose
Hello

I have some applications in webfaction (more than 2 years).

I recently upgraded web2py to version 1.98.2 and then to 1.99.2.

What I noticed is that since the first update errors began to appear:

502 – Bad Gateway

I reported this to webfaction and they answered that it is because it
exceeds the memory limit to my plan:

"It appears that you are regularly exceeding your memory limit of
80MB. This leads to your processes getting killed, and therefore your
backend web server is not working until it gets restarted. This is the
reason for the 502 errors."

As I said, this started after upgrading web2py.

How I can solve this problem?

best regards
Jose


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread TheSweetlink
I don't wish to irritate rather just curious to know if anyone else
can replicate this.

A SQLFORM.factory with an empty field of type='list:string' is
submitting as passed when an IS_NOT_EMPTY() validator is used in any
and every way possible.

The very same .factory has a field type string where the same exact
validation works as it should.  Why should my list:string not work the
same way?

Thank you in advance for your time.

David


[web2py] Re: Help making nav menu work please!

2011-10-23 Thread noremac


On Oct 24, 7:42 am, Christopher Steel  wrote:
> Are you looking to generate navigation menu's using table data?
>
> If so, you can try a search for web2py "generate menu". Make sure to check
> out the web2pyslices as well, I think one of the very first slices was
> related to creating dynamic menus.

Thanks for the reply mate but I already have the menu generating from
the table data. Im looking to make the menu work.  It is for an online
store selling many different products. For example.

Animal
Dog
Cat
Bird

Animal is the main category and dog, cat and bird are subcategories.

When I click on Dog I would like to be able to pass animal and dog as
parameters to a function of some sort that will generate a query with
those parameters, something like this.

products = db((db.products.category=='animal') &
(db.products.subcategory=='dog')).select(db.products.all)


I hope that it makes for sense for people now :) I am not looking for
someone to write me code, I am just very new to web2py and not sure
how to go about achieving this.

I will have a look into web2pyslices and see if there is anything in
there that can help me out :)


[web2py] Re: Exceeding memory limits in webfaction

2011-10-23 Thread Massimo Di Pierro
Can you try run your app locally with 1.99.2 and see if you can
reproduce any memory problem. What version did you upgrade from? Di
you have also with 1.98.2? I cannot think of any change that results
in more memory usage, actually the opposite.

Massimo

On Oct 23, 5:31 pm, Jose  wrote:
> Hello
>
> I have some applications in webfaction (more than 2 years).
>
> I recently upgraded web2py to version 1.98.2 and then to 1.99.2.
>
> What I noticed is that since the first update errors began to appear:
>
> 502 – Bad Gateway
>
> I reported this to webfaction and they answered that it is because it
> exceeds the memory limit to my plan:
>
> "It appears that you are regularly exceeding your memory limit of
> 80MB. This leads to your processes getting killed, and therefore your
> backend web server is not working until it gets restarted. This is the
> reason for the 502 errors."
>
> As I said, this started after upgrading web2py.
>
> How I can solve this problem?
>
> best regards
> Jose


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread Massimo Di Pierro
Thanks for the reminder. What is the expected behavior? 'list:string'
only accepts strings that are not empty. Are you trying to have at
least one item in the list?
We do not have a validator to do that but can make one:

class IS_LIST_SIZE(Validator):

def __init__(self, min=0,max=10,error_message='not in range'):
self.min = min
self.max=max
self.error_message = error_message

def __call__(self, value):
ivalue = value
if not isinstance(value, list):
ivalue = [ivalue]
if not self.min<=len(ivalue)<=self.max:
return (ivalue, self.error_message)
return (ivalue, None)




On Oct 23, 5:37 pm, TheSweetlink  wrote:
> I don't wish to irritate rather just curious to know if anyone else
> can replicate this.
>
> A SQLFORM.factory with an empty field of type='list:string' is
> submitting as passed when an IS_NOT_EMPTY() validator is used in any
> and every way possible.
>
> The very same .factory has a field type string where the same exact
> validation works as it should.  Why should my list:string not work the
> same way?
>
> Thank you in advance for your time.
>
> David


Re: [web2py] Re: web3py & lifetime of web2py

2011-10-23 Thread Mariano Reingart
Ovidio:

I'm working in a python 3 upgrade (web2py-py3k), you can take a look at:

http://code.google.com/r/reingart-web2py/source/browse/?name=py3k

Some screenshots:

web2py-py3k: welcome app running python 3! http://pic.twitter.com/BR5PqAJ8

web2py-py3k: after 2to3 and 1 hour of minor fixes, web2py runs in
python 3.2! http://pic.twitter.com/7Ff85G1r

My idea is to run most web2py applications unchanged in py3k (not even
needing to use 2to3 manually).

The proof-of-concept code is working (dal, forms, registration, etc.)
but has some minor issues right now.
I didn't have time to work on it but I expect for December to have a
full version of web2py seamless working on py3k.

Best regards

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com


On Sun, Oct 23, 2011 at 6:02 PM, Ovidio Marinho  wrote:
>
>       Massimo , this means that one version may be next Web3py ?
>        Ovidio Marinho Falcao Neto
>                 Web Developer
>              ovidio...@gmail.com
>                  ITJP - itjp.net.br
>                83   8826 9088 - Oi
>                83   9334 0266 - Claro
>                         Brasil
>
>
>
> 2011/10/23 Massimo Di Pierro 
>>
>> We do not have a web2py roadmap but you can assume the basic logic
>> will stay the same. Dal and templates will stay the same.
>> helpers will stay the same. Forms and form handling we do not know.
>> Bottom line: very relevant.
>>
>>
>> On Oct 23, 1:50 am, Gour  wrote:
>> > There is some talk that web3py will probably become 'new' product and
>> > not just python-3 upgrade.
>> >
>> > Otoh, I'm considering to buy paperback versions of Web2py's 4th ed as
>> > well as
>> > the upcoming Packt book, but wonder how much would the skills acquired
>> > by
>> > learning web2py be relevant for web3py, iow, what is the estimated
>> > lifetime for
>> > web2py before some important work on web3py is underwent?
>> >
>> > Sincerely,
>> > Gour
>> >
>> > --
>> > In the material world, one who is unaffected by whatever good
>> > or evil he may obtain, neither praising it nor despising it,
>> > is firmly fixed in perfect knowledge.
>> >
>> > http://atmarama.net| Hlapicina (Croatia) | GPG: 52B5C810
>> >
>> >  signature.asc
>> > < 1KViewDownload
>


[web2py] Re: Exceeding memory limits in webfaction

2011-10-23 Thread Jose


On 23 oct, 19:53, Massimo Di Pierro 
wrote:
> Can you try run your app locally with 1.99.2 and see if you can
> reproduce any memory problem. What version did you upgrade from?

I do not remember, but I'm sure it was a version of more than 1 year.

Jose


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread TheSweetlink
Thank you Massimo,

The expected behavior is for the 'list:string' field to be a required
field in order for the form to pass validation.

It is currently a jquery multi-select checkbox dropdown created from
an IS_IN_SET(...zero=None) validator on the same field (which works
perfectly to my knowledge).

I'm fairly certain there is a simple way to accomplish what I want to
do but I'm not seeing it.

The idea is to have a custom error message like 'Please select one or
more...bloggittyblahblah'.

I have a validator in the form which works great for an empty string,
sadly though my list:select will submit no matter what I do whether
there are options selected or none selected.

How can I implement something like IS_NOT_EMPTY() to require the field
have a value to pass validation with a 'list:string' field?

David

On Oct 23, 6:58 pm, Massimo Di Pierro 
wrote:
> Thanks for the reminder. What is the expected behavior? 'list:string'
> only accepts strings that are not empty. Are you trying to have at
> least one item in the list?
> We do not have a validator to do that but can make one:
>
> class IS_LIST_SIZE(Validator):
>
>     def __init__(self, min=0,max=10,error_message='not in range'):
>         self.min = min
>         self.max=max
>         self.error_message = error_message
>
>     def __call__(self, value):
>         ivalue = value
>         if not isinstance(value, list):
>             ivalue = [ivalue]
>         if not self.min<=len(ivalue)<=self.max:
>             return (ivalue, self.error_message)
>         return (ivalue, None)
>
> On Oct 23, 5:37 pm, TheSweetlink  wrote:
>
> > I don't wish to irritate rather just curious to know if anyone else
> > can replicate this.
>
> > A SQLFORM.factory with an empty field of type='list:string' is
> > submitting as passed when an IS_NOT_EMPTY() validator is used in any
> > and every way possible.
>
> > The very same .factory has a field type string where the same exact
> > validation works as it should.  Why should my list:string not work the
> > same way?
>
> > Thank you in advance for your time.
>
> > David
>
>


[web2py] Re: Found a bug: XMLRPC with basic authorization fails

2011-10-23 Thread Robert Clark
Hi Massimo

Here are the steps to reproduce this problem in web2py 1.99.2 (these
steps worked fine on 1.98.x versions)

1) In web2py admin create "New simple application" called "foo"

2) Add to db.py:
auth.settings.allow_basic_login = True

3) Decorate call() with @auth.requires_login in default.py:

@auth.requires_login()
def call():
...

4) Add a simple XMLPRC method to default.py:

@service.xmlrpc
def multiply(a=1,b=1):
return dict(answer=int(a) * int(b))

5) Register a user with email "bob.sm...@foo.com" password "snowball"

6) From a python shell use ServerProxy to invoke the service

> from xmlrpclib import ServerProxy
> server = 
> ServerProxy('http://bob.sm...@foo.com:snowball@localhost:8000/foo/default/call/xmlrpc',
>  verbose=True)
> server.multiply(2, 2)

...
reply: 'HTTP/1.1 303 SEE OTHER\r\n'
...



Cheers,
Rob


On Oct 22, 2:59 am, Massimo Di Pierro 
wrote:
> Can you provide an example to reproduce the problem?
>
> On Oct 21, 12:38 am,RobinMarshall
> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > Just wanted to say that we found a bug in 1.99.2 when using XMLRPC
> > services with the @auth.requires_login decorator using basic
> > authentication.
>
> > It looks like some code was refactored out of requires_login into a
> > generic requires method which might be the cause of the problem.
>
> > A quick hack was to change the following code, but obviously that
> > won't work very well for people who aren't using basic authentication.
>
> >     def is_logged_in(self):
> >         """
> >         checks if the user is logged in and returns True/False.
> >         if so user is in auth.user as well as in session.auth.user
> >         """
> >         if self.user:
> >             return True
> >         return False
>
> > to:
>
> >     def is_logged_in(self):
> >         """
> >         checks if the user is logged in and returns True/False.
> >         if so user is in auth.user as well as in session.auth.user
> >         """
> >         if self.basic() and self.user:
> >             return True
> >         return False
>
> > Cheers,
> >Robin


[web2py] Re: Help making nav menu work please!

2011-10-23 Thread Anthony
On Sunday, October 23, 2011 6:47:45 PM UTC-4, noremac wrote:
>
>
>
> On Oct 24, 7:42 am, Christopher Steel  wrote: 
> > Are you looking to generate navigation menu's using table data? 
> > 
> > If so, you can try a search for web2py "generate menu". Make sure to 
> check 
> > out the web2pyslices as well, I think one of the very first slices was 
> > related to creating dynamic menus. 
>
> Thanks for the reply mate but I already have the menu generating from 
> the table data. Im looking to make the menu work.  It is for an online 
> store selling many different products. For example. 
>
> Animal 
> Dog 
> Cat 
> Bird 
>
> Animal is the main category and dog, cat and bird are subcategories. 
>
> When I click on Dog I would like to be able to pass animal and dog as 
> parameters to a function of some sort that will generate a query with 
> those parameters, something like this. 
>
> products = db((db.products.category=='animal') & 
> (db.products.subcategory=='dog')).select(db.products.all) 
>

def products():
products = db((db.products.category==request.args(0)) &
(db.products.subcategory==request.args(1)).select()
return dict(products=products)

Then construct your menu so the links include the category and subcategory 
as arguments. For dogs, the link should be:

URL('your_controller', 'products', args=['animal', 'dog'])

Which will generate the URL /your_app/your_controller/products/animal/dog.

Anthony


[web2py] Re: dal aggregation sum fields None

2011-10-23 Thread Anthony
On Sunday, October 23, 2011 5:14:17 PM UTC-4, Massimo Di Pierro wrote:
>
> I am not happy with extra. 
>
> Currently we have three mechanisms to deal with "extra" fields. 
> table._extra, lazy virtual fields, links in grid/smartgrid. None of 
> them are undocumented in the book which means that for none of them we 
> promise backward compatibility.
>

Right now, Row._extra is used to store the results of expressions (such as 
aggregate functions) in selects. The key used to store the expression is the 
expression itself, and I think that does have to remain backward compatible 
(i.e., row[expression] should retrieve the value of the expression returned 
by the select, regardless of the internal implementation). The question is 
whether it should be possible to do row[expression] = some_other_value 
(i.e., alter the value returned by the select). Currently it is not possible 
without hacking _extra. We could make it possible now, which would involve 
making an assignment to _extra in Row.__setitem__, and if the internal 
implementation of _extra fields in Row objects changes in the future, 
presumably we could just make sure the new implementation also allows such 
assignments. In other words, should the API allow assignments to expression 
results in Row objects (without reference to _extra), or should they remain 
read-only?

Anthony 


Re: [web2py] Re: Getting Too many tables error on GAE , HELP!

2011-10-23 Thread howesc
it is very much a mindset.  joins are expensive no matter what system you 
use (well they are not free, though still very fast on a relational system), 
so when they build GAE which is supposed to be optimized for web page views, 
they disallowed joins.  i have a love/hate relationship with it!


[web2py] Re: Complex CRUD Forms Examples with Web2py?

2011-10-23 Thread Anthony
It sounds like you already know about building custom forms 
(http://web2py.com/book/default/chapter/07#Custom-forms). If you need to do 
custom error displays, also check out 
http://web2py.com/book/default/chapter/07#Hide-Errors. Server-side DOM 
manipulation might help as well 
(see http://web2py.com/book/default/chapter/05#Server-side-DOM-and-Parsing; 
http://www.web2pyslices.com/slices/take_slice/43).

Anthony

On Sunday, October 23, 2011 4:18:44 PM UTC-4, BrendanC wrote:
>
> Hi
> Some time ago I developed a CRUD demo app in Django that used some some 
> complex forms. Here's an example:
>
> http://theludditegeek.com/prescreen/1
>
> I'd like to convert this to web2py. AFAIK the standard web2py forms/SQLform 
> features (and related error handling) are based on the use of a single data 
> element per row layout - which is very wasteful of screen real estate - 
> especially if the form has a series of checkboxes for data input.  Are there 
> any features in Web2py that help build more complex forms with non standard 
> layouts (I'm thinking about possible error handling/error display issues 
> here - I know I need to build the custom templates by hand).
>
> Interested to hear any comments/feedback as the only form  examples I can 
> find are very basic (not real world).
>
> TIA,
> BrendanC
>
>

[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread TheSweetlink
Ugh, just realized, right from the online book:

"
Note that when multiple=True, IS_IN_SET will accept zero or more
values, i.e. it will accept the field when nothing has been selected.
"

How can I have multiple=true AND require the field?  Is that possible?

David


TheSweetlink wrote:
> Thank you Massimo,
>
> The expected behavior is for the 'list:string' field to be a required
> field in order for the form to pass validation.
>
> It is currently a jquery multi-select checkbox dropdown created from
> an IS_IN_SET(...zero=None) validator on the same field (which works
> perfectly to my knowledge).
>
> I'm fairly certain there is a simple way to accomplish what I want to
> do but I'm not seeing it.
>
> The idea is to have a custom error message like 'Please select one or
> more...bloggittyblahblah'.
>
> I have a validator in the form which works great for an empty string,
> sadly though my list:select will submit no matter what I do whether
> there are options selected or none selected.
>
> How can I implement something like IS_NOT_EMPTY() to require the field
> have a value to pass validation with a 'list:string' field?
>
> David
>
> On Oct 23, 6:58 pm, Massimo Di Pierro 
> wrote:
> > Thanks for the reminder. What is the expected behavior? 'list:string'
> > only accepts strings that are not empty. Are you trying to have at
> > least one item in the list?
> > We do not have a validator to do that but can make one:
> >
> > class IS_LIST_SIZE(Validator):
> >
> >     def __init__(self, min=0,max=10,error_message='not in range'):
> >         self.min = min
> >         self.max=max
> >         self.error_message = error_message
> >
> >     def __call__(self, value):
> >         ivalue = value
> >         if not isinstance(value, list):
> >             ivalue = [ivalue]
> >         if not self.min<=len(ivalue)<=self.max:
> >             return (ivalue, self.error_message)
> >         return (ivalue, None)
> >
> > On Oct 23, 5:37 pm, TheSweetlink  wrote:
> >
> > > I don't wish to irritate rather just curious to know if anyone else
> > > can replicate this.
> >
> > > A SQLFORM.factory with an empty field of type='list:string' is
> > > submitting as passed when an IS_NOT_EMPTY() validator is used in any
> > > and every way possible.
> >
> > > The very same .factory has a field type string where the same exact
> > > validation works as it should.  Why should my list:string not work the
> > > same way?
> >
> > > Thank you in advance for your time.
> >
> > > David
> >
> >


Re: [web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread Vasile Ermicioi
perhaps

db.table.field.requires = [IS_NOT_EMPTY(), IS_IN_SET(...)]


[web2py] identity column with web2py

2011-10-23 Thread tom h
Hi,

I've recently started to use web2py, pretty new to it and python also,
and I'd like to change the identity field that are automatically
created to be decimal(13,0) instead of integer.

Basically I would not like to deal with identity columns overflowing
when it reaches 10**9.  I mean, I'm only doing about a million rows
every day, but it could be more, and i'm just worried about future
migration to other systems.

I'm currently trying to hack dal.py but it's all over the place.

Is there anyway to get around this or make this id field a bit more
flexible?  It would be nice if it was implemented as a Field.identity,
and people can always name it whatever they wanted, and specify the
size smallint, int, decimal(X,0) that they feel like doing.

Thanks a lot!

Tom


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread ニコノコ
How about:  db.table.field.requires = IS_LENGTH(1)
On Oct 22, 12:35 am, TheSweetlink  wrote:
> I have a SQLFORM.factory that is respecting IS_NOT_EMPTY() for a field
> with type='string' but not respecting it for a diffirent field of
> type='list:string'.
>
> If the list:string type field is left empty the form validates.
>
> Confirmed with firebug.
>
> Tested with form.accepts, form.process(...).accepted, and
> form.validate.
>
> I tried removing all other conditions in the list:string field's
> requirements as well as setting it manually after the form is created
> with:
>
> form.element('#no_table_yayweb2py')['requires']=IS_NOT_EMPTY()
>
> The form uses an onvalidation= and again, it works for the plain
> string but not a field of list:string
>
> The form is validated no matter what I do.
>
> Your thoughts are most appreciated.
>
> David


[web2py] Re: grid custom button icons

2011-10-23 Thread ニコノコ

I create new buttons like this in the grid:
links = [lambda row: A('X', _href=URL(args=["view", db.person,
row.id] ))]

How should I specify an icon for the new button?

On Oct 19, 10:04 pm, Bruno Rocha  wrote:
> Herehttps://github.com/michenriksen/css3buttonsyou can find a list of all
> suported classes for standard style,
>
> for the ui-icon option take a look at jquery-ui theme roller page


Re: [web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread Vasile Ermicioi
>
> How about:  db.table.field.requires = IS_LENGTH(1)

that will limit the field to one character, not to one value from set


[web2py] Re: identity column with web2py

2011-10-23 Thread tom h
PS, I could change the default types in PostgreSQL adapter or whatever
other adapter I'm using, to be BIGSERIAL and BIGINT for id and
reference id as opposed to SERIAL and INTEGER.  But this is something
I'd like to control on a table level, not on a database connection
level.  I could extend the adapter to make my own and overwrite the
type, but I really don't want to have to maintain two different
database handles just for identity columns.


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread TheSweetlink
Hello Vasile,

I tried that and the IS_NOT_EMPTY() doesn't take.

I should really test if the IS_IN_SET() is working properly too but I
suspect that it is.

I need to find out how I can override that behavior I described above
from the book.

Apparently multiple=true allows IS_IN_SET() to pass validation even
without that var being sent along with the rest.

Thanks for your help all.

David

On Oct 23, 9:32 pm, Vasile Ermicioi  wrote:
> perhaps
>
> db.table.field.requires = [IS_NOT_EMPTY(), IS_IN_SET(...)]


[web2py] Re: Complex CRUD Forms Examples with Web2py?

2011-10-23 Thread ニコノコ
Checkout the solidForm plugin from http://dev.s-cubism.com/web2py_plugins

On Oct 24, 4:18 am, BrendanC  wrote:
> Hi
> Some time ago I developed a CRUD demo app in Django that used some some
> complex forms. Here's an example:
>
> http://theludditegeek.com/prescreen/1
>
> I'd like to convert this to web2py. AFAIK the standard web2py forms/SQLform
> features (and related error handling) are based on the use of a single data
> element per row layout - which is very wasteful of screen real estate -
> especially if the form has a series of checkboxes for data input.  Are there
> any features in Web2py that help build more complex forms with non standard
> layouts (I'm thinking about possible error handling/error display issues
> here - I know I need to build the custom templates by hand).
>
> Interested to hear any comments/feedback as the only form  examples I can
> find are very basic (not real world).
>
> TIA,
> BrendanC


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread ニコノコ

not if the field is list:string

On Oct 24, 10:32 am, Vasile Ermicioi  wrote:
> > How about:  db.table.field.requires = IS_LENGTH(1)
>
> that will limit the field to one character, not to one value from set


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread ニコノコ
Eeugh. Sorry for the ugly suggestion. Post validation could

def person_processing(form):

if len(form.vars.field or '')<1:
form.errors.field= 'Select one.'



On Oct 24, 10:32 am, Vasile Ermicioi  wrote:
> > How about:  db.table.field.requires = IS_LENGTH(1)
>
> that will limit the field to one character, not to one value from set


[web2py] elfinder integrated into web2py as a plugin?

2011-10-23 Thread ron_m
It looks like elfinder would be a very nice implementation of a file 
manipulation area open to users for an application I am working on.

I found this discussion about elfinder which is over a year old

https://groups.google.com/d/topic/web2py/Ove0jTJn_Vk/discussion

where in the last posting a Massimo is copied in a section that describes 
how to turn this into a plugin. I found the appliance and the hg repository 
on google code.

Was this ever turned into a plugin and if so where is it? Is there any 
interest in someone completing that if it has not been done? Since I will be 
using it I can volunteer.

Thanks,

Ron



[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] password_two

2011-10-23 Thread lucas
hello one and all,

i think i found a inconsistency in the default auth register form.
the  tags for the password_two fields don't have the class
references.  so like password has

...Password:for the input
widgetfor the comment...

but the class references are not in there for the password_two which
makes the form look a little funky if you set this classes in the css
file.  that could be fixed in the future correct?

just a thought either way.  lucas


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread TheSweetlink
Thank you all for your help.

I was able to resolve the problem quirky as it may be but here we go.
For science!!!

To get a type='list:string' to fail validation if none passed from
your SQLFORM.factory form:

1) Used an onvalidation=... in my form.accepts(...) /
process(...).accepted / validate(...)

Within the validation function:

if not request.vars.choochoo:
form.errors.choochoo = "Please select 1 or more witches before
burning them."

form.errors.fieldname <--- Unless the fieldname
matched .errors.fieldname, flashing form.errors.fieldname wouldn't
work.

To reiterate more simply, Field('choochoo'...) had to match
form.errors.choochoo in order to have
form = SQLFORM.factory(...)
if form.validate(...):
do something
elif form.errors.choochoo:
response.flash = form.errors.choochoo

work when set from my onvalidation function


2)  IS_NOT_EMPTY() constraint added after form = SQLFORM.factory(...)

form.element('#no_table_myawesomeselect')
['requires']=IS_NOT_EMPTY(error_message='Please select 1 or more
witches before burning them.')

It wouldn't work when added to requires= in the Field(...) of my form
= definition but only when added after form is created but before
processing.



Now my errors flash from response as they should according to the
onvalidation function that's called.

Thanks again web2py community, you're wonderful as always.

David





On Oct 23, 11:21 pm, ニコノコ  wrote:
> Eeugh. Sorry for the ugly suggestion. Post validation could
>
> def person_processing(form):
>
> if len(form.vars.field or '')<1:
> form.errors.field= 'Select one.'
>
> On Oct 24, 10:32 am, Vasile Ermicioi  wrote:
>
> > > How about:  db.table.field.requires = IS_LENGTH(1)
>
> > that will limit the field to one character, not to one value from set
>
>


[web2py] Re: web3py & lifetime of web2py

2011-10-23 Thread Gour
On Sun, 23 Oct 2011 19:59:14 -0300
Mariano Reingart 
wrote:

> I didn't have time to work on it but I expect for December to have a
> full version of web2py seamless working on py3k.

Do you work with the web2py's trunk?


Sincerely,
Gour


-- 
While contemplating the objects of the senses, a person 
develops attachment for them, and from such attachment lust 
develops, and from lust anger arises.

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810


signature.asc
Description: PGP signature