[web2py] vCard and vEvent

2012-04-15 Thread Annet
In a web2py application I generate .vcf and .ics files using web2py's 
templating features. The problem is that all the code in {{}} results in 
empty lines, which is no problem on my Mac, but Google doesn't allow empty 
lines. For example, this: 

{{response.headers['Content-Disposition'] = 'attachment;filename=%s.vcf' % 
IS_SLUG()(organization.name)[0]}}BEGIN:VCARD
VERSION:4.0
{{if organization:}}
FN: {{=organization.name}}
ORG: {{=organization.name}}
{{pass}}
{{if address:}}
ADR;


... results in:


BEGIN:VCARD
VERSION:4.0

FN: Health Center Amsterdam
ORG: Health Center Amsterdam


ADR;


... and Google only allows:


BEGIN:VCARD
VERSION:4.0
FN: Health Center Amsterdam
ORG: Health Center Amsterdam
ADR;


Is there a way to solve this problem?

Kind regards,

Annet/


Re: [web2py] CMS/blog app suitable for web2py beginners

2012-04-15 Thread Chibuzo Ottih
Yeah, with instantpress, you can manage users, create tags and categories,
publish articles in few seconds and more. It also has the ability to manage
comments. To see more, I think you should download it and add it as an
application to your web2py framework to see how it works. Most of your
configuration/customization would be done in the apconfig.py file

Sunday, April 15, 2012, Gour  wrote:
> On Sun, 15 Apr 2012 07:39:58 +0100
> Chibuzo Ottih 
> wrote:
>
>> InstantPress is a more suitable CMS for blogs.
>
> Thank you.
>
>> That's its main aim.
>
> But it ca nbe use as CMS as well, right?
>
>> Movuca is a general CMS but more focused on social sites.
>
> Yeah, we're not interested for social sites, but more for smaller
> (brochure-like) sites with 'standard' features like blog/news sections,
> nice RSS feeds etc...and hopefully there will be some nice & simple cart
> solution available in the future for our small ecommerce needs.
>
> Btw, I've found the following explanation by Bruno: "In resume, Instant
> Press is an organized CMS (just like wordpress). Movuca is a mess! :)"
>
>> I've used instantpress and its much fun. Its very easy to customize
>> and has so many features you may want to add to your blog(e.g disquss)
>
> Does it have its own comment system which I'd prefer over Disquss?
>
> What about categories/tags, nice RSS feed?
>
> Have you tried to customize it with some other CSS framework?
>
>
> Sincerely,
> Gour
>
> --
> But for one who takes pleasure in the self, whose human life
> is one of self-realization, and who is satisfied in the self only,
> fully satiated — for him there is no duty.
>
> http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810
>


Re: [web2py] Overlapping periods

2012-04-15 Thread Rick
Thanks for the replies. Pbreit, you pointed the real issue -- what should I 
call the arguments (addperiodform.vars.id), that are passed from the goal 
function to the addingperiod function?

from the controller file:

def goal():
...some code...
addperiodform = SQLFORM(db.period, fields=['begindate','enddate', 
'planned'], labels={'begindate':'First day','enddate':'Last 
day','planned':'Goal'},submit_button='Submit',formstyle='table2cols')
if addperiodform.accepts(request.post_vars, session):
redirect(URL('default', 'addingperiod', args=addperiodform.vars.id))
...some code...

def addingperiod():
if request.args and request.args[0]:
item_id=request.args[0]
prerecords = db().select(db.period.ALL, orderby=db.period.begindate)
for prerecord in prerecords:
if prerecord.theauth==auth.user_id:
accepted1="true"
accepted2="true"

...some if-statements...

if accepted1=="true":
if accepted2=="true":
db.period.insert(item_id) #this line creates an error
redirect(URL(f='goal'))



On Saturday, April 14, 2012 10:44:28 AM UTC+2, backseat wrote:
>
> On Fri, 13 Apr 2012 11:38:25 -0700 (PDT), sababa.sab...@gmail.com said:
>
> > The 
> >  function should only add periods that doesn't overlap any of the
> > already registered ones. 
>
> Let me try to help (I owe this group a lot of help). I've ignored your
> code, and I don't know what schema you're using, but here's the pseudo
> and untested code:
>
> def should_this_period_be_inserted(start,end):
> # Check that all periods that started before this one
> # also finished before this one started
> q = ((db.period.begindatestart))
> if db(query).count():
> return False
> # Check that no periods started while this one was in progress
> q = ((db.period.begindate>=start)&(db.period.begindate<=end))
> if db(query).count():
> return False
> # If we got this far, the period didn't overlap
> return True
>
> Have I understood what you're trying to do?
> -- 
> "You can have everything in life you want if you help enough other people
> get what they want" - Zig Ziglar. 
>
> Who did you help today?
>
>

[web2py] smartgrid crashes when submitting a duplicate field value

2012-04-15 Thread weheh
If smartgrid is used to edit the values of fields in auth_user that are 
designated unique=True, smartgrid will crash when a duplicate value is 
entered. Here's a ticket trace. SQLite is the underlying db. Incidentally, 
this is my first go at grid and smartgrid and I'm very impressed. Kudos.

  File "N:\web2py\gluon\sqlhtml.py", line 1962, in smartgrid
user_signature=user_signature,**kwargs)
  File "N:\web2py\gluon\sqlhtml.py", line 1584, in grid
next=referrer)
  File "N:\web2py\gluon\html.py", line 1951, in process
self.validate(**kwargs)
  File "N:\web2py\gluon\html.py", line 1898, in validate
if self.accepts(**kwargs):
  File "N:\web2py\gluon\sqlhtml.py", line 1265, in accepts
self.table._db(self.table._id == self.record.id).update(**fields)
  File "N:\web2py\gluon\dal.py", line 6346, in update
return self.db._adapter.update(tablename,self.query,fields)
  File "N:\web2py\gluon\dal.py", line 1093, in update
self.execute(sql)
  File "N:\web2py\gluon\dal.py", line 1359, in execute
return self.log_execute(*a, **b)
  File "N:\web2py\gluon\dal.py", line 1353, in log_execute
ret = self.cursor.execute(*a, **b)
IntegrityError: column username is not unique



Re: [web2py] Re: Multiselect form and many-to-many relationship

2012-04-15 Thread Chris Rowson
Heh, no worries. :-)

I wonder, just out of interest, is there any great performance difference
between searching for records containing region.id 'x' (as below) rather
than returning all rows with region.id 'x' from a junction table?

Chris

On Sat, Apr 14, 2012 at 11:34 PM, villas  wrote:

> Oops I think I got confused with the vertical bars,  try it with just a
> plain integer:
> houses = db(db.house_types.regions.**contains(7)).select()
>
>
> On Saturday, 14 April 2012 22:33:54 UTC+1, leftcase wrote:
>
>> Thank you again David,
>>
>> I shall give it a go.
>>
>> Chris
>>
>>
>> On Sat, Apr 14, 2012 at 10:29 PM, villas wrote:
>>
>>> Yes,  it would store the ids of the regions between vertical bars,
>>> something like this: |4|7|23|.  So say you are looking for the house-types
>>> in China (which is id = 7).  It would be something like this:
>>>
>>> if you already have the record id no.7,  then just this:
>>> houses = db(db.house_types.regions.**contains('|7|')).select()
>>>
>>> Or, you might have the find the record no. first:
>>> china_rec = db(db.regions.name == 'China').select(db.regions.id)**
>>> .first()
>>> houses = db(db.house_types.regions.**contains('|'+str(china_rec.id)**
>>> +'|')).select()
>>>
>>> As long as your requirements are not too complex it seems to work well.
>>>  See also the book.  DAL chapter, search for list:reference.
>>>
>>> Regards, D
>>>
>>> On Saturday, 14 April 2012 21:27:34 UTC+1, leftcase wrote:
>>>
 Hi David,

 Thanks for your reply.

 I did come across the list:reference option while trying to figure this
 out. I couldn't figure this out though:

 Say I add the following to my house-type table:

Field('regions', 'list:reference region')

 If I generate a form using SQLFORM, it presents me with a multiselect
 region option where I can select as many regions as I need. Reading around,
 it seems that the region field would then store something like this for
 instance:

'england', 'france', 'US', 'china'

 How do I then create a query to show all house-type records with a
 region of 'china' for instance?

 I'm not an experienced user of development frameworks like this. Is it
 usually this difficult to accomplish this kind of thing? Seems to me it
 would be a pretty common requirement?

 Thanks in advance, :-)

 Chris

 On Sat, Apr 14, 2012 at 8:52 PM, villas wrote:

> I would just mention that if you only have a few regions/housetypes,
>  you might consider de-normalising the data and using list:reference and
> work with the jQuery.multiselect (if you have any problems with that,  you
> might like to read my other thread on the topic).
> Best regards,  David
>
> On Saturday, 14 April 2012 18:31:58 UTC+1, leftcase wrote:
>>
>> Hi all,
>>
>> I'm pretty new to web2py and web app development and I've spend some
>> time trying to figure out the best way to do this.
>>
>> I have two tables, house-types and regions. A house-type can exist in
>> many regions, and a region can have many house types:
>>
>> db.define_table(
>> 'region',
>> Field('name', 'string', length=512, required=True),
>> format = '%(name)s')
>>
>> db.define_table(
>> 'house-type',
>> Field('title', 'string', length=512), #title of the newbuild
>> property listing
>> Field('vendor',db.vendor, required=True),
>> Field('bedrooms', 'integer'),
>> Field('price', 'double',required=True),
>> Field('description', 'text',length=65536, required=True),
>> Field('live', 'boolean', default=False)
>> )
>>
>> If I understand correctly, in order to create the many-to-many
>> relationship I should create a junction table like the following:
>>
>> db.define_table(
>>'houses_and_regions',
>>Field('house', db.house-type),
>>Field('region', db.region))
>>
>> And then I should use SQLFORM to construct a form which updates both
>> house-type and houses_and_region tables when I create or modify a new 
>> house.
>>
>> What I'm struggling with is how to create a form which allows me to
>> select multiple regions for a house. I wondered if anyone could give me 
>> any
>> examples?
>>
>> Thanks in advance!
>>
>> Chris
>>
>

>>


[web2py] Re: Vertical lines around database string values

2012-04-15 Thread Yarin
This went away, don't know why or how..

On Saturday, April 14, 2012 11:17:51 AM UTC-4, Yarin wrote:
>
> When inserting records with web2py's db class, my string values have 
> vertical bars surrounding them. I don't remember seeing this behavior 
> before. What's more, if i insert records through web2py's db admin 
> interface, i don't get vertical bars.
>
> What are the vertical bars - is it a unicode thing? - and how are we 
> supposed to handle them?
>


[web2py] Re: vCard and vEvent

2012-04-15 Thread Anthony

>
> In a web2py application I generate .vcf and .ics files using web2py's 
> templating features. The problem is that all the code in {{}} results in 
> empty lines, which is no problem on my Mac, but Google doesn't allow empty 
> lines. For example, this: 
>
> {{response.headers['Content-Disposition'] = 'attachment;filename=%s.vcf' % 
> IS_SLUG()(organization.name)[0]}}BEGIN:VCARD
> VERSION:4.0
> {{if organization:}}
> FN: {{=organization.name}}
> ORG: {{=organization.name}}
> {{pass}}
>

You could do:

{{if organization:}}FN: {{=organization.name}}
ORG: {{=organization.name}}{{pass}}

and you won't get any blank lines when there is an organization, but I 
think you'll still get two blank lines when there is no organization.

Another option might be to render the response in the controller and then 
remove any blank lines from the text:

def make_vcard():
data = [code to generate vcard data]
vcard = response.render(context=dict(data=data))
return vcard.replace('\n\n', '\n')

Anthony



[web2py] Re: How to create a form from db.mytable, add checkboxes to each row and use form.custom.begin?

2012-04-15 Thread DenesL

Only SQLFORM has a custom attribute.
You are using FORM.

 


[web2py] Re: how to access google spreadsheets using Oauth2 in web2py

2012-04-15 Thread Massimo Di Pierro
Look into gluon/contrib/login_methods/oauth2_auth.py there is sample code 
in there.

On Saturday, 14 April 2012 09:33:51 UTC-5, SB wrote:
>
> how to access google spreadsheets using Oauth2 in web2py. Need help.
>


[web2py] Re: Design of a minimal chat-like application in Web2py

2012-04-15 Thread Massimo Di Pierro
there is a chat in KPAX (in its own controller). Not very efficient because 
does not uses websockets but works. You may want to look also into 
gluon/contrib/comet_messaging.py

On Friday, 13 April 2012 17:30:19 UTC-5, cyan wrote:
>
>
> Hi group,
>
> I am trying to make a minimal multiuser chat-like app using Web2py. 
> Nothing too fancy here, I just need the app to be able to do the following:
>
> 1. client browsers can send the receive text msgs from a server
> 2. server may manipulate the msgs received and selectively routes those 
> msgs to different client browsers
> 3. server pushes msgs to client browsers using either comet or websocket 
> or (something else? please enlighten me here).
> 4. it would be nice if the server can remember the client so that if a 
> client drops and comes back in, all the previous sent/received msgs are 
> remembered and shown, but this is not essential.
>
> So how should I design this given the MVC model of Web2py? What extra 
> pieces (besides Javascript on the client side) do I need? Thanks!
>
>

[web2py] Re: new feature in trunk: full auditing

2012-04-15 Thread Massimo Di Pierro
Fixed in trunk.

On Saturday, 14 April 2012 23:10:18 UTC-5, tomt wrote:
>
> I discovered why the archive table wasn't being created, there is a typo 
> in gluon/tools.py at line 1293:
> for table in tables: 
> if 'modifed_on' in table.fields():
> should be
> for table in tables: 
> if 'modified_on' in table.fields():
>
> Now the the 'mythings_archive' table is created as expected, and changes 
> are recorded in it as expected.
>
> I didn't mention it before, but I expect that the builtin audit feature 
> will be very useful for my applications.  This feature along with the 
> addition of SQLFORM.grid have made web2py enormously more productive.
>
> Thanks to all the developers for all these improvements.
> - Tom
>
>
>
> On Friday, April 13, 2012 10:53:10 PM UTC-6, tomt wrote:
>>
>> I'm have been trying to test this new audit function in trunk, but so far 
>> the mything_archive table has never been created in any of my tests.
>>
>> Is this the current state of the implementation, or am I missing 
>> something?
>>
>> I downloaded the latest trunk and used it web2py admin to create a new 
>> app.
>>
>> I then modified db.py according to the instructions in this thread:
>> 
>> auth = Auth(db, hmac_key=Auth.get_or_create_key())
>> auth.define_tables(username=True, signature=True)
>> ...
>> db.define_table("points",
>> Field('type','integer'),
>> Field('point','integer'),
>> Field('pointname','string'),
>> auth.signature)
>> auth.enable_record_versioning(db)
>> 
>>
>> I've tried this with both mysql and sqlite databases, but no *_archive 
>> table...
>>
>>
>> Any comments or suggestions?
>>
>> thanks, - Tom
>>
>>
>>
>> On Thursday, April 5, 2012 4:16:04 PM UTC-6, Massimo Di Pierro wrote:
>>>
>>> This is how it works:
>>>
>>> # define auth 
>>> auth = Auth(db, hmac_key=Auth.get_or_create_key())
>>> auth.define_tables(username=True,signature=True)
>>>
>>> # define your own tables like
>>> db.define_table('mything',Field('name'),auth.signature)
>>>
>>> # than do:
>>> auth.enable_record_versioning(db)
>>>
>>> how does it work? every table, including auth_user will have an 
>>> auth.signature including created_by, created_on, modified_by, modified_on, 
>>> is_active fields. When a record of table mything (or any other table) is 
>>> modified, a copy of the previous record is copied into mything_archive 
>>> which references the current record. When a record is deleted, it is not 
>>> actually deleted but is_active is set to False, all records with 
>>> is_active==False are filtered out in searches except in appadmin.
>>>
>>> Pros:
>>> - your app will get full record archival for auditing purposes
>>> - could not be simpler. nothing else to do. Try with 
>>> SQLFORM.grid(db.mything) for example.
>>> - does not break references and there is no need for uuids
>>> - does not slow down searches because archive is done in separate 
>>> archive tables
>>>
>>> Cons:
>>> - uses lots of extra memory because every version of a record is stored 
>>> (it would be more efficient to store changes only but that would make more 
>>> difficult to do auditing).
>>> - slows down db(...).update(...) for multi record because it needs to 
>>> copy all records needing update from the original table to the archive 
>>> table. This requires selecting all the records.
>>>
>>> Comments? Suggestions?
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>> On Thursday, April 5, 2012 4:16:04 PM UTC-6, Massimo Di Pierro wrote:
>>>
>>> This is how it works:
>>>
>>> # define auth 
>>> auth = Auth(db, hmac_key=Auth.get_or_create_key())
>>> auth.define_tables(username=True,signature=True)
>>>
>>> # define your own tables like
>>> db.define_table('mything',Field('name'),auth.signature)
>>>
>>> # than do:
>>> auth.enable_record_versioning(db)
>>>
>>> how does it work? every table, including auth_user will have an 
>>> auth.signature including created_by, created_on, modified_by, modified_on, 
>>> is_active fields. When a record of table mything (or any other table) is 
>>> modified, a copy of the previous record is copied into mything_archive 
>>> which references the current record. When a record is deleted, it is not 
>>> actually deleted but is_active is set to False, all records with 
>>> is_active==False are filtered out in searches except in appadmin.
>>>
>>> Pros:
>>> - your app will get full record archival for auditing purposes
>>> - could not be simpler. nothing else to do. Try with 
>>> SQLFORM.grid(db.mything) for example.
>>> - does not break references and there is no need for uuids
>>> - does not slow down searches because archive is done in separate 
>>> archive tables
>>>
>>> Cons:
>>> - uses lots of extra memory because every version of a record is stored 
>>> (it would be more efficient to store changes only but that would make more 
>>> difficult to do auditing).
>>> - slows down db(...).update(...) f

[web2py] Re: smartgrid crashes when submitting a duplicate field value

2012-04-15 Thread Massimo Di Pierro
Please submit a google code ticket.

On Sunday, 15 April 2012 06:09:19 UTC-5, weheh wrote:
>
> If smartgrid is used to edit the values of fields in auth_user that are 
> designated unique=True, smartgrid will crash when a duplicate value is 
> entered. Here's a ticket trace. SQLite is the underlying db. Incidentally, 
> this is my first go at grid and smartgrid and I'm very impressed. Kudos.
>
>   File "N:\web2py\gluon\sqlhtml.py", line 1962, in smartgrid
> user_signature=user_signature,**kwargs)
>   File "N:\web2py\gluon\sqlhtml.py", line 1584, in grid
> next=referrer)
>   File "N:\web2py\gluon\html.py", line 1951, in process
> self.validate(**kwargs)
>   File "N:\web2py\gluon\html.py", line 1898, in validate
> if self.accepts(**kwargs):
>   File "N:\web2py\gluon\sqlhtml.py", line 1265, in accepts
> self.table._db(self.table._id == self.record.id).update(**fields)
>   File "N:\web2py\gluon\dal.py", line 6346, in update
> return self.db._adapter.update(tablename,self.query,fields)
>   File "N:\web2py\gluon\dal.py", line 1093, in update
> self.execute(sql)
>   File "N:\web2py\gluon\dal.py", line 1359, in execute
> return self.log_execute(*a, **b)
>   File "N:\web2py\gluon\dal.py", line 1353, in log_execute
> ret = self.cursor.execute(*a, **b)
> IntegrityError: column username is not unique
>
>

[web2py] Re: How to create a form from db.mytable, add checkboxes to each row and use form.custom.begin?

2012-04-15 Thread web2py_Superfan
Thanks a bunch DenesL,  Do you know how I could use SQLFORM and have the 
checkboxes added to each row in the form?  I couldn't figure that out.

On Sunday, April 15, 2012 7:12:13 AM UTC-7, DenesL wrote:
>
>
> Only SQLFORM has a custom attribute.
> You are using FORM.
>
>  
>


[web2py] Re: How to create a form from db.mytable, add checkboxes to each row and use form.custom.begin?

2012-04-15 Thread web2py_Superfan
when I change FORM to SQLFORM i get error

'THEAD' object has no attribute 'writable'



On Sunday, April 15, 2012 7:58:37 AM UTC-7, web2py_Superfan wrote:
>
> Thanks a bunch DenesL,  Do you know how I could use SQLFORM and have the 
> checkboxes added to each row in the form?  I couldn't figure that out.
>
> On Sunday, April 15, 2012 7:12:13 AM UTC-7, DenesL wrote:
>>
>>
>> Only SQLFORM has a custom attribute.
>> You are using FORM.
>>
>>  
>>
>

Re: [web2py] Re: Multiselect form and many-to-many relationship

2012-04-15 Thread villas
Depends,  but I think there would always be a difference in favour of 
normalized data because the data access is fully indexed.  However,  this 
difference may be almost negligible if your main table is less than say 10K 
records and your queries are simple.  

In my experience,  where performance differences are slight,  it is almost 
always better to go with the easiest coding -- it is better to get the job 
done than study the latest indexing algorithms!  

You should consider how complex your queries will be,  and it is probably 
advisable to do your own tests on your chosen platform. 

One other advantage of denormalized data is that by avoiding joins it makes 
it easier to use NoSql databases,  if in the future you want to go that way.

David


On Sunday, 15 April 2012 13:16:31 UTC+1, leftcase wrote:
>
> Heh, no worries. :-)
>
> I wonder, just out of interest, is there any great performance difference 
> between searching for records containing region.id 'x' (as below) rather 
> than returning all rows with region.id 'x' from a junction table?
>
> Chris
>
> On Sat, Apr 14, 2012 at 11:34 PM, villas  wrote:
>
>> Oops I think I got confused with the vertical bars,  try it with just a 
>> plain integer:
>> houses = db(db.house_types.regions.**contains(7)).select() 
>>
>>
>> On Saturday, 14 April 2012 22:33:54 UTC+1, leftcase wrote:
>>
>>> Thank you again David,
>>>
>>> I shall give it a go.
>>>
>>> Chris
>>>
>>>
>>> On Sat, Apr 14, 2012 at 10:29 PM, villas wrote:
>>>
 Yes,  it would store the ids of the regions between vertical bars, 
 something like this: |4|7|23|.  So say you are looking for the house-types 
 in China (which is id = 7).  It would be something like this:

 if you already have the record id no.7,  then just this:
 houses = db(db.house_types.regions.**contains('|7|')).select()

 Or, you might have the find the record no. first:
 china_rec = db(db.regions.name == 'China').select(db.regions.id)**
 .first()
 houses = db(db.house_types.regions.**contains('|'+str(china_rec.id)**
 +'|')).select()

 As long as your requirements are not too complex it seems to work well. 
  See also the book.  DAL chapter, search for list:reference.

 Regards, D

 On Saturday, 14 April 2012 21:27:34 UTC+1, leftcase wrote:

> Hi David,
>
> Thanks for your reply.
>
> I did come across the list:reference option while trying to figure 
> this out. I couldn't figure this out though:
>
> Say I add the following to my house-type table:
>
>Field('regions', 'list:reference region')
>
> If I generate a form using SQLFORM, it presents me with a multiselect 
> region option where I can select as many regions as I need. Reading 
> around, 
> it seems that the region field would then store something like this for 
> instance: 
>
>'england', 'france', 'US', 'china'
>
> How do I then create a query to show all house-type records with a 
> region of 'china' for instance?
>
> I'm not an experienced user of development frameworks like this. Is it 
> usually this difficult to accomplish this kind of thing? Seems to me it 
> would be a pretty common requirement?
>
> Thanks in advance, :-)
>
> Chris
>
> On Sat, Apr 14, 2012 at 8:52 PM, villas wrote:
>
>> I would just mention that if you only have a few regions/housetypes, 
>>  you might consider de-normalising the data and using list:reference and 
>> work with the jQuery.multiselect (if you have any problems with that,  
>> you 
>> might like to read my other thread on the topic). 
>> Best regards,  David
>>
>> On Saturday, 14 April 2012 18:31:58 UTC+1, leftcase wrote:
>>>
>>> Hi all,
>>>
>>> I'm pretty new to web2py and web app development and I've spend some 
>>> time trying to figure out the best way to do this.
>>>
>>> I have two tables, house-types and regions. A house-type can exist 
>>> in many regions, and a region can have many house types:
>>>
>>> db.define_table(
>>> 'region',
>>> Field('name', 'string', length=512, required=True),
>>> format = '%(name)s')
>>>
>>> db.define_table(
>>> 'house-type',
>>> Field('title', 'string', length=512), #title of the newbuild 
>>> property listing
>>> Field('vendor',db.vendor, required=True),
>>> Field('bedrooms', 'integer'),
>>> Field('price', 'double',required=True),
>>> Field('description', 'text',length=65536, required=True),
>>> Field('live', 'boolean', default=False)
>>> )
>>>
>>> If I understand correctly, in order to create the many-to-many 
>>> relationship I should create a junction table like the following:
>>>
>>> db.define_table(
>>>'houses_and_regions',
>>>Field('house', db.house-type),
>>>Field('r

[web2py] Re: How to create a form from db.mytable, add checkboxes to each row and use form.custom.begin?

2012-04-15 Thread DenesL

You can not just substitute FORM with SQLFORM.
In your case it is better to stick with FORM and use element to access and 
modify the table inside the form.

tbod=form.element('table tbody') # the body of the SQLTABLE
tbod is a list of the table rows, so tbod[0] is the first TR
and each TR is a list of TDs, so you can append to each the checkbox or 
anything else you need.

Hope this helps.

On Sunday, April 15, 2012 11:27:19 AM UTC-4, web2py_Superfan wrote:
>
> when I change FORM to SQLFORM i get error
>
> 'THEAD' object has no attribute 'writable'
>
>
>
> On Sunday, April 15, 2012 7:58:37 AM UTC-7, web2py_Superfan wrote:
>>
>> Thanks a bunch DenesL,  Do you know how I could use SQLFORM and have the 
>> checkboxes added to each row in the form?  I couldn't figure that out.
>>
>> On Sunday, April 15, 2012 7:12:13 AM UTC-7, DenesL wrote:
>>>
>>>
>>> Only SQLFORM has a custom attribute.
>>> You are using FORM.
>>>
>>>  
>>>
>>

[web2py] Re: How to create a form from db.mytable, add checkboxes to each row and use form.custom.begin?

2012-04-15 Thread web2py_Superfan
Thanks again, will give it a shot

On Sunday, April 15, 2012 9:39:32 AM UTC-7, DenesL wrote:
>
>
> You can not just substitute FORM with SQLFORM.
> In your case it is better to stick with FORM and use element to access and 
> modify the table inside the form.
>
> tbod=form.element('table tbody') # the body of the SQLTABLE
> tbod is a list of the table rows, so tbod[0] is the first TR
> and each TR is a list of TDs, so you can append to each the checkbox or 
> anything else you need.
>
> Hope this helps.
>
> On Sunday, April 15, 2012 11:27:19 AM UTC-4, web2py_Superfan wrote:
>>
>> when I change FORM to SQLFORM i get error
>>
>> 'THEAD' object has no attribute 'writable'
>>
>>
>>
>> On Sunday, April 15, 2012 7:58:37 AM UTC-7, web2py_Superfan wrote:
>>>
>>> Thanks a bunch DenesL,  Do you know how I could use SQLFORM and have the 
>>> checkboxes added to each row in the form?  I couldn't figure that out.
>>>
>>> On Sunday, April 15, 2012 7:12:13 AM UTC-7, DenesL wrote:


 Only SQLFORM has a custom attribute.
 You are using FORM.

  

>>>

Re: [web2py] CPU 210%

2012-04-15 Thread Bruce Wade
I think it was the server. I rebuilt/installed from scratch OS etc.. the
server last night and now it seems to be running without problems. I am
slowing increasing the load to see how well it handles before moving it to
the new site again.

On Sat, Apr 14, 2012 at 8:13 PM, Bruno Rocha  wrote:

> We have to see significant part of the code too figure out what is going
> on...
>
> http://zerp.ly/rochacbruno
> Em 14/04/2012 22:45, "Bruce Wade"  escreveu:
>
> Hi,
>>
>> So I just launched and have been hit with a tone of traffic and my CPU on
>> linode is showing 210% usage. Any suggestions?
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/brucelwade
>> http://www.wadecybertech.com
>> http://www.fittraineronline.com - Fitness Personal Trainers Online
>> http://www.warplydesigned.com
>>
>>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


[web2py] Anyone use Jmeter for load testing web2py before?

2012-04-15 Thread Bruce Wade
Hi,

I want to load test my server to see how much it can handle while running
my web2py app. I came across Jmeter has any used this or have a better
suggestion?

http://jmeter.apache.org/

-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


Re: [web2py] shared host deployment of my web2py site

2012-04-15 Thread Keith Edmunds
On Sun, 15 Apr 2012 07:36:19 +0100, doncoleon...@gmail.com said:

> So you mean I should just click the 'configure' file?

You need to do this from the command line.

> And how do I add
> the parameters, are u saying

It's "you", not "u".

You need a open a terminal window and type in the commands you quoted
originally.
-- 
"You can have everything in life you want if you help enough other people
get what they want" - Zig Ziglar. 

Who did you help today?


Re: [web2py] Eclipse and autocomplete

2012-04-15 Thread cyan

I've just tried it out.

Unzip the latest stable source code of web2py to a folder, say, 
"web2py_src".
Go to Eclipse - Preferences - PyDev - 'Interpreter - Python'
In the 'System PYTHONPATH' window, add 'web2py_src' to the path.

So far, it seems autocomplete is working without doing all the import 
statements... Hope it helps.

On Monday, April 9, 2012 3:04:30 PM UTC-4, ikdme wrote:
>
> Tang, please how do i implement this your suggestion?
>
> On Thu, Apr 5, 2012 at 3:54 PM, Xiaofeng Tang wrote:
>
>> I use PyDev and add web2py src into "PyDev - PythonPath" to resolve the
>> incorrect refs and enable autocompletion.
>>
>> Alternatively, u could install the path of web2py src into systeml
>> envirnoment vairable "pythonpath".
>>
>> --- on 2012/4/5 22:51:41, Rod Watkins  wrote:
>> > I know this has been asked before. I don't mean to be an annoyance.
>> > I've done the searches are read numerous posts about how to handle
>> > this. But the advice conflicts and I've yet to actually fix the problem.
>> >
>> > What is the best way to handle imports for eclipse to get autocomplete
>> > to work properly (as well as rid eclipse of all the incorrect error
>> > messages?
>> >
>> > I rather like having autocomplete functioning since, as a beginner, it
>> > helps me discover functionality that I might otherwise miss (besides
>> > saving some typing).
>> >
>> > Please accept my thanks in advance for any help on this.
>> >
>> > Cordially,
>> > Rod Watkins
>>
>>
>

[web2py] routes.py

2012-04-15 Thread namfonos
got a problem with my routes
routes_in = (
  ('/asdf', '/aggat/default/rules'),
)
routes_out = (
  ('/aggat/default/rules', '/asdf'),
)
 isn't working, but i followed the same format on the web2py tutorial 
 defining the base router works when i have that defined alone


[web2py] Re: DAL IMAP errors

2012-04-15 Thread Alan Etkin
Not fixed yet in trunk. There is a regex replacement proposal in the issue 
page by Massimo.

El sábado, 14 de abril de 2012 22:44:41 UTC-3, pyhead escribió:
>
>
> Hi web2py users,
>
> db = DAL('imap://') successfully logs in to the mail server, but fails 
> when the commonly used spaces or '.' are returned in a folder name. Is 
> there any way to substitute not allowed characters for '_' so imap works?
>  only [0-9a-zA-Z_] allowed in table and 
> field names, received Gmail_All Mail
>
> This was reported and was flagged as accepted, so the fix should already 
> be in the nightly build, right?
> http://code.google.com/p/web2py/issues/detail?id=644
>
> Please share the recipe if you are successfully using DAL with IMAP.  I am 
> developing a web2py email client and this is crucial to its success.  Thank 
> you!
>

El sábado, 14 de abril de 2012 22:44:41 UTC-3, pyhead escribió:
>
>
> Hi web2py users,
>
> db = DAL('imap://') successfully logs in to the mail server, but fails 
> when the commonly used spaces or '.' are returned in a folder name. Is 
> there any way to substitute not allowed characters for '_' so imap works?
>  only [0-9a-zA-Z_] allowed in table and 
> field names, received Gmail_All Mail
>
> This was reported and was flagged as accepted, so the fix should already 
> be in the nightly build, right?
> http://code.google.com/p/web2py/issues/detail?id=644
>
> Please share the recipe if you are successfully using DAL with IMAP.  I am 
> developing a web2py email client and this is crucial to its success.  Thank 
> you!
>

El sábado, 14 de abril de 2012 22:44:41 UTC-3, pyhead escribió:
>
>
> Hi web2py users,
>
> db = DAL('imap://') successfully logs in to the mail server, but fails 
> when the commonly used spaces or '.' are returned in a folder name. Is 
> there any way to substitute not allowed characters for '_' so imap works?
>  only [0-9a-zA-Z_] allowed in table and 
> field names, received Gmail_All Mail
>
> This was reported and was flagged as accepted, so the fix should already 
> be in the nightly build, right?
> http://code.google.com/p/web2py/issues/detail?id=644
>
> Please share the recipe if you are successfully using DAL with IMAP.  I am 
> developing a web2py email client and this is crucial to its success.  Thank 
> you!
>


[web2py]

2012-04-15 Thread Bruce Wade
Does web2py automatically save a cPickle in the database as gluon.storage?
Because I saved ads with the web2py framework, however now when trying to
load them with the old framework I get an error ImportError: No module
named gluon.storage when I don't use gluon at all in that old framework.

-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


[web2py] Re:

2012-04-15 Thread Anthony
What exactly did you save in the database?

On Sunday, April 15, 2012 8:10:50 PM UTC-4, Bruce Wade wrote:
>
> Does web2py automatically save a cPickle in the database as gluon.storage? 
> Because I saved ads with the web2py framework, however now when trying to 
> load them with the old framework I get an error ImportError: No module 
> named gluon.storage when I don't use gluon at all in that old framework.
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>

Re: [web2py] Re:

2012-04-15 Thread Bruce Wade
   ads = []
   if random_ads:
for index, url in enumerate(random_ads):
ads.append({
'index': index,
'id': url['id'],
'url': url['url'],
'valid': '',
'suburlcount': '',
'viewcanceled': '',
'timestart': '',
'timeend': '',
'rating': ''
})
ads_to_view = cPickle.dumps(ads)
#print "Unseen", len(ads)
# Create todays ads to view
self.db.viewedads.insert(member_id=member, date=date,
adsviewed=ads_to_view)

On Sun, Apr 15, 2012 at 5:17 PM, Anthony  wrote:

> What exactly did you save in the database?
>
>
> On Sunday, April 15, 2012 8:10:50 PM UTC-4, Bruce Wade wrote:
>>
>> Does web2py automatically save a cPickle in the database as
>> gluon.storage? Because I saved ads with the web2py framework, however now
>> when trying to load them with the old framework I get an error ImportError:
>> No module named gluon.storage when I don't use gluon at all in that old
>> framework.
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/**brucelwade
>> http://www.wadecybertech.com
>> http://www.fittraineronline.**com  -
>> Fitness Personal Trainers Online
>> http://www.warplydesigned.com
>>
>>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


Re: [web2py] Re:

2012-04-15 Thread Anthony
And what are the index, url['id'], and url['url'] objects? Are any of them 
storage objects?

On Sunday, April 15, 2012 8:19:45 PM UTC-4, Bruce Wade wrote:
>
>ads = []
>if random_ads:
> for index, url in enumerate(random_ads):
> ads.append({
> 'index': index,
> 'id': url['id'],
> 'url': url['url'],
> 'valid': '',
> 'suburlcount': '',
> 'viewcanceled': '',
> 'timestart': '',
> 'timeend': '',
> 'rating': ''
> })
> ads_to_view = cPickle.dumps(ads)
> #print "Unseen", len(ads)
> # Create todays ads to view
> self.db.viewedads.insert(member_id=member, date=date, 
> adsviewed=ads_to_view)
>
> On Sun, Apr 15, 2012 at 5:17 PM, Anthony  wrote:
>
>> What exactly did you save in the database?
>>
>>
>> On Sunday, April 15, 2012 8:10:50 PM UTC-4, Bruce Wade wrote:
>>>
>>> Does web2py automatically save a cPickle in the database as 
>>> gluon.storage? Because I saved ads with the web2py framework, however now 
>>> when trying to load them with the old framework I get an error ImportError: 
>>> No module named gluon.storage when I don't use gluon at all in that old 
>>> framework.
>>>
>>> -- 
>>> -- 
>>> Regards,
>>> Bruce Wade
>>> http://ca.linkedin.com/in/**brucelwade
>>> http://www.wadecybertech.com
>>> http://www.fittraineronline.**com  - 
>>> Fitness Personal Trainers Online
>>> http://www.warplydesigned.com
>>>
>>>
>
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>

Re: [web2py] Re:

2012-04-15 Thread Bruce Wade
url['id'] = integer
url['url'] = string

On Sun, Apr 15, 2012 at 7:03 PM, Anthony  wrote:

> And what are the index, url['id'], and url['url'] objects? Are any of them
> storage objects?
>
>
> On Sunday, April 15, 2012 8:19:45 PM UTC-4, Bruce Wade wrote:
>>
>>ads = []
>>if random_ads:
>> for index, url in enumerate(random_ads):
>> ads.append({
>> 'index': index,
>> 'id': url['id'],
>> 'url': url['url'],
>> 'valid': '',
>> 'suburlcount': '',
>> 'viewcanceled': '',
>> 'timestart': '',
>> 'timeend': '',
>> 'rating': ''
>> })
>> ads_to_view = cPickle.dumps(ads)
>> #print "Unseen", len(ads)
>> # Create todays ads to view
>> self.db.viewedads.insert(**member_id=member, date=date,
>> adsviewed=ads_to_view)
>>
>> On Sun, Apr 15, 2012 at 5:17 PM, Anthony  wrote:
>>
>>> What exactly did you save in the database?
>>>
>>>
>>> On Sunday, April 15, 2012 8:10:50 PM UTC-4, Bruce Wade wrote:

 Does web2py automatically save a cPickle in the database as
 gluon.storage? Because I saved ads with the web2py framework, however now
 when trying to load them with the old framework I get an error ImportError:
 No module named gluon.storage when I don't use gluon at all in that old
 framework.

 --
 --
 Regards,
 Bruce Wade
 http://ca.linkedin.com/in/**bruc**elwade
 http://www.wadecybertech.com
 http://www.fittraineronline.**co**m - 
 Fitness Personal Trainers Online
 http://www.warplydesigned.com


>>
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/**brucelwade
>> http://www.wadecybertech.com
>> http://www.fittraineronline.**com  -
>> Fitness Personal Trainers Online
>> http://www.warplydesigned.com
>>
>>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


[web2py] Re: Add conditional sub-menu

2012-04-15 Thread Cliff
Omi,

Sorry, my bad.  Been away.

Should be:
sub_menu = [('Admin',  False,  URL('admin'), []), ] # Added empty list

On Thursday, April 12, 2012 9:43:39 AM UTC-4, Omi Chiba wrote:
>
> Cliff, 
>
> Thank you for sharing code but now I got a different error. Maybe it 
> cannot understand sub_menu contains three parameters..
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 205, in restricted
> exec ccode in environment
>   File "C:\web2py\applications\home\views\default/index.html", line 64, in 
> 
>   File "C:\web2py\gluon\globals.py", line 182, in write
> self.body.write(xmlescape(data))
>   File "C:\web2py\gluon\html.py", line 114, in xmlescape
> return data.xml()
>   File "C:\web2py\gluon\html.py", line 2146, in xml
> return self.serialize(self.data, 0).xml()
>   File "C:\web2py\gluon\html.py", line 2121, in serialize
> li.append(self.serialize(item[3], level+1))
>   File "C:\web2py\gluon\html.py", line 2109, in serialize
> (name, active, link) = item[:3]
> ValueError: need more than 0 values to unpack
>
> On Wednesday, April 11, 2012 11:00:30 PM UTC-5, Cliff wrote:
>>
>> I have something like this working:
>>
>> sub_menu = []
>> if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))):
>> sub_menu = [('Admin',  False,  URL('admin')), ]
>> response.menu = [('Home', False, URL('home','default','index'), []),
>> (SPAN('Price List',_style='color:yellow'), True, 
>> URL('pricelist','default','index'), 
>> [('Guideline',  False,  URL('pricelist','default','guideline')),
>>  ('Multiplier Tables',  False, 
>>  URL('pricelist','default','multitable')),
>>  ('Cut Charge Tables',  False, 
>>  URL('pricelist','default','cuttable')),
>>  (sub_menu),
>> ])]
>>
>> On Wednesday, April 11, 2012 12:24:29 PM UTC-4, Omi Chiba wrote:
>>>
>>> The following menu works. It's add "Admin" menu next to "Price List" if 
>>> the user has role "admin". Now, I want to add the "Admin" menu as sub-menu 
>>> of "Price List" where it's right after the "Cut Charge Tables". How can I 
>>> do this ?
>>>
>>> response.menu = [('Home', False, URL('home','default','index'), []),
>>> (SPAN('Price List',_style='color:yellow'), True, 
>>> URL('pricelist','default','index'), 
>>> [('Guideline',  False,  URL('pricelist','default','guideline')),
>>>  ('Multiplier Tables',  False, 
>>>  URL('pricelist','default','multitable')),
>>>  ('Cut Charge Tables',  False, 
>>>  URL('pricelist','default','cuttable')),
>>> ])]
>>>
>>> if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))):
>>> response.menu += [('Admin',  False,  URL('admin')), ]
>>>
>>

[web2py] Re: Browser back button: Reloading database results

2012-04-15 Thread Cliff
Good point.

Also that is the rule of thumb for we applications.

A request that can make a change to a resource should be a POST.

A request to access a resource should be a GET.

On Thursday, April 12, 2012 8:15:09 AM UTC-4, villas wrote:
>
> My conclusion is that it is better to submit search forms with GET.  
> Not only does it seem to avoid this problem,  it allows users to bookmark 
> searches.
> I create the search form with SQLFORM.factory and usually use 
> keepvalues=True so that the user can keep his previous choice.
> I hope this is relevant for you.
> Best Regards,
> David
>
> On Wednesday, 11 April 2012 22:07:50 UTC+1, DJ wrote:
>>
>> Hello W2People,
>>
>> This may be a simple setting that I am unaware of - how does one retain 
>> the database search results when you click the Back Button on the browser 
>> without having to refresh the page and confirming?
>>
>> Thank you,
>> Sebastian
>>
>

[web2py] how to intercept password before encryption, if possible?

2012-04-15 Thread weheh
I'm building an administrative interface where only the admin can register 
new users. Upon registering a new user, the system will email login and 
initial temporary password to user. I'm using the auth_user table but with 
a customized form and create action. Is there a way to capture the password 
before it's encrypted?

Obviously, I can have the admin enter the password twice, the second time 
as a string, but that's a little user hostile. I could make an ajax call 
that would copy it behind the scenes, but that's extra work. What's the 
easy way?

def create():
"""adds a new user to the auth_user database"""
response.sub_title = T('Add New User')
form = SQLFORM.factory(
db.auth_user.username,
db.auth_user.password,
db.auth_user.email,
)
# password not available here
if form.process(onvalidation=get_password).accepted:
user_id = db.auth_user.insert(
username=form.vars.username,
password=form.vars.password,  # password already encrypted 
here
email=form.vars.email,
)
send_new_user_mail(form.vars.username, form.vars.email, response.
password)
session.flash = T('Added new user')
redirect(URL(c='user', f='manage_users'))
elif form.errors:
response.flash = T('Please correct errors')
return dict(form=form)

def get_password(form):
# password already encrypted here
...


Re: [web2py] Re: Add conditional sub-menu

2012-04-15 Thread Omi Chiba
Cliff,

Thanks ! I'm on vacation but I will try when I come back but I'm sure it
works !!


On Sun, Apr 15, 2012 at 9:52 PM, Cliff  wrote:

> Omi,
>
> Sorry, my bad.  Been away.
>
> Should be:
> sub_menu = [('Admin',  False,  URL('admin'), []), ] # Added empty list
>
> On Thursday, April 12, 2012 9:43:39 AM UTC-4, Omi Chiba wrote:
>>
>> Cliff,
>>
>> Thank you for sharing code but now I got a different error. Maybe it
>> cannot understand sub_menu contains three parameters..
>>
>> Traceback (most recent call last):
>>   File "C:\web2py\gluon\restricted.**py", line 205, in restricted
>> exec ccode in environment
>>   File "C:\web2py\applications\home\**views\default/index.html", line
>> 64, in 
>>   File "C:\web2py\gluon\globals.py", line 182, in write
>> self.body.write(xmlescape(**data))
>>   File "C:\web2py\gluon\html.py", line 114, in xmlescape
>> return data.xml()
>>   File "C:\web2py\gluon\html.py", line 2146, in xml
>> return self.serialize(self.data, 0).xml()
>>   File "C:\web2py\gluon\html.py", line 2121, in serialize
>> li.append(self.serialize(item[**3], level+1))
>>   File "C:\web2py\gluon\html.py", line 2109, in serialize
>> (name, active, link) = item[:3]
>> ValueError: need more than 0 values to unpack
>>
>> On Wednesday, April 11, 2012 11:00:30 PM UTC-5, Cliff wrote:
>>>
>>> I have something like this working:
>>>
>>> sub_menu = []
>>> if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))):
>>> sub_menu = [('Admin',  False,  URL('admin')), ]
>>> response.menu = [('Home', False, URL('home','default','index'), []),
>>> (SPAN('Price List',_style='color:yellow'), True,
>>> URL('pricelist','default','**index'),
>>> [('Guideline',  False,  URL('pricelist','default','**guideline')),
>>>  ('Multiplier Tables',  False,  URL('pricelist','default','**
>>> multitable')),
>>>  ('Cut Charge Tables',  False,  URL('pricelist','default','**
>>> cuttable')),
>>>  (sub_menu),
>>> ])]
>>>
>>> On Wednesday, April 11, 2012 12:24:29 PM UTC-4, Omi Chiba wrote:

 The following menu works. It's add "Admin" menu next to "Price List" if
 the user has role "admin". Now, I want to add the "Admin" menu as sub-menu
 of "Price List" where it's right after the "Cut Charge Tables". How can I
 do this ?

 response.menu = [('Home', False, URL('home','default','index'), []),
 (SPAN('Price List',_style='color:yellow'), True,
 URL('pricelist','default','**index'),
 [('Guideline',  False,  URL('pricelist','default','**guideline')),
  ('Multiplier Tables',  False,  URL('pricelist','default','**
 multitable')),
  ('Cut Charge Tables',  False,  URL('pricelist','default','**
 cuttable')),
 ])]

 if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))):
 response.menu += [('Admin',  False,  URL('admin')), ]

>>>


Re: [web2py] how to intercept password before encryption, if possible?

2012-04-15 Thread Bruce Wade
use request.vars.password to get unencrypted and form.vars.password for
encrypted if you use requires CRYPT()

On Sun, Apr 15, 2012 at 8:06 PM, weheh  wrote:

> I'm building an administrative interface where only the admin can register
> new users. Upon registering a new user, the system will email login and
> initial temporary password to user. I'm using the auth_user table but with
> a customized form and create action. Is there a way to capture the password
> before it's encrypted?
>
> Obviously, I can have the admin enter the password twice, the second time
> as a string, but that's a little user hostile. I could make an ajax call
> that would copy it behind the scenes, but that's extra work. What's the
> easy way?
>
> def create():
> """adds a new user to the auth_user database"""
> response.sub_title = T('Add New User')
> form = SQLFORM.factory(
> db.auth_user.username,
> db.auth_user.password,
> db.auth_user.email,
> )
> # password not available here
> if form.process(onvalidation=get_password).accepted:
> user_id = db.auth_user.insert(
> username=form.vars.username,
> password=form.vars.password,  # password already
> encrypted here
> email=form.vars.email,
> )
> send_new_user_mail(form.vars.username, form.vars.email, response.
> password)
> session.flash = T('Added new user')
> redirect(URL(c='user', f='manage_users'))
> elif form.errors:
> response.flash = T('Please correct errors')
> return dict(form=form)
>
> def get_password(form):
> # password already encrypted here
> ...
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


[web2py] Re: how to intercept password before encryption, if possible?

2012-04-15 Thread Matt Gorecki
In one of my applications, I create users by hand as well with a custom 
form.  My flow goes something like this:

1. Fill out the Create User form. There are is no password field here.
2. In the function that processes the form, I generate a random, readable 
password at the beginning.
3. Before inserting into the database, I encrypt the password:
my_crypt = CRYPT(key=auth.settings.hmac_key)
crypt_pass = my_crypt(passwd)[0]

4. Once that is successful, I send the email out with the plaintext 
password from the beginning.


Here's the function I use to generate a readable, random password.  
https://gist.github.com/2396242


Matt Gorecki

On Sunday, April 15, 2012 9:06:21 PM UTC-6, weheh wrote:
>
> I'm building an administrative interface where only the admin can register 
> new users. Upon registering a new user, the system will email login and 
> initial temporary password to user. I'm using the auth_user table but with 
> a customized form and create action. Is there a way to capture the password 
> before it's encrypted?
>
> Obviously, I can have the admin enter the password twice, the second time 
> as a string, but that's a little user hostile. I could make an ajax call 
> that would copy it behind the scenes, but that's extra work. What's the 
> easy way?
>
> def create():
> """adds a new user to the auth_user database"""
> response.sub_title = T('Add New User')
> form = SQLFORM.factory(
> db.auth_user.username,
> db.auth_user.password,
> db.auth_user.email,
> )
> # password not available here
> if form.process(onvalidation=get_password).accepted:
> user_id = db.auth_user.insert(
> username=form.vars.username,
> password=form.vars.password,  # password already 
> encrypted here
> email=form.vars.email,
> )
> send_new_user_mail(form.vars.username, form.vars.email, response.
> password)
> session.flash = T('Added new user')
> redirect(URL(c='user', f='manage_users'))
> elif form.errors:
> response.flash = T('Please correct errors')
> return dict(form=form)
>
> def get_password(form):
> # password already encrypted here
> ...
>


[web2py] Re: how to intercept password before encryption, if possible?

2012-04-15 Thread weheh
that makes sense. thanks!

On Monday, April 16, 2012 11:39:52 AM UTC+8, Matt Gorecki wrote:
>
> In one of my applications, I create users by hand as well with a custom 
> form.  My flow goes something like this:
>
> 1. Fill out the Create User form. There are is no password field here.
> 2. In the function that processes the form, I generate a random, readable 
> password at the beginning.
> 3. Before inserting into the database, I encrypt the password:
> my_crypt = CRYPT(key=auth.settings.hmac_key)
> crypt_pass = my_crypt(passwd)[0]
>
> 4. Once that is successful, I send the email out with the plaintext 
> password from the beginning.
>
>
> Here's the function I use to generate a readable, random password.  
> https://gist.github.com/2396242
>
>
> Matt Gorecki
>
> On Sunday, April 15, 2012 9:06:21 PM UTC-6, weheh wrote:
>>
>> I'm building an administrative interface where only the admin can 
>> register new users. Upon registering a new user, the system will email 
>> login and initial temporary password to user. I'm using the auth_user table 
>> but with a customized form and create action. Is there a way to capture the 
>> password before it's encrypted?
>>
>> Obviously, I can have the admin enter the password twice, the second time 
>> as a string, but that's a little user hostile. I could make an ajax call 
>> that would copy it behind the scenes, but that's extra work. What's the 
>> easy way?
>>
>> def create():
>> """adds a new user to the auth_user database"""
>> response.sub_title = T('Add New User')
>> form = SQLFORM.factory(
>> db.auth_user.username,
>> db.auth_user.password,
>> db.auth_user.email,
>> )
>> # password not available here
>> if form.process(onvalidation=get_password).accepted:
>> user_id = db.auth_user.insert(
>> username=form.vars.username,
>> password=form.vars.password,  # password already 
>> encrypted here
>> email=form.vars.email,
>> )
>> send_new_user_mail(form.vars.username, form.vars.email, response.
>> password)
>> session.flash = T('Added new user')
>> redirect(URL(c='user', f='manage_users'))
>> elif form.errors:
>> response.flash = T('Please correct errors')
>> return dict(form=form)
>>
>> def get_password(form):
>> # password already encrypted here
>> ...
>>
>

Re: [web2py] how to intercept password before encryption, if possible?

2012-04-15 Thread weheh
Thanks, Bruce. It's good to know where this is being stored. Actually, I 
like Matt's suggestion for auto-password generation. I'm doing this for a 
client and I assumed they wanted to choose the password, but Matt's 
approach makes more sense to me.

On Monday, April 16, 2012 11:38:09 AM UTC+8, Bruce Wade wrote:
>
> use request.vars.password to get unencrypted and form.vars.password for 
> encrypted if you use requires CRYPT()
>
> On Sun, Apr 15, 2012 at 8:06 PM, weheh  wrote:
>
>> I'm building an administrative interface where only the admin can 
>> register new users. Upon registering a new user, the system will email 
>> login and initial temporary password to user. I'm using the auth_user table 
>> but with a customized form and create action. Is there a way to capture the 
>> password before it's encrypted?
>>
>> Obviously, I can have the admin enter the password twice, the second time 
>> as a string, but that's a little user hostile. I could make an ajax call 
>> that would copy it behind the scenes, but that's extra work. What's the 
>> easy way?
>>
>> def create():
>> """adds a new user to the auth_user database"""
>> response.sub_title = T('Add New User')
>> form = SQLFORM.factory(
>> db.auth_user.username,
>> db.auth_user.password,
>> db.auth_user.email,
>> )
>> # password not available here
>> if form.process(onvalidation=get_password).accepted:
>> user_id = db.auth_user.insert(
>> username=form.vars.username,
>> password=form.vars.password,  # password already 
>> encrypted here
>> email=form.vars.email,
>> )
>> send_new_user_mail(form.vars.username, form.vars.email, response.
>> password)
>> session.flash = T('Added new user')
>> redirect(URL(c='user', f='manage_users'))
>> elif form.errors:
>> response.flash = T('Please correct errors')
>> return dict(form=form)
>>
>> def get_password(form):
>> # password already encrypted here
>> ...
>>
>
>
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>

[web2py] Re: DAL IMAP errors

2012-04-15 Thread Massimo Di Pierro
Will the proposed solution solve the problem?

replace mailbox_name = mailbox.replace("[", "").replace("]", "").replace("/", 
"_")

with

mailbox_name = re.sub('[^_\w]','',re.sub('[/ ]','_',mailbox))



On Sunday, 15 April 2012 18:40:29 UTC-5, Alan Etkin wrote:
>
> Not fixed yet in trunk. There is a regex replacement proposal in the issue 
> page by Massimo.
>
> El sábado, 14 de abril de 2012 22:44:41 UTC-3, pyhead escribió:
>>
>>
>> Hi web2py users,
>>
>> db = DAL('imap://') successfully logs in to the mail server, but fails 
>> when the commonly used spaces or '.' are returned in a folder name. Is 
>> there any way to substitute not allowed characters for '_' so imap works?
>>  only [0-9a-zA-Z_] allowed in table and 
>> field names, received Gmail_All Mail
>>
>> This was reported and was flagged as accepted, so the fix should already 
>> be in the nightly build, right?
>> http://code.google.com/p/web2py/issues/detail?id=644
>>
>> Please share the recipe if you are successfully using DAL with IMAP.  I 
>> am developing a web2py email client and this is crucial to its success.  
>> Thank you!
>>
>
> El sábado, 14 de abril de 2012 22:44:41 UTC-3, pyhead escribió:
>>
>>
>> Hi web2py users,
>>
>> db = DAL('imap://') successfully logs in to the mail server, but fails 
>> when the commonly used spaces or '.' are returned in a folder name. Is 
>> there any way to substitute not allowed characters for '_' so imap works?
>>  only [0-9a-zA-Z_] allowed in table and 
>> field names, received Gmail_All Mail
>>
>> This was reported and was flagged as accepted, so the fix should already 
>> be in the nightly build, right?
>> http://code.google.com/p/web2py/issues/detail?id=644
>>
>> Please share the recipe if you are successfully using DAL with IMAP.  I 
>> am developing a web2py email client and this is crucial to its success.  
>> Thank you!
>>
>
> El sábado, 14 de abril de 2012 22:44:41 UTC-3, pyhead escribió:
>>
>>
>> Hi web2py users,
>>
>> db = DAL('imap://') successfully logs in to the mail server, but fails 
>> when the commonly used spaces or '.' are returned in a folder name. Is 
>> there any way to substitute not allowed characters for '_' so imap works?
>>  only [0-9a-zA-Z_] allowed in table and 
>> field names, received Gmail_All Mail
>>
>> This was reported and was flagged as accepted, so the fix should already 
>> be in the nightly build, right?
>> http://code.google.com/p/web2py/issues/detail?id=644
>>
>> Please share the recipe if you are successfully using DAL with IMAP.  I 
>> am developing a web2py email client and this is crucial to its success.  
>> Thank you!
>>
>

Re: [web2py] Re:

2012-04-15 Thread Anthony
I assume a Storage object got into some part of one of your ads objects 
somehow. How is the url object created? Aside from that insert code, is 
there any other code that updates the records?

On Sunday, April 15, 2012 10:27:41 PM UTC-4, Bruce Wade wrote:
>
> url['id'] = integer
> url['url'] = string
>
> On Sun, Apr 15, 2012 at 7:03 PM, Anthony  wrote:
>
>> And what are the index, url['id'], and url['url'] objects? Are any of 
>> them storage objects?
>>
>>
>> On Sunday, April 15, 2012 8:19:45 PM UTC-4, Bruce Wade wrote:
>>>
>>>ads = []
>>>if random_ads:
>>> for index, url in enumerate(random_ads):
>>> ads.append({
>>> 'index': index,
>>> 'id': url['id'],
>>> 'url': url['url'],
>>> 'valid': '',
>>> 'suburlcount': '',
>>> 'viewcanceled': '',
>>> 'timestart': '',
>>> 'timeend': '',
>>> 'rating': ''
>>> })
>>> ads_to_view = cPickle.dumps(ads)
>>> #print "Unseen", len(ads)
>>> # Create todays ads to view
>>> self.db.viewedads.insert(**member_id=member, date=date, 
>>> adsviewed=ads_to_view)
>>>
>>> On Sun, Apr 15, 2012 at 5:17 PM, Anthony  wrote:
>>>
 What exactly did you save in the database?


 On Sunday, April 15, 2012 8:10:50 PM UTC-4, Bruce Wade wrote:
>
> Does web2py automatically save a cPickle in the database as 
> gluon.storage? Because I saved ads with the web2py framework, however now 
> when trying to load them with the old framework I get an error 
> ImportError: 
> No module named gluon.storage when I don't use gluon at all in that old 
> framework.
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/**bruc**elwade
> http://www.wadecybertech.com
> http://www.fittraineronline.**co**m - 
> Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>
>>>
>>>
>>> -- 
>>> -- 
>>> Regards,
>>> Bruce Wade
>>> http://ca.linkedin.com/in/**brucelwade
>>> http://www.wadecybertech.com
>>> http://www.fittraineronline.**com  - 
>>> Fitness Personal Trainers Online
>>> http://www.warplydesigned.com
>>>
>>>
>
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>  

Re: [web2py] Re:

2012-04-15 Thread Bruce Wade
The code I showed you is exactly how ads are created and stored in the
database. It is all through that code.

The code that updates the code uses cPickle.loads and treats it like a
python object updating the array then redumps it cPickle.dumps before
saving.

This is the exact same code I use in the other framework besides the web2py
insert method.

On Sun, Apr 15, 2012 at 9:33 PM, Anthony  wrote:

> I assume a Storage object got into some part of one of your ads objects
> somehow. How is the url object created? Aside from that insert code, is
> there any other code that updates the records?
>
>
> On Sunday, April 15, 2012 10:27:41 PM UTC-4, Bruce Wade wrote:
>>
>> url['id'] = integer
>> url['url'] = string
>>
>> On Sun, Apr 15, 2012 at 7:03 PM, Anthony  wrote:
>>
>>> And what are the index, url['id'], and url['url'] objects? Are any of
>>> them storage objects?
>>>
>>>
>>> On Sunday, April 15, 2012 8:19:45 PM UTC-4, Bruce Wade wrote:

ads = []
if random_ads:
 for index, url in enumerate(random_ads):
 ads.append({
 'index': index,
 'id': url['id'],
 'url': url['url'],
 'valid': '',
 'suburlcount': '',
 'viewcanceled': '',
 'timestart': '',
 'timeend': '',
 'rating': ''
 })
 ads_to_view = cPickle.dumps(ads)
 #print "Unseen", len(ads)
 # Create todays ads to view
 self.db.viewedads.insert(**membe**r_id=member, date=date,
 adsviewed=ads_to_view)

 On Sun, Apr 15, 2012 at 5:17 PM, Anthony  wrote:

> What exactly did you save in the database?
>
>
> On Sunday, April 15, 2012 8:10:50 PM UTC-4, Bruce Wade wrote:
>>
>> Does web2py automatically save a cPickle in the database as
>> gluon.storage? Because I saved ads with the web2py framework, however now
>> when trying to load them with the old framework I get an error 
>> ImportError:
>> No module named gluon.storage when I don't use gluon at all in that old
>> framework.
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/**brucelwade
>> http://www.wadecybertech.com
>> http://www.fittraineronline.**com- 
>> Fitness Personal Trainers Online
>> http://www.warplydesigned.com
>>
>>


 --
 --
 Regards,
 Bruce Wade
 http://ca.linkedin.com/in/**bruc**elwade
 http://www.wadecybertech.com
 http://www.fittraineronline.**co**m - 
 Fitness Personal Trainers Online
 http://www.warplydesigned.com


>>
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/**brucelwade
>> http://www.wadecybertech.com
>> http://www.fittraineronline.**com  -
>> Fitness Personal Trainers Online
>> http://www.warplydesigned.com
>>
>>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


[web2py] Re: vCard and vEvent

2012-04-15 Thread Annet
Hi Anthony,

Thanks for your reply.

You could do:
>
> {{if organization:}}FN: {{=organization.name}}
> ORG: {{=organization.name}}{{pass}}
>
> and you won't get any blank lines when there is an organization, but I 
> think you'll still get two blank lines when there is no organization.
>

This won't be a problem in case of the organization, however, in case of 
telecom addresses this solution won't solve the problem.

 I tried this solution:

Another option might be to render the response in the controller and then 
> remove any blank lines from the text:
>
> def make_vcard():
> data = [code to generate vcard data]
> vcard = response.render(context=dict(data=data))
> return vcard.replace('\n\n', '\n')
>
>
... but got the following error:

 

Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/web2py/gluon/restricted.py", line 
205, in restricted
exec ccode in environment
  File 
"/Library/Python/2.5/site-packages/web2py/applications/bootstrap/views/addressbook/downloadvcard.vcf",
 line 1, in 
{{response.headers['Content-Disposition'] = 'attachment;filename=%s.vcf' % 
IS_SLUG()(organization.name)[0]}}BEGIN:VCARD
NameError: name 'organization' is not defined


In the address book controller I got a function vcard which returns a vcard to 
an html view. In this function I store organization, address and telecom data 
in session:

session.organization=db(db.Organization.nodeID==session.id).select(db.Organization.nodeID,db.Organization.name).first()
session.address=db(db.Address.nodeID==session.id).select(db.Address.ALL).first()
session.telecom=db(db.Telecom.nodeID==session.id).select(db.Telecom.ALL)

The view contains a button 'download vcard' which calls the function 
downloadvcard:

def downloadvcard():
if request.args(0)!=session.id:
redirect(URL('vcard',args=request.args(0)))
else:
vcard=response.render(context=dict(organization=session.organization,\
address=session.address,telecom=session.telecom))
return vcard.replace('\n\n','\n')

I guess my problem lies in the data part of your solution. organization and 
address are single row objects, telecom contains as many rows as an 
organization has telecom addresses.

I hope I provided you with sufficient information to help me solve the problem.


Kind regards,

Annet.



Re: [web2py] Re:

2012-04-15 Thread Anthony

>
> The code I showed you is exactly how ads are created and stored in the 
> database. It is all through that code.


The code doesn't show how the random_ads object and the url objects it 
contains are created.
 

> The code that updates the code uses cPickle.loads and treats it like a 
> python object updating the array then redumps it cPickle.dumps before 
> saving.
>

Is it web2py code that is doing this updating, or is that all in the other 
framework? If web2py, show that code too.

Anthony


Re: [web2py] Re:

2012-04-15 Thread Anthony
You might also try inspecting the contents of some of the records. Do all 
records include a Storage object, or just some? What part of the dumped 
"ads" object is a Storage object? This may provide some clues.

Anthony

On Monday, April 16, 2012 1:27:19 AM UTC-4, Anthony wrote:
>
> The code I showed you is exactly how ads are created and stored in the 
>> database. It is all through that code.
>
>
> The code doesn't show how the random_ads object and the url objects it 
> contains are created.
>  
>
>> The code that updates the code uses cPickle.loads and treats it like a 
>> python object updating the array then redumps it cPickle.dumps before 
>> saving.
>>
>
> Is it web2py code that is doing this updating, or is that all in the other 
> framework? If web2py, show that code too.
>
> Anthony
>


Re: [web2py] Re:

2012-04-15 Thread Bruce Wade
random ads web2py query:
unseen_ads = unseen_ads_query.select(orderby='', limitby=(0,5))
return unseen_ads

update is pretty much the exact same code as provided before, with the
different it appends to the list of ads it got from the database.
today_ads = self.db((self.db.viewedads.member_id == member) &
(self.db.viewedads.date == date)).select().first()
if today_ads.adsviewed:
  ads_viewed = cPickle.loads(str(today_ads.adsviewed))
else:
  ads_viewed = []
unseen = []
ad_ids_to_skip = []
start_index = 0
if ads_viewed:
 #print ads_viewed
 for ad in ads_viewed:
 if not ad['valid']:
 unseen.append(ad)
 ad_ids_to_skip.append(ad['id'])
 start_index = int(ads_viewed[-1]['index']) + 1

random_ads = self._get_random_urls(ad_ids_to_skip)
for new_ad in random_ads:
ad_details = {
'index':start_index,
'id':new_ad['id'],
'url':new_ad['url'],
'valid':'',
'suburlcount':'',
'viewcanceled':'',
'timestart':'',
'timeend':'',
'rating':''
}
start_index += 1
#print "New index", start_index
unseen.append(ad_details)
ads_viewed.append(ad_details)
today_ads.update_record(adsviewed=cPickle.dumps(ads_viewed))

I have it working in both frameworks, however I needed to include gluon in
python path on the old framework. So I am just curious as to where is this
code is causing it to use a storage object.

On Sun, Apr 15, 2012 at 10:27 PM, Anthony  wrote:

> The code I showed you is exactly how ads are created and stored in the
>> database. It is all through that code.
>
>
> The code doesn't show how the random_ads object and the url objects it
> contains are created.
>
>
>> The code that updates the code uses cPickle.loads and treats it like a
>> python object updating the array then redumps it cPickle.dumps before
>> saving.
>>
>
> Is it web2py code that is doing this updating, or is that all in the other
> framework? If web2py, show that code too.
>
> Anthony
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


[web2py] Re: vCard and vEvent

2012-04-15 Thread Anthony
Sorry, my mistake -- there is no "context" argument. Just pass the dict as 
an unnamed argument, or pass each item as its own keyword argument:

response.render(dict(organization=session.organization, ...))

or just:

response.render(organization=session.organization, ...)

Side note: you don't need the line continuation slash ("\") if what you're 
continuing is in parentheses.

Anthony

On Monday, April 16, 2012 1:23:53 AM UTC-4, Annet wrote:
>
> Hi Anthony,
>
> Thanks for your reply.
>
> You could do:
>>
>> {{if organization:}}FN: {{=organization.name}}
>> ORG: {{=organization.name}}{{pass}}
>>
>> and you won't get any blank lines when there is an organization, but I 
>> think you'll still get two blank lines when there is no organization.
>>
>
> This won't be a problem in case of the organization, however, in case of 
> telecom addresses this solution won't solve the problem.
>
>  I tried this solution:
>
> Another option might be to render the response in the controller and then 
>> remove any blank lines from the text:
>>
>> def make_vcard():
>> data = [code to generate vcard data]
>> vcard = response.render(context=dict(data=data))
>> return vcard.replace('\n\n', '\n')
>>
>>
> ... but got the following error:
>
>  
>
> Traceback (most recent call last):
>   File "/Library/Python/2.5/site-packages/web2py/gluon/restricted.py", line 
> 205, in restricted
> exec ccode in environment
>   File 
> "/Library/Python/2.5/site-packages/web2py/applications/bootstrap/views/addressbook/downloadvcard.vcf",
>  line 1, in 
> {{response.headers['Content-Disposition'] = 'attachment;filename=%s.vcf' 
> % IS_SLUG()(organization.name)[0]}}BEGIN:VCARD
> NameError: name 'organization' is not defined
>
>
> In the address book controller I got a function vcard which returns a vcard 
> to an html view. In this function I store organization, address and telecom 
> data in session:
>
> session.organization=db(db.Organization.nodeID==session.id).select(db.Organization.nodeID,db.Organization.name).first()
> session.address=db(db.Address.nodeID==session.id).select(db.Address.ALL).first()
> session.telecom=db(db.Telecom.nodeID==session.id).select(db.Telecom.ALL)
>
> The view contains a button 'download vcard' which calls the function 
> downloadvcard:
>
> def downloadvcard():
> if request.args(0)!=session.id:
> redirect(URL('vcard',args=request.args(0)))
> else:
> vcard=response.render(context=dict(organization=session.organization,\
> address=session.address,telecom=session.telecom))
> return vcard.replace('\n\n','\n')
>
> I guess my problem lies in the data part of your solution. organization and 
> address are single row objects, telecom contains as many rows as an 
> organization has telecom addresses.
>
> I hope I provided you with sufficient information to help me solve the 
> problem.
>
>
> Kind regards,
>
> Annet.
>
>

Re: [web2py] Re:

2012-04-15 Thread Anthony

>
> random_ads = self._get_random_urls(ad_ids_to_skip)
> for new_ad in random_ads:
> ad_details = {
> 'index':start_index,
> 'id':new_ad['id'],
> 'url':new_ad['url'],
> 'valid':'',
> 'suburlcount':'',
> 'viewcanceled':'',
> 'timestart':'',
> 'timeend':'',
> 'rating':''
> }
> start_index += 1
> #print "New index", start_index
> unseen.append(ad_details)
> ads_viewed.append(ad_details)
> today_ads.update_record(adsviewed=cPickle.dumps(ads_viewed))
>
> I have it working in both frameworks, however I needed to include gluon in 
> python path on the old framework. So I am just curious as to where is this 
> code is causing it to use a storage object.
>

I don't know. Again, it might help to inspect the stored values in the 
adsviewed field. What does self._get_random_urls() look like?

Anthony 


[web2py] Re: vCard and vEvent

2012-04-15 Thread Annet
Hi Anthony,

Thanks for your help, problem solved.


Side note: you don't need the line continuation slash ("\") if what you're 
> continuing is in parentheses.
>

I appreciate the side node.
 

Kind regards,

Annet 


Re: [web2py] heroku, web2py and gunicorn

2012-04-15 Thread Rahul
It gives me an error - 
*-bash-3.2$ python anyserver.py -s gunicorn -i 72.3.247.225 -p 9065*
starting gunicorn on 72.3.247.225:9065...
Traceback (most recent call last):
  File "anyserver.py", line 299, in 
main()
  File "anyserver.py", line 295, in main

run(options.server,options.ip,options.port,logging=options.logging,profiler=options.profiler)
  File "anyserver.py", line 157, in run
getattr(Servers,servername)(application,(ip,int(port)))
AttributeError: class Servers has no attribute 'gunicorn'

Gunicorn is installed. Anything I need to do in gunicorn configuration to 
resolve it? 
I am confused... 

Sincerely, Rahul D



On Friday, April 13, 2012 7:01:27 PM UTC+5:30, Massimo Di Pierro wrote:
>
> No. If you want to use gunicorn you must start web2py with
>
> anyserver -s gunicorn
>
> anyserver comes with web2py.
>
> On Friday, 13 April 2012 04:27:14 UTC-5, Rahul wrote:
>>
>> Hi Massimo,
>>  I am trying to explore gunicorn.  Below is the command I use to 
>> activate my site. I am not sure if the parameter -s gunicorn does anything. 
>> How do I confirm this? I have gunicorn, eventlet and greenlet installed via 
>> virtualenv. I am trying to streamline my deployment and eventually remove 
>> the port number as well. 
>> *
>> -bash-3.2$* python web2py.py -a'' -i flockbird.com -p 
>> 9065 -s gunicorn &
>>
>> Thanks,
>>
>> sincerely, Rahul D [www.flockbird.com]
>>
>>
>> On Friday, July 22, 2011 9:33:10 PM UTC+5:30, Furqan Rauf wrote:
>>>
>>> I could do it but I am a newbie, no nothing about the deployment or 
>>> stress testing
>>>
>>> On Fri, Jul 22, 2011 at 10:06 AM, Massimo Di Pierro <
>>> massimo.dipie...@gmail.com> wrote:
>>>
 Hello everybody,

 heroku will be supporting web2py. They run gunicorn. web2py runs with
 gunicorn but I have never tried it.

 Any volunteer to run some stress tests?

 cd web2py
 python anyserver -s gunicorn

 Massimo
>>>
>>>
>>>
>>>
>>> -- 
>>> *-Furqan Rauf*
>>> *Do you love your creator? Love your fellow-beings first. -Prophet 
>>> Muhammad
>>> *
>>> *http://www.amway.com/furqanrauf*
>>>
>>>