[web2py:36476] Login Problem with the Administrative Interface

2009-12-03 Thread Ross Peoples
Hello, I need help with something. I just downloaded the OSX binary
for web2py, copied it to my Applications folder, launched it, entered
a password, started the server, then tried to log into the
administrative interface, but everytime I enter my password, it just
keeps reloading the log in page. No error messages or anything. Any
thoughts?

--

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




[web2py] Re: new web2py cheatsheet

2012-04-11 Thread Ross Peoples
This new cheat sheet is great! I saw the one page version, but I agree 
there is too much information to fit on to one page. I'm glad a second page 
was added.

On Monday, April 9, 2012 4:44:22 PM UTC-4, Massimo Di Pierro wrote:
>
> http://dl.dropbox.com/u/18065445/Tmp/web2py_cheatsheet.pdf
>


[web2py] Re: priority of web2py CMS

2012-04-16 Thread Ross Peoples
No, I've been tied up doing other (non-web2py) projects lately. I hope to 
get back to being more active here in a couple of weeks.

On Sunday, April 15, 2012 2:54:45 AM UTC-4, Gour wrote:
>
> On Mon, 16 Jan 2012 12:41:32 -0800 (PST)
> Ross Peoples 
> wrote:
>
> Hello Ross,
>
> > The good news is I've already figured out how to do it, I just have to
> > put the work in.
>
> Have you done some work on your web2py-powered-CMS-ala-C5?
>
>
> Sincerely,
> Gour
>
> -- 
> But those who, out of envy, disregard these teachings and do not 
> follow them are to be considered bereft of all knowledge, befooled, 
> and ruined in their endeavors for perfection.
>
> http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810
>
>

[web2py] Re: Getting https to work with rocket

2012-04-16 Thread Ross Peoples
You can't connect to https using http as the protocol. Getting a "bad 
request" message is exactly what happens when you try. So in your browser, 
you need to specifically type https://:3.

On Monday, April 16, 2012 1:42:06 PM UTC-4, Shivakumar GN wrote:
>
> Hi,
>
> I am using python 2.5 on Solaris and web2py 1.99.7
>
> I am trying to get https to work with in built web server as per recipe at 
> below link.
> http://www.web2py.com/AlterEgo/default/show/140
>
> I built ssl module built from source since it was missing in python 2.5
>
> > python web2py.py --nogui -i  -p 3 -c server.crt -k 
> server.key
>
> After this, there is no service available via https. On using http, a "bad 
> request" message appears in the browser.
>
> This seems similar to issue reported long back, the discussion thread for 
> which doesn't seem to have reached a closure.
> http://comments.gmane.org/gmane.comp.python.web2py/46045
>
> How to resolve this?
>
> thanks & best regards
> Shivakumar GN
>
>

[web2py] Re: CMS question

2012-04-23 Thread Ross Peoples
I don't know about that. I've started installing Concrete5 for people 
because it's so easy to use and they can create "blocks" of content that 
they can move around. I think a good CMS should be as dynamic as possible, 
without being overly complicated.

On Monday, April 23, 2012 1:30:12 AM UTC-4, Ramkrishan Bhatt wrote:
>
> 3) using fully editable html with no limitation on themes (any existing 
> page would be a theme without need for tweaking) yet one would not be able 
> to swap a theme on a page without loss of content, any more you can swap 
> the theme on a msworld document.  
> Option3 is better and most in demand now a days. 
>
> On Sunday, 22 April 2012 21:54:50 UTC+5:30, Massimo Di Pierro wrote:
>>
>> Let's say we want to build a new kick-ass CMS.
>>
>> My technical side tells me that the best way it to use markup language 
>> and separate data from presentation (which allows swapping of themes).
>>
>> My practical side tells is is better to allow users to edit html.
>>
>> Everytime I has worked with end-users I had a hard time explaining this 
>> concept of separation of data from presentation. They usually want a page 
>> tat looks like "that page" but the ability to edit all text and images in 
>> it.
>>
>> Most CMS's (like concrete CMS) solve the problem by a compromise. You can 
>> only edit specific parts of  a page (and they must be clearly tag in the 
>> HTML). This allows some separation because as long as two themes have the 
>> same editable tags, the content it portable between the themes. Yet if they 
>> use a wysiwyg the editable blocks are stored as HTML. Moreover creating 
>> themes requires some programming skills and make the themes CMS specific. 
>> In the case of Concrete5 or Joomla for example, this tagging is done in PHP.
>>
>> So what is better?
>> 1) using a markup language with limited choice of themes (like wikipedia)
>> 2) using wysiwyg to edit fixed sections in themes (like joomla and 
>> concrete5)
>> 3) using fully editable html with no limitation on themes (any existing 
>> page would be a theme without need for tweaking) yet one would not be able 
>> to swap a theme on a page without loss of content, any more you can swap 
>> the theme on a msworld document.
>>
>>
>> Massimo
>>
>

[web2py] Re: CMS question

2012-04-23 Thread Ross Peoples
I guess it comes down to figuring out what kind of CMS we want to build. Do 
you want a CMS that is easy for web designers (like WordPress), or do you 
want a CMS that is easy for end users? My feeling is that there are already 
SO MANY WordPress clones out there that if we are going to build a 
"kickass" CMS, it should be easy for end users. I started to design a CMS 
for just this reason, but I haven't had a lot of time to mess with it 
recently.

My thought process when I started to design the CMS was to make it dead 
simple. If you know how to check your email and/or Facebook, then you can 
build a website. I had a working prototype of a CSS designer that was used 
to make themes. I had also come up with the idea for blocks (this was 
before I knew about Concrete5) where you select what type of content you 
want for the block (Markmin, HTML, RSS feed, tag cloud, nivo slider, other 
widget, etc). Then when in design mode, you could drag blocks around, 
resize them, etc.

The result of this design was a CMS that allowed users to create entire 
websites using pre-created components and widgets without knowing anything 
about HTML or CSS. Adding new widgets, plugins, and components would be 
simple for developers. And dropping down to regular HTML for a block was 
always an option incase something complicated needed to be done that the 
plugin system didn't cover.

This is the kind of CMS that I would love to see, and I know for a fact it 
is in high demand. But, it's difficult to develop which is why no one has 
really done it before (Concrete5 got close, but you still have to build 
themes/templates using HTML). So if we are going to build a CMS, we might 
as well make it "kickass".


[web2py] Re: CMS question

2012-04-23 Thread Ross Peoples
I remember seeing this once before. This is great if you find a theme you 
like online and want to make a prototype of your site in that theme and 
this is a very cool tool in general. The question is, do we really want to 
go in this direction for a CMS? The content is basically imprisoned in 
hard-coded HTML, making theme changes difficult at best. I could see making 
static HTML pages for sites with this (i.e. like Dreamwaver), but for a 
CMS, I'm not sure.

On Monday, April 23, 2012 2:07:27 PM UTC-4, Massimo Di Pierro wrote:
>
> P.S. You have to register else there are copyright issues. This is a 
> complete rewrite of a previous experiment with the same name.
>
> On Monday, 23 April 2012 12:46:13 UTC-5, Massimo Di Pierro wrote:
>>
>> Here is a just a piece of the puzzle for you to try:
>>
>>http://tests.web2py.com/plasmid/
>>
>> It may be useful to build web2py layouts or CMS themes. Or it could be 
>> useful to edit the pages themselves.
>> Nothing prevents from inserting @{...} tags that embed web2py 
>> (plugin_wiki?) components.
>>
>> My server is slow so be patient and try not to kill it or I will have to 
>> take the app down.
>>
>> massimo
>>
>

[web2py] Re: Cannot start web2py - Runtime error: Unable to import driver

2012-04-24 Thread Ross Peoples
Can you paste the traceback of the ticket? 

On Monday, April 23, 2012 11:10:55 PM UTC-4, Goronmon wrote:
>
> I'm trying to use web2py on a Ubuntu install. I can start it up from the 
> console, but as soon as I navigate to it in the browser I the internal 
> error about not being able to import the driver.
>
> I haven't touched anything or done any type of special configuration. I've 
> gotten it to work in WIndows just fine, but for some reason I just can't 
> get it working on Ubuntu. I've spent all evening trying to get around the 
> issue but have had no luck so far.
>
> I would really appreciate any help anyone can give me in getting around 
> this error.
>


[web2py] Re: Free e-book abhout Rest API

2012-04-25 Thread Ross Peoples
Thanks for the link! I've been looking for good API design resources.

[web2py] Re: crud.create causes an id problem

2012-04-26 Thread Ross Peoples
I'm having a similar issue using SQLFORM. I am using a table that stores 
extra data for users, and I call it auth_user_extended:

db.define_table('auth_user_extended',
Field('auth_user', db.auth_user, readable=False, writable=False),
Field('supervisor', 'boolean', label='Is Supervisor?', default=False),
Field('status', 'integer', 
requires=IS_IN_SET(db.auth_user_extended_status_types), default=1, 
notnull=True),
Field('legal_name', length=255, notnull=True),
Field('secondary_email', length=255),
Field('primary_phone', length=20),
Field('secondary_phone', length=20),
Field('start_date', 'datetime'),
Field('end_date', 'datetime'),
Field('barcode_id', length=12, notnull=True, unique=True), 
#requires=IS_NOT_IN_DB(db, 'auth_user_extended.barcode_id')),
Field('alliance_id', length=10, default=None),  # this is the user's 
Alliance ID. If this is None, it defaults to auth_user.username.
Field('supervisor_auth_user', db.auth_user, label='User\'s Supervisor', 
ondelete='NO ACTION'),
Field('assistant_to_auth_user', db.auth_user, label='Assistant To 
User', ondelete='NO ACTION'),
Field('vacation_minutes', 'decimal(10,2)', default=0, 
requires=IS_NOT_EMPTY(), notnull=True),
Field('personal_minutes', 'decimal(10,2)', default=0, 
requires=IS_NOT_EMPTY(), notnull=True),
Field('sick_minutes', 'decimal(10,2)', default=0, 
requires=IS_NOT_EMPTY(), notnull=True),
Field('holiday_minutes', 'decimal(10,2)', default=None),   # setting 
this field to None makes it default to the holiday's holiday_minutes setting
Field('picture', 'upload', 
uploadfolder=os.path.join(request.folder,'static/images/user-pictures'))
)

I'm trying to use this code:

form = SQLFORM(db.auth_user, row.auth_user)
form.append(SQLFORM(db.auth_user_extended, row.auth_user_extended))

But I've also tried making a form for auth_user_extended by itself and I 
still get the same problem:

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.

Traceback (most recent call last):
  File "/var/web2py/gluon/restricted.py", line 205, in restricted
exec ccode in environment
  File "/var/web2py/applications/bonfire/controllers/administration.py" 
, line 
292, in 
  File "/var/web2py/gluon/globals.py", line 175, in 
self._caller = lambda f: f()
  File "applications/bonfire/modules/core.py", line 473, in f
return action(*a, **b)
  File "/var/web2py/applications/bonfire/controllers/administration.py" 
, line 
286, in users
return update()
  File "/var/web2py/applications/bonfire/controllers/administration.py" 
, line 
232, in update
form.append(SQLFORM(db.auth_user_extended, row.auth_user_extended))
  File "/var/web2py/gluon/sqlhtml.py", line 888, in __init__
inp = self.widgets.options.widget(field, default)
  File "/var/web2py/gluon/sqlhtml.py", line 218, in widget
options = requires[0].options()
  File "/var/web2py/gluon/validators.py", line 471, in options
self.build_set()
  File "/var/web2py/gluon/validators.py", line 458, in build_set
records = self.dbset(table).select(*fields, **dd)
  File "/var/web2py/gluon/dal.py", line 8004, in __call__
query = query._id>0
  File "/var/web2py/gluon/dal.py", line 7165, in __getattr__
return self[key]
  File "/var/web2py/gluon/dal.py", line 7105, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: '_id'


I just updated to the latest trunk and started having this issue.



[web2py] Add RESTful Client to Contrib

2012-04-26 Thread Ross Peoples
Should we add a RESTful client to web2py's contrib folder? We already have 
clients for XML-RPC and JSON-RPC, so maybe we should include one for REST 
that can handle both simple a more complex cases (like file uploads, 
unicode, etc). I found one that I was just about to add to a project and 
thought it would be good to include into web2py 
contrib: 
https://github.com/thraxil/restclient/blob/master/restclient/__init__.py

[web2py] Re: crud.create causes an id problem

2012-04-27 Thread Ross Peoples
I have created Issue 
777: http://code.google.com/p/web2py/issues/detail?id=777

On Friday, April 27, 2012 9:15:07 AM UTC-4, Massimo Di Pierro wrote:
>
> Please open a ticket about this.
>
> On Thursday, 26 April 2012 13:21:34 UTC-5, villas wrote:
>>
>> Just a thought...  if you are trying to create a new table which has a 
>> 'bigint' id,  this may be incompatible if it references an existing table 
>> which has an 'integer' id. 
>>
>> Regards,
>> David
>>
>

Re: [web2py] Re: Ubuntu and Python3

2012-04-27 Thread Ross Peoples
I would imagine that you would still have the same problem unless shared 
hosts figure out a way to make uWSGI easier to use.

I have given up on shared hosting. The price of a low-end VPS is just as 
low (and sometimes lower) as most shared hosting plans with MUCH better 
performance. I have played with shared hosting from multiple providers, and 
success really varies. I found myself spending hours getting it all set up, 
when I can set up a VPS the right way in about 15 minutes.

You can find really good deals on VPS providers on webhostingtalk.com, but 
I keep up with deals posted to lowendbox.com because they make sure the 
providers are reputable before posting their promotions. I personally have 
VPS instances from both ChicagoVPS and RethinkVPS and have been pretty 
happy. Basically, you can get root access to a web server for $7/month or 
less. They seem to handle traffic pretty well too for the price, but if you 
have a high traffic site, you would want something more expensive (and you 
wouldn't be using shared hosting to begin with).

On Thursday, April 26, 2012 12:22:09 PM UTC-4, sebastian wrote:
>
> just wondering if having web3py in python 3 will give us some problem with 
> some share hosting
>
> On Thu, Apr 26, 2012 at 2:52 PM, Johann Spies wrote:
>
>> That article says that Python 2.7 will still be part of Ubuntu so there 
>> should not be a problem.
>>
>> Regards
>> Johann
>>
>>
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>
>>  
>
>
> -- 
> Sebastian E. Ovide
>
>
>
>  

[web2py] RFC: web2py-based workflow engine

2012-05-01 Thread Ross Peoples
In reference 
to: 
https://groups.google.com/forum/#!searchin/web2py/workflow/web2py/osEmmtu9hlg/2MHi_ZCeMBMJ

Has anyone done any work on this yet? I was thinking about making a 
web2py-based workflow engine.

I mentioned previously that I built one of these for an application I wrote 
several years ago, but it was built specifically for that app. This will be 
my first attempt at making a general-use workflow engine, so let me know if 
you find any problems with my design:

Make a contrib module that is initialized like the Auth module:
from gluon.contrib.workflow_engine import WorkflowEngine, Step
workflow_engine = WorkflowEngine()
workflow_engine.define_tables()


I will use the example that I know best, which is passing around a sales 
order throughout a company's departments. This first example would define a 
workflow template because every sales order will have the same workflow:
workflow_engine.add_template('Sales Order',
Step(group_id=2, hours=4), # Engineering gets 4 hours to complete their 
step
Step(user_id=7, hours=0), # The engineering manager (user) has no time 
limit
Step(group_id=3, hours=2), # Quality department gets 2 hours to inspect 
the order
Step(group_id=8, hours=6.5), # Shipping department gets 6.5 hours to 
ship order
)


You would start this workflow like this:
workflow_id = workflow_engine.load_template('Sales Order', item_type=
'document', item_id=1)
workflow_id = workflow_engine.
workflow_engine.start(workflow_id)


Optionally, a workflow can be created on the fly (if the workflow will only 
be used once):
workflow_id = workflow_engine.create_workflow('One-time Workflow', 
'document', 1 # same as item_type and item_id used in load_template()
Step(group_id=2, hours=4)
Step(group_id=3, due_date=request.now + datetime.timedelta(days=1)) # 
set time limit to an exact datetime
)

workflow_engine.start(workflow_id) # start the workflow we just created


We assume that we are going to associate this workflow with another object. 
In this case, we will assume there is a table called "document" and that 
the document we want to pass around has an id of 1. The "item_type" 
argument allows you to pass around any type of database object. In this 
case, we will call it the same thing as our table: "document".

These are some common operations that could be done:
workflow_engine.active_workflows() # returns a list of all active workflows
workflow_engine.active_workflows(user_id=1) # all active workflows for the 
user_id
workflow_engine.active_workflows(user_id=1, include_groups=True) # same as 
above, but includes groups the user is a member of
workflow_engine.active_workflows(group_id=2) # all active workflows for the 
group_id
workflow_engine.late_workflows() # returns a list of all late/overdue 
workflows
workflow_engine.step_complete(workflow_id, notes='General info about 
completed task') # moves workflow to the next step
workflow_engine.step_reject(workflow_id, to_step=2, notes='Why step was 
rejected') # moves workflow back to step 2 incase there was a problem with 
one of the previously completed steps


Workflow triggers:
workflow_engine.before_start = function(workflow, step)
workflow_engine.after_start = function(workflow, step)
workflow_engine.before_step_complete = function(workflow, step)
workflow_engine.after_step_complete = function(workflow, step)
workflow_engine.before_step_reject = function(workflow, step)
workflow_engine.after_step_reject = function(workflow, step)
workflow_engine.before_finish = function(workflow, step)
workflow_engine.after_finish = function(workflow, step)


Finally, (and I MIGHT do this) since we are using time limits in hours, we 
should set some time ranges where users are available. For example, if the 
company is only open from 8 AM to 5 PM, you wouldn't want something to be 
late at 7 PM. You would want to roll over the extra 2 hours so that it 
becomes late at 10 AM the next business day. A list of time ranges would be 
created, and a user would be assigned to one of the time ranges. This would 
accommodate users in different time zones or with different "work" hours. 
Again, this last part I MIGHT do if I have enough time. I've done it 
before, but I'm sure you can imagine how complicated this part is.


So any questions, comments, improvements? Thanks!


[web2py] Re: CMS question

2012-05-02 Thread Ross Peoples
Looks pretty nice, Massimo. I look forward to trying it out and 
contributing to it.

[web2py] Re: RFC: web2py-based workflow engine

2012-05-02 Thread Ross Peoples
Cliff,

Thanks for the feedback. I added the ability to name / title steps. I also 
added the ability to set priorities for workflows.

It is assumed that when a step is complete, that step is already "done" and 
the next step in workflow is "new". Each step has an order_id to show which 
order the steps are in. The workflow table stores the "order_id" of the 
active workflow step. So in this case if the workflow is on order_id 3, 
then anything below 3 is considered done, while everything else is new. Is 
this what you mean by states to account for?

Active workflows can be modified on the fly as well. This has a limitation 
that any step that has been completed cannot be modified. All future steps 
can be modified. So if the workflow needs to have another step added to it 
or if it has been determined that the next destination user_id / group_id 
needs to be changed, that can be done (i.e. someone accidentally added the 
Engineering group, but it should have been Quality instead).

I will add another method to WorkflowEngine (I was going to do this 
anyways, but forgot to include it in my original post:
workflow = workflow_engine.get_workflow(workflow_id)

# The contents of the workflow object would contain:
#name: the name of the workflow
#is_template: is this workflow a template
#item_type, item_id: what object is the workflow attached to
#order_id: the current position of the workflow
#priority: the priority of the workflow
#steps: list of step as Row objects
#
# There would be a few helper methods as well:
#current_step(): returns the Row object of the current step or None
#due_date(): returns the current step's due date or None
#...

I have not built in any security, as I figured that would be something more 
application-specific. For example, a document management system might want 
security on folders, just like a regular file system, and 
not necessarily on a workflow-by-workflow basis.

However, I am planning on adding auditing support. I almost used the new 
record versioning feature, but decided I wanted to go with delta-based 
changes instead of full copies of everything for better timeline support.

Additional questions, comments, and improvements are welcome!

On Tuesday, May 1, 2012 4:07:05 PM UTC-4, Cliff wrote:
>
> Ross,
>
> I like the on-the-fly ability.
>
> Each step in your template changes the state of the item.  Each one of 
> those states should have a title.
>
> There are two other states to account for, new and done.
>
> Workflows sometimes have more than one path to completion.  
>
> I see an entity called a workflow_item that has the ability to determine 
> its current state and all possible states to which it could transition.  It 
> also knows who can cause it to transition to one of those states as well as 
> which of its attributes should be hidden, visible or editable in any given 
> state, and who should be able to see or edit those attributes while in that 
> state.
>
>
> On Tuesday, May 1, 2012 12:00:42 PM UTC-4, Ross Peoples wrote:
>>
>> In reference to: 
>> https://groups.google.com/forum/#!searchin/web2py/workflow/web2py/osEmmtu9hlg/2MHi_ZCeMBMJ
>>
>> Has anyone done any work on this yet? I was thinking about making a 
>> web2py-based workflow engine.
>>
>> I mentioned previously that I built one of these for an application I 
>> wrote several years ago, but it was built specifically for that app. This 
>> will be my first attempt at making a general-use workflow engine, so let me 
>> know if you find any problems with my design:
>>
>> Make a contrib module that is initialized like the Auth module:
>> from gluon.contrib.workflow_engine import WorkflowEngine, Step
>> workflow_engine = WorkflowEngine()
>> workflow_engine.define_tables()
>>
>>
>> I will use the example that I know best, which is passing around a sales 
>> order throughout a company's departments. This first example would define a 
>> workflow template because every sales order will have the same workflow:
>> workflow_engine.add_template('Sales Order',
>> Step(group_id=2, hours=4), # Engineering gets 4 hours to complete 
>> their step
>> Step(user_id=7, hours=0), # The engineering manager (user) has no 
>> time limit
>> Step(group_id=3, hours=2), # Quality department gets 2 hours to 
>> inspect the order
>> Step(group_id=8, hours=6.5), # Shipping department gets 6.5 hours to 
>> ship order
>> )
>>
>>
>> You would start this workflow like this:
>> workflow_id = workflow_engine.load_template('Sales Order', item_type=
>> 'document', item_id=1)
>> workflow_id = workflow_engine.
>> workflow_engine.star

[web2py] Re: CMS question

2012-05-03 Thread Ross Peoples
Looking at the "better" version of that you just added to trunk, this is 
pretty cool!

I also looked at bluePen editor. That is very cool and looks like something 
I did once using jQuery UI components. I can't seem to find the code I 
wrote for it. It was a proof-of-concept that didn't really go anywhere. But 
the way it worked was you would mark DIV tags with a 'editable' class (or 
whatever you want to call it) and when the DIV was double-clicked, it 
opened a CSS editing dialog that gave options to change colors, borders, 
and rounding.

When saved, it would send an AJAX request with the CSS that changed and the 
next time the DIV was rendered, the CSS was injected. This way you could 
still use a style.css to style the whole site, but use the CSS editor to 
override some of the attributes for the one DIV. I don't know if this is 
the behavior you are looking for, but it's totally possible.

On Thursday, May 3, 2012 12:16:57 PM UTC-4, Massimo Di Pierro wrote:
>
> Another piece of the puzzle is in trunk
>
> gluon/contrib/autolinks.py
>


[web2py] Re: Nginx-uwsgi problem.

2012-05-10 Thread Ross Peoples
The DB layer is usually the bottleneck. However, moving from models to 
modules should reduce any bottleneck caused by the web server.

[web2py] Re: when I open a second DAL connection to the same sqlite database it does not detect a new table

2012-05-14 Thread Ross Peoples
I don't think you are supposed to open more than one connection to a SQLite 
database at a time. It is file-based and doesn't have multi-connection 
abilities like other databases like MySQL and PostgreSQL.

On Monday, May 14, 2012 7:29:44 AM UTC-4, simon wrote:
>
> *In the following code I create a new table in db1. However when I open a 
> second DAL connection to the same database the new table is not shown. Why 
> is that?*
> *
> *
> *db1 = DAL('sqlite://storage.sqlite', folder=dbfolder, auto_import=True)*
> *print(db1.tables)*
> *
> *
> *db1.executesql("DROP TABLE IF EXISTS test;")*
> *print(db1._timings)*
> *try:*
> *os.remove(dbfolder+"/test.table")*
> *except:*
> *pass*
> **
> *db1.define_table('test', Field('testfield'), migrate='test.table')*
> *db1.commit()*
> *print(db1.tables)*
> *
> *
> *db2 = DAL('sqlite://storage.sqlite', folder=dbfolder, auto_import=True)*
> *print(db2.tables)*
>


Re: [web2py] To uuid or not?

2012-05-14 Thread Ross Peoples
Some databases allow you to temporarily turn off auto-generating IDs so 
that you can import a table keeping its original IDs intact. I wrote a 
database abstraction layer a few years back for another project that 
specifically allowed you to make an identical copy of a database from a 
MySQL database to a PostgreSQL database on a different machine and 
preserving the IDs was something I needed to figure out. Here is how you do 
it with MSSQL, MySQL, and PostgreSQL. Maybe Massimo can add this as an 
option to the DAL's import method:

First, import your records, then run these on your database engine:

MSSQL:
db.executesql('SET IDENTITY_INSERT dbo.mytable OFF');
db.executesql('DBCC CHECKIDENT (mytable)');

MySQL:
count = db.executesql('SELECT MAX(id) FROM mytable;')
count += 1
db.executesql('ALTER TABLE mytable AUTO_INCREMENT=%s;' % count)

PostgreSQL:
count = db.executesql('SELECT MAX(id) FROM mytable;')
count += 1
db.executesql('ALTER SEQUENCE mytable_sequence RESTART WITH %s;' % count)

For all 3 database engines, this sets the auto-increment counter to the max 
ID it finds in the table (AFTER the import) +1 so that new rows will have 
the proper IDs.


Re: [web2py] To uuid or not?

2012-05-14 Thread Ross Peoples
I have created issue 
796: http://code.google.com/p/web2py/issues/detail?id=796

While creating the issue, I noticed that I had made an error with the MSSQL 
part. This was corrected in the issue.


[web2py] Re: when I open a second DAL connection to the same sqlite database it does not detect a new table

2012-05-14 Thread Ross Peoples
In my experience, "can" doesn't always mean "should". There may be an issue 
with db2 not seeing the table definitions from db1. For testing, do 
something like this to explicitly share the "test" table definition:

def define_tables(db, migrate=False):
   db.define_table('test', Field('testfield'), migrate=migrate)

define_tables(db1)
define_tables(db2)




Re: [web2py] Re: Nginx-uwsgi problem.

2012-05-14 Thread Ross Peoples
I'm reading through the profile log, not that I'm an expert on profiling or 
anything, but I do have a few possible tips:

   1. Most of your calls are done in ~86 ms. That's pretty respectable. 
   2. Most of your time is spent on database calls, with compiling being 
   the second biggest time consumer. So compiling your code should provide you 
   with a quick speed boost without having to change any code.
   3. The biggest bottleneck is almost always the queries to the database, 
   regardless of using the DAL or not. So spend more time optimizing your 
   queries before optimizing your code.
   4. Your "adviewer/viewads" makes 10 calls to the database. Try to 
   optimize this either by writing fewer queries, creating a view, and/or only 
   selecting fields that you need. Also make sure you get the criteria right 
   so that you (ideally) don't have any extra, unneeded rows.
   5. The "trees/index", "trees/get_binary_tree.json", 
   "trees/team_members", etc. I assume are supposed to be showing a 
   parent-child type of relationship. I've done this with folders in a 
   document management system before and trees are tough. The way I did it was 
   to load only the top-level and one level below in a single database query 
   (so you would know if the folder had subfolders), and then loaded the rest 
   whenever the user "opened" or "expanded" a folder. If your application 
   resembles this type of tree, then maybe try that. Otherwise, try to load 
   two or three levels per query. Even using a sub-select will be faster than 
   repeated queries.
   6. Moving models to modules and only loading the tables you need has 
   already been mentioned, but it's worth adding to the list of tips.
   7. When you absolutely have to load a few thousand rows (or more) in a 
   query (you should avoid this whenever possible), then try using 
   "db.executesql(query)" to manually execute a hand-crafted SQL query. This 
   will always be faster than using the DAL directly.
   8. Another point about executesql: The obvious issue is reduced 
   portability, but if you are only planning on using PostgreSQL, then you can 
hand-craft a SQL query and profile it against PostgreSQL for maximum 
   performance. Once you've got it giving only the data you want, then you can 
   copy and paste that query into executesql.

I don't know how much, if any, of this applies to your situation, but I'd 
like to think it's good advice in general.


[web2py] Re: Can/should {{super}} works even without a parent block?

2012-05-14 Thread Ross Peoples
While not the prettiest solution, you can always use 
{{try:}}{{super}}{{catch}} in views. I know that sounds like a bandaid, but 
I think an exception is the desired behavior here. Otherwise, returning an 
empty string would make troubleshooting difficult if you accidentally 
mistyped the name of the block and the block keeps showing up as empty.

[web2py] Re: Can/should {{super}} works even without a parent block?

2012-05-14 Thread Ross Peoples
Correction, that should be:
{{try:}}{{super}}{{catch:pass}}



On Monday, May 14, 2012 11:45:37 AM UTC-4, Ross Peoples wrote:
>
> While not the prettiest solution, you can always use 
> {{try:}}{{super}}{{catch}} in views. I know that sounds like a bandaid, but 
> I think an exception is the desired behavior here. Otherwise, returning an 
> empty string would make troubleshooting difficult if you accidentally 
> mistyped the name of the block and the block keeps showing up as empty.



Re: [web2py] Re: Nginx-uwsgi problem.

2012-05-14 Thread Ross Peoples


On Monday, May 14, 2012 11:50:06 AM UTC-4, Anthony wrote:
>
>
>>1. Your "adviewer/viewads" makes 10 calls to the database. Try to 
>>optimize this either by writing fewer queries, creating a view, and/or 
>> only 
>>selecting fields that you need. Also make sure you get the criteria right 
>>so that you (ideally) don't have any extra, unneeded rows.
>>
>> If it's feasible, also consider caching the queries for some amount of 
> time (assuming the results don't change too frequently). 
>

This is a good point. For things that may not change a whole lot, I usually 
set the time_expires=3600 or even None. Give the key a well-defined name, 
and then when something changes, run cache.ram.clear(key) so that the next 
query will get the changes. 

>
>>1. When you absolutely have to load a few thousand rows (or more) in 
>>a query (you should avoid this whenever possible), then try using 
>>"db.executesql(query)" to manually execute a hand-crafted SQL query. This 
>>will always be faster than using the DAL directly.
>>
>> Note, the difference in speed is due to the fact that the DAL won't be 
> converting the results set to a Rows object -- so you won't have the 
> convenience of dealing with DAL Rows and Row objects. If you do 
> db.executesql(query, 
> as_dict=True), it will convert to a list of dictionaries (which is still 
> faster than converting to a Rows object). 
>
>>
>>1. Another point about executesql: The obvious issue is reduced 
>>portability, but if you are only planning on using PostgreSQL, then you 
>> can 
>> hand-craft a SQL query and profile it against PostgreSQL for maximum 
>>performance. Once you've got it giving only the data you want, then you 
>> can 
>>copy and paste that query into executesql.
>>
>> If you want to use db.executesql() but remain portable, you can still 
> have the DAL generate the SQL for you by using the ._select() method:
>
> db.executesql(db(query)._select(...))
>
> Obviously in that case you don't get to hand optimize the SQL, but you 
> still get the speed advantage of not converting the results to a Rows 
> object (which is only significant for large results sets).
>

While true, since he is going for performance in a high-traffic environment 
that requires low-latency, such as a site that serves ads, he 
would definitely want to hand-craft the SQL for complex and large queries 
that slow things down. I wouldn't recommend doing it for every query, just 
the slow ones.
 

>
> Anthony
>
>

Re: [web2py] Re: Nginx-uwsgi problem.

2012-05-14 Thread Ross Peoples
The problem with doing it as a C module is that it would have to be 
compiled. I know that this is something that has been mentioned before but 
was shot down because web2py wouldn't be easily accessible, modified, etc, 
which is the goal of web2py. Alternatively, maybe running web2oy in PyPy 
environment could improve the performance without taking away from the 
flexibility of web2py.

On Monday, May 14, 2012 11:57:49 AM UTC-4, Richard wrote:
>
> Hello,
>
> I wonder if some of the speed problem that web2py has could be address by 
> translate some of the web2py module into C??
>
> There is already many walk around for speed problem, but could there is 
> some major speed improvement by rewrite some of web2py fondation into C?
>
> I am just curious about that possibility since I didn't see popup as 
> possible option to improve speed of app in major scalling process.
>
> Thanks
>
> Richard
>
> On Mon, May 14, 2012 at 11:50 AM, Anthony  wrote:
>
>>
>>>1. Your "adviewer/viewads" makes 10 calls to the database. Try to 
>>>optimize this either by writing fewer queries, creating a view, and/or 
>>> only 
>>>selecting fields that you need. Also make sure you get the criteria 
>>> right 
>>>so that you (ideally) don't have any extra, unneeded rows. 
>>>
>>> If it's feasible, also consider caching the queries for some amount of 
>> time (assuming the results don't change too frequently). 
>>
>>>
>>>1. When you absolutely have to load a few thousand rows (or more) in 
>>>a query (you should avoid this whenever possible), then try using 
>>>"db.executesql(query)" to manually execute a hand-crafted SQL query. 
>>> This 
>>>will always be faster than using the DAL directly. 
>>>
>>> Note, the difference in speed is due to the fact that the DAL won't be 
>> converting the results set to a Rows object -- so you won't have the 
>> convenience of dealing with DAL Rows and Row objects. If you do 
>> db.executesql(query, 
>> as_dict=True), it will convert to a list of dictionaries (which is still 
>> faster than converting to a Rows object). 
>>
>>>
>>>1. Another point about executesql: The obvious issue is reduced 
>>>portability, but if you are only planning on using PostgreSQL, then you 
>>> can 
>>> hand-craft a SQL query and profile it against PostgreSQL for maximum 
>>>performance. Once you've got it giving only the data you want, then you 
>>> can 
>>>copy and paste that query into executesql. 
>>>
>>> If you want to use db.executesql() but remain portable, you can still 
>> have the DAL generate the SQL for you by using the ._select() method:
>>
>> db.executesql(db(query)._select(...))
>>
>> Obviously in that case you don't get to hand optimize the SQL, but you 
>> still get the speed advantage of not converting the results to a Rows 
>> object (which is only significant for large results sets).
>>
>> Anthony
>>
>>
>

[web2py] Re: Can/should {{super}} works even without a parent block?

2012-05-14 Thread Ross Peoples
Sorry, been switch between languages a lot this morning. If you are still 
getting the error, then I'm not sure. Maybe someone else has a thought.

On Monday, May 14, 2012 11:56:45 AM UTC-4, Ray (a.k.a. Iceberg) wrote:
>
> Guess you mean {{try:}}{{super}}{{except: pass}}
>
> Unfortunately it fails too.
>
> So a fix is a must?
>
> Regards,
> Ray
>
> On Monday, May 14, 2012 11:50:45 PM UTC+8, Ross Peoples wrote:
>>
>> Correction, that should be:
>> {{try:}}{{super}}{{catch:pass}}
>>
>>
>>
>> On Monday, May 14, 2012 11:45:37 AM UTC-4, Ross Peoples wrote:
>>>
>>> While not the prettiest solution, you can always use 
>>> {{try:}}{{super}}{{catch}} in views. I know that sounds like a bandaid, but 
>>> I think an exception is the desired behavior here. Otherwise, returning an 
>>> empty string would make troubleshooting difficult if you accidentally 
>>> mistyped the name of the block and the block keeps showing up as empty.
>>
>>

[web2py] Re: Is there anyone who running web2py application on Redhat openshift?

2012-05-15 Thread Ross Peoples
I don't know anything about openshift, but I would think the normal MySQL 
troubleshooting steps apply:


   1. Make sure MySQL is listening on all interfaces
   2. Make sure your MySQL account accepts connections from the '%' host.


On Tuesday, May 15, 2012 3:55:07 AM UTC-4, JungHyun Kim wrote:
>
> Hello. I'm now trying to use redhat openshift.
>
> I am struggling access database - mysql-5.1 - which is set via openshift 
> cartridge.
> I got admin user(admin), password and database name(we2py).
> So I modified database setting in models/db.py 
>
> as
>
> db = DAL('mysql://admin:passw...@web2py-codingday.rhcloud.com/web2py')
>
> But web2py application can't connect to mysql.
>
> OperationalError: (2003, "Can't connect to MySQL server on '
> web2py-codingday.rhcloud.com' (111)")
>
> I think I couldn't understand enough. I am a noob for both web2py and 
> openshift.
>
> How can I make web2py connect to database right?
>
> Thank you.
>
>
>

[web2py] Re: SNI or dedicated IP.

2012-05-16 Thread Ross Peoples
I'd never heard of SNI before, but looking at the Wikipedia page for 
it: http://en.wikipedia.org/wiki/Server_Name_Indication

This will NOT work. The main reason being that Python 2 (which web2py runs 
on) does not support SNI. Python 3.2 does, however. So until there is a 
web3py, SNI will not be an option unless you use it through Apache (and 
figure out how to enable it). It's still pretty new; they just added 
support for it to Java 7 and Qt 4.8 (which were both just released a few 
months ago). Just because the OS supports it doesn't mean that the 
applications or the frameworks for those applications supports it.

This quote seems to sum up SNI: "As of 2012 there are still many users of 
browsers that do not support SNI"

On Wednesday, May 16, 2012 1:33:48 AM UTC-4, Annet wrote:
>
> To be able to access web2py's admin online I had a dedicated IP address at 
> WebFaction, and referenced admin 
> with a subdomain: admin.mydomain.com. A few weeks ago I changed accounts and 
> when I asked for a dedicated IP 
> address they answered:
>
> The connection using SNI is just as strong as a normal SSL connection
> except that the domain is sent in cleartext.
>
> If you are not using a really old browser/OS combination
> you can just use SNI instead of getting a dedicated IP.
>
>
> Is anybody using SNI to access web2py's admin, how does it work, and how do I 
> set it up?
>
>
> Kind regards,
>
> Annet
>
>

[web2py] Re: https for login

2012-05-16 Thread Ross Peoples
You could force a redirect within web2py. I do this with most of my 
applications:

In a model:

if request.controller == 'default' and request.function == 'user':
   request.requires_https()

This will force all user operations (login, profile, reset_password, etc) 
to use HTTPS. The advantage to doing it through web2py rather than through 
the web server is that if you get sick of Apache, you don't have to worry 
about this again with your new web server.


[web2py] Re: https for login

2012-05-16 Thread Ross Peoples
By the way, in case you are wondering, I stopped using Apache once I tried 
Nginx. Configuration is much easier (in my humble opinion) and it's way 
faster. So I've been using Nginx for all of my stuff for over 6 months now 
and haven't looked back. However, I still try to write my applications to 
be server-agnostic when I can.

[web2py] Re: https for login

2012-05-16 Thread Ross Peoples
I only know about it because I submitted it :) We really need to open the 
book up for editing so that we can add these kinds of things.

On Wednesday, May 16, 2012 9:22:28 AM UTC-4, Anthony wrote:
>
>request.requires_https()
>>
>
> Yet another secret feature. :-) 
>


[web2py] Re: RFC: web2py-based workflow engine

2012-05-16 Thread Ross Peoples
Cliff,

Thanks for putting this into a spec. My current code follows most of what 
is in there. I still haven't finished writing (or testing it), but I do 
have some thoughts on implementation for one or two of the items listed at 
the end:

I imagine a "workflow_monitor" table that has the fields: user_id, 
workflow_id. By default, when a workflow is started, the user that started 
gets added to this table along with the workflow they started. Using this, 
an application can design an interface that shows two lists: one listing 
workflows waiting on the user, and another listing workflows being 
monitored by the user. Templates should have to ability to set a default 
list of users or groups that automatically get added as monitoring the 
workflow. This would be great for managers to see a birds-eye view of 
everything going on for every person they manage.

Approvers should be part of the workflow, since it should not continue 
unless approved.

I'm not sure how to handle reviewers, since they don't really have any 
control over the workflow. Maybe reviewers can be marked as "monitoring", 
and when they need to comment on something, they just leave a note. For 
this, I see a "workflow_comment" table that has these fields: workflow_id, 
user_id, event_date, is_active, comment. The is_active field will be set to 
True by default. Once the comment / issue has been addressed, is_active 
gets set to False.

I could also imagine a high-level list of goals that need to be 
accomplished with the workflow, sort of like a checklist, that users mark 
as completed as the workflow moves through the system. This would probably 
satisfy a use case that exists in my current company. They currently use a 
page within a document as a "sign off" page to make sure everyone inspected 
their section of the document. Having this workflow checklist would remove 
the need for this extra page within the document.

Thoughts?

Thanks, Ross


[web2py] Re: SNI or dedicated IP.

2012-05-16 Thread Ross Peoples
I wouldn't know the first thing about setting up SNI, so I would tell 
WebFaction that if they will do it for me and it works, then sure, I'll use 
SNI, otherwise stick with what you know.

On Wednesday, May 16, 2012 12:14:42 PM UTC-4, Anthony wrote:
>
> I'd never heard of SNI before, but looking at the Wikipedia page for it: 
>> http://en.wikipedia.org/wiki/Server_Name_Indication
>>
>> This will NOT work. The main reason being that Python 2 (which web2py 
>> runs on) does not support SNI. Python 3.2 does, however. So until there is 
>> a web3py, SNI will not be an option unless you use it through Apache (and 
>> figure out how to enable it).
>>
>
> Wouldn't that only be a limitation with the Rocket server? But on 
> WebFaction, the app would probably be served with 
> Apacheor 
> Nginx,
>  
> so should work, no?
>
> Anthony 
>


[web2py] Re: RFC: web2py-based workflow engine

2012-05-16 Thread Ross Peoples
The data model I already have does things a bit differently, but I think it 
accomplishes the same thing. I am in the process of writing all of the 
support methods.

This is my current data model:

# workflow table
db.define_table('workflow',
Field('name', length=50),
Field('is_template', 'boolean', default=False),
Field('created_by', db.auth_user, default=current_user),
Field('created_on', 'datetime', default=self.request.now),
Field('table_name', length=128),
Field('row_id', 'integer'),
Field('order_id', 'integer', default=self.ORDER_ID_STOP, 
comment='Current position of the workflow'),
Field('priority', 'integer', requires=IS_INT_IN_RANGE(1, 9), 
default=self.DEFAULT_PRIORITY)
)

# allow users / groups to "monitor" select workflows without needing to be 
a part of the workflow
# if workflow is template, this list is copied to the new workflow
db.define_table('workflow_monitor',
Field('workflow_id', db.workflow),
Field('user_id', db.auth_user),
Field('group_id', db.auth_group),
Field('viewed', 'boolean', default=False) # once the monitor looks at 
it, mark as viewed until another change happens
)

# comments can be attached to workflows so that users can voice questions 
and concerns
db.define_table('workflow_comment',
Field('workflow_id', db.workflow),
Field('user_id', db.auth_user, default=current_user),
Field('event_date', 'datetime', default=self.request.now),
Field('is_active', 'boolean', default=True, comment='Is the comment 
waiting to be addressed'),
Field('comment', length=512, comment='The question, comment, or 
concern'),
Field('response', length=512, comment='Response to the question, 
comment, or concern')
)

# high-level list of goals for workflows. Users mark items as completed as 
they complete the goals
# if workflow is template, the checklist is copied to new workflow
db.define_table('workflow_checklist',
Field('workflow_id', db.workflow),
Field('name', length=50),
Field('order_id', 'integer', comment='Ordering position of the item'),
Field('is_active', 'boolean', default=True, comment='Is the item 
waiting to be addressed'),
Field('completed_by', db.auth_user),
Field('completed_at', 'datetime'),
Field('completed_note', length=512)
)

# workflow step table
db.define_table('workflow_step',
Field('workflow_id', db.workflow),
Field('order_id', 'integer', comment='Ordering position of the step'),
Field('name', length=50),
Field('user_id', db.auth_user),
Field('group_id', db.auth_group),
Field('hours', 'decimal(10,2)', requires=IS_DECIMAL_IN_RANGE(0), 
default=0, comment='Optional time limit in hours'),
Field('due_date', 'datetime', comment='Optional due date'),
Field('note', length=512, comment='Note on current state of the step') 
# represents a stateful note (i.e. kickback reason). Can change at any time.
)

# audit tables
db.define_table('workflow_event',
Field('workflow_id', 'integer'),
Field('table_name', length=128), # i.e. document, folder, etc
Field('row_id', 'integer'), # i.e. the ID of the document
Field('user_id', db.auth_user, default=current_user),
Field('event_date', 'datetime', default=self.request.now),
Field('action', length=10, default='update'), # could be: create, 
update, delete
Field('field_name', length=128), # i.e order_id, name, hours, etc
Field('value_before', length=128), # None if create or delete
Field('value_after', length=128) # None if delete
)

db.define_table('workflow_step_event',
Field('workflow_id', 'integer'),
Field('step_id', 'integer'), # the ID of the workflow_step modified 
(used to match up fields in batch changes)
Field('user_id', db.auth_user, default=current_user),
Field('event_date', 'datetime', default=self.request.now),
Field('action', length=10, default='update'), # could be: create, 
update, delete
Field('field_name', length=128), # i.e order_id, name, hours, etc
Field('value_before', length=128), # None if create or delete
Field('value_after', length=128) # None if delete
)


As you can see, this model has quite a few of the features we discussed: 
workflows, templates, monitors, comments, checklists, and auditing. It also 
has triggers that applications can register (i.e. before_step_complete, 
after_step_complete, etc) so applications can interact with the workflow 
engine when an event is triggered.

Workflows are copied from templates so that changes can be made to 
templates and workflows without one affecting the other. This has worked 
very well in my previous implementation. Tying monitors to templates 
wouldn't work well like this. Attaching monitors to workflows themselves 
also offers the advantage of giving the monitors a read/unread indicator 
and when a workflow has been changed (i.e step completed), the indicator 
turns back to "unread" so that way they keep up with workflows and not have 
to remember if a workflow has changed

[web2py] Re: web2py back reference and compute fields problem

2012-05-17 Thread Ross Peoples
I don't know about the "order.order_item.select()" part. Have you tried 
debugging the "calc" method? Insert this line right above "result = 0":
import pdb; pdb.set_trace()

Run the app from the console (i.e: python web2py.py -a password ...) and 
when the method gets called, the application should freeze. If you look at 
the console, you will have a (Pdb) prompt. Continue to enter "n" to move to 
the next line and type "print result" to show the value of result at any 
time. You should be able to figure out the problem this way.

If the application continues to work without freezing, then the "calc" 
method is not even being called, so you'd need to figure out why. 


[web2py] Re: RFC: web2py-based workflow engine

2012-05-17 Thread Ross Peoples


On Thursday, May 17, 2012 9:37:46 AM UTC-4, Cliff wrote:
>
> Ross,
>
> I understand your reasons for attaching approvals to the workflow.  I do 
> it the other way because if a deliverable needs approval by six parties, 
> putting six additional steps in the flow makes things a little cluttered. 
>  If you add six people as performers of an approval step, does that mean 
> that any one of the six can approve or must all of them?  
>

If you were to put all of them in a group and add the group as part of the 
workflow, any one of them can approve. For cases when you need all 6 to 
approve, then you would add all 6 of them as steps in the workflow. I don't 
know of a good, clean, and understandable way to do that otherwise.
 

>
> I very much like your workflow object table.
>
> I'm still debating over whether to use auth to handle the roles.  I think 
> auth needs a table called auth_role, actually a group of groups, to collect 
> permissions.  It would be nice to have a 'has_role' decorator for it.
>
>
Authorization is the only thing in this I'm having trouble wrapping my head 
around. Previously, I had the objects the workflows were attached to handle 
their own security with minimal restrictions on the workflow side. It 
worked out great because the documents were tightly integrated with the 
workflow system. The major problem being that only documents could 
participate in the workflows. So I'm still having trouble figuring out how 
to do this in a more general way without making it so complicated that no 
one would use it. I am definitely open to suggestions on this one.



[web2py] Re: RFC: web2py-based workflow engine

2012-05-17 Thread Ross Peoples


On Thursday, May 17, 2012 3:54:44 PM UTC-4, Cliff wrote:
>
> Let's inject manufacturing into the order processing scenario you were 
> using before.  It's a three step process.  Step one fabricates widgets. 
>  Step 2 attaches the widgets to widget bicarackets, purchased from another 
> vendor.  Step 3 packages the assemblies for shipment.
>
> If the last batch of widgets from the fabricator won't fit the brackets 
> because they are oversize, obviously the guy in assembly wants to send them 
> back for rework.  How would the system handle this?
>

In this case, assembly would reject their step, and enter a short message 
to explain why they rejected it. Assembly would also select a previous step 
in the workflow to send it back to, in this case the fabricator (step 1). 
The message from assembly goes into the workflow_comments table as needing 
to be resolved. Once the fabricator fixes the problem, they mark the 
problem resolved and send the workflow on to the next step (which in this 
case would be to step 2).
 

>
> And how would it avoid forcing the guy in charge of assembly to take 
> action on every batch of good widgets, assuming the system's intent is to 
> manage by exception?
>

Let's say the guy in assembly has 5 work orders to assemble for the day and 
each work order makes 20 assemblies (for a total of 100 things to make for 
the day). He would come in with the parts waiting for him for all 5 work 
orders, and he would have 5 workflows waiting on him. When he completes one 
work order (20 assemblies), he marks that workflow as completed and the 
workflow moves on to the shipping department. If we wanted, we could even 
add a "progress" field that allows him to enter a percentage of how close 
he is finishing the 20 assemblies for the one work order.

The great thing about doing it this way is allows management to track where 
everything thing is. My implementation puts an emphasis on accountability 
and making sure nothing gets lost or forgotten. Most manufacturing places 
have computers on the floor, so asking the assembly guy to click a button 
isn't a stretch for most places. In fact, by making this whole 
implementation generic like this, you could even put a simple keypad out 
there in assembly, shipping, and other places that don't have full 
computers to manage workflows.

Nothing about the implementation forces you to use a GUI. You could program 
a keypad to accept a work order number that marks the associated workflow 
as complete via a REST call or something. And worst case, you could always 
have the assembly supervisor handle the workflows for the guys in assembly. 
That's what supervisors are for, right? :)


[web2py] Re: RFC: web2py-based workflow engine

2012-05-18 Thread Ross Peoples
Yes, thanks for the links. I was able to add parallel steps that work as 
you describe. I have almost finished my workflow engine. I only have a 
couple more methods to write before I begin writing unit tests.

Thanks for all the input. I am still taking comments and suggestions, so if 
anyone has ideas to make it even better (or thoughts on how to handle 
security), your thoughts are welcome.


[web2py] Re: What to expect in web2py 2.0

2012-05-22 Thread Ross Peoples
There may even be an experimental workflow engine in there if I can finish 
it in time.

Re: [web2py] Re: What to expect in web2py 2.0

2012-05-22 Thread Ross Peoples
Richard,

Thanks for the offer. I *think* I'm nearly done. I'm writing some tests for 
it now and so far so good. If I run into any problems, I'll let you know.

Ross

On Tuesday, May 22, 2012 11:09:31 AM UTC-4, Richard wrote:
>
> Ross,
>
> If you need help just ask!
>
> Richard
>
>

Re: [web2py] Re: Unable to connect to mssql database

2012-05-22 Thread Ross Peoples
I have been using MSSQL from Linux for quite some time. I use FreeTDS for 
my driver. This is my connection string:

db = DAL('mssql://user:password@server/db_name?DRIVER={FreeTDS}')

If you need help setting up FreeTDS / unixODBC, let me know. I have some 
notes on how to set this up using a Ubuntu machine.


[web2py] Re: RFC: web2py-based workflow engine

2012-05-24 Thread Ross Peoples
Just wanted to give an update on this. I'm working on the workflow engine 
nearly every day. Workflow engines are complicated things with lots of 
pitfalls that need to be taken into account. Having said that, I am getting 
closer to completing it.

What works:

   - Templates
   - Creating workflows on-the-fly
   - Serial and parallel steps (wait on more than one user/group at a time)
   - Due date calculation taking schedules, holidays, etc into account
   - Simple flow of a workflow (i.e. every step is completed successfully, 
   without issue)
   - Full delta auditing with support for writing audit logs to another DAL 
   instance
   - Triggers (when someone does something to a workflow, some code can be 
   executed)

What needs to be finished:

   - Step rejections (someone noticed a problem created in a previous step 
   and wants to send it back to be corrected)
   - Workflow monitors (users that aren't currently involved with the 
   workflow, but want to monitor the workflow's progress)
   - Workflow comments (have rejections and other comments on the workflow 
   been addressed)
   - Workflow check-list (high-level workflow objectives, created and 
   managed by users, basically just meta-data)
   - Documentation (API and User Guide)

Most of the functionality in the "needs to be finished" list has been 
written, but not tested. The engine is about 1500 lines of code right now, 
which includes about 350 lines of tests. One of my main goals has been to 
write a test suite that tests as many scenarios as possible. Writing a user 
guide with example usage will come after the engine has been accepted in 
web2py. I want to make sure the API doesn't need changing before I start 
writing actual documentation.

I started writing this engine because I needed to replace a proprietary 
engine I created in C# several years ago that has seen years of production 
use. Unfortunately, the old engine lacks a lot of features (parallel steps, 
monitors, comments, check-lists, auditing, etc) and is tied to a single 
specific object. I wanted a workflow engine that could attach a workflow to 
just about anything. I also wanted it to have better features, cleaner 
code, and be easier to use.

Hopefully, I will continue to make excellent progress on it and have 
something to submit for approval soon. I'll keep you posted!


Re: [web2py] Re: RFC: web2py-based workflow engine

2012-05-25 Thread Ross Peoples
Andrew,

If I'm understanding you properly, the only major difference between the 
business process workflow (the one I am writing) and the data integration 
workflow you mention is that one requires human interaction, while the 
other is handled by automated systems. Is that fairly accurate? If so, then 
I could see my workflow engine being used for both types of workflows. I 
have well-defined the human interaction of workflows, but never touched on 
the automated aspect, though it was a consideration during the design of 
the engine.

Let me give an example of what I understand an automated workflow to be. 
Say we are running an e-commerce site and we want to create an automated 
workflow for the ordering process. This is how the process should go:

   1. Customer orders something
   2. Payment is processed
   3. Order confirmation email sent to customer
   4. Order is shipped
   5. Shipping confirmation email sent to customer

You could certainly just hardcode the "workflow" of each step, but then 
there's not a lot of flexibility. For example, maybe you want to insert an 
extra step later (i.e. quality control before shipping). You could use the 
workflow engine I'm creating to handle this scenario. Let me explain how:

You would have several parts to your e-commerce site:

   - Main web interface
   - Payment processing thread
   - Email thread for order confirmations
   - Email thread for shipment confirmations

I use the term "thread", but this would be any process or web2py scheduler 
instance that runs in the background waiting for something to do. You would 
have a process waiting for payments to process and processes waiting for 
emails to send. This could potentially be the workflow you would use for 
the ordering and shipping process:

# auth_group 50 = Automated payment processor group
# auth_group 51 = Automated order confirmation email group
# auth_group 52 = Shipping group of people that package the order
# auth_group 53 = Automated shipment confirmation email group

workflow_engine.create_template('Process order',
Step('Process the payment', dict(group=50)),
Step('Send order confirmation email', dict(group=51)),
Step('Package and ship order', dict(group=52)),
Step('Send shipment confirmation email', dict(group=53))
)

The trick here being that you can assign workflows to groups. So if you 
create a group for each background process, then those processes can 
continually check to see if there are any workflows waiting on them. Once 
they finish their job, they call:

workflow_engine.step_complete(workflow_id, as_group=50) # payment processor 
is finished

Because it's designed to be as general as possible, you can have the best 
of both worlds which this example demonstrates: mixing both human and 
automated workflows into a single workflow.

Does this address you question?

Thanks


Re: [web2py] Re: RFC: web2py-based workflow engine

2012-05-25 Thread Ross Peoples
No, it is just a singleton module, just like Auth or Cache.

[web2py] Re: CMS idea

2011-12-12 Thread Ross Peoples
This would be great tool for moving an existing website to a web2py-based 
CMS. I remember having to move static HTML pages to WordPress a few years 
back and it was such a pain. This would be an excellent migration tool.

[web2py] Re: How to save the 'current' object to database?

2011-12-13 Thread Ross Peoples
I don't think you can because "current" is a threaded object. It contains 3 
things: request, response, session. You could probably serialize much of 
the data contained in those three objects, however, this will be difficult 
because they contain functions. Web2py does a lot of this when it generates 
an error ticket. So maybe you could look into how those tickets are 
generated.

Also, I have to ask: Why would you want to do this? Web2py does it to 
provide debugging information when something bad happens and that's about 
the only reason this type of thing should be done. If there is something 
else you are trying to accomplish, maybe we can find a better way.


[web2py] Re: How to save the 'current' object to database?

2011-12-13 Thread Ross Peoples
I've never used GAE before, but you would normally get the absolute path to 
web2py using something like this:

import os
from gluon.settings import global_settings

web2py_path = os.path.join(global_settings.applications_parent, 
request.folder)

Hope that helps.


Re: [web2py] production site hosting

2011-12-20 Thread Ross Peoples
There's a sticky on this somewhere, but webfaction is always recommended. 
There is also Google App Engine. If you would like a VPS-like host instead, 
then Rackspace, VPS.NET and Amazon EC2 are also options.

[web2py] Re: haml and sass

2011-12-20 Thread Ross Peoples
HamlPy is actually really cool. I've never heard or seen anything about it 
until now. It's like CSS syntax for making HTML so you don't have to write 
so much HTML code. If you can get something together to make it work with 
web2py, you could probably get it added to contrib.

Re: [web2py] Re: site-packages how?

2011-12-20 Thread Ross Peoples
>From my understanding, if you just plan on using 3rd party modules in a 
single application, then they should go into the application/modules 
folder. If they are going to be used in several applications, then you put 
them in site-packages. At least, that's how I've been doing it.

[web2py] Re: Is there any "mainstream" wysiwyg html editor in web2py world?

2011-12-20 Thread Ross Peoples
I actually wrote this one that Anthony 
mentions: https://bitbucket.org/PhreeStyle/web2py_ckeditor/wiki/Home

It is based on the framework laid in the slice (#4) that you mention.


[web2py] Re: json with https?

2011-12-20 Thread Ross Peoples
I do it all the time. As long as you are connecting to the same server that 
you loaded the page from, then you are all set. This is how I normally make 
JSON requests:

var url = '{{=URL('some.json')}}/';
jQuery.getJSON(url).success(function(data) {
// finished successfully
alert(data);
}).fail(function(err) {
// ajax failed
alert(err);
});

There are many ways to do this, but this one seems to be the most robust 
for me, as it can catch connection and server errors.


[web2py] Re: haml and sass

2011-12-20 Thread Ross Peoples
That's funny :) I didn't go very deep into the haml docs. I just saw the 
part about:

#wrapper
.header Title text
.body Text for the body

And realized it would be quicker to write than:


Title text
Text for the body


Wonder if we could do something like this in web2py, but make it suit our 
needs while making it faster to write than HTML.


On Tuesday, December 20, 2011 10:43:36 AM UTC-5, Massimo Di Pierro wrote:
>
> so ... ruby has discovered the value of whitespaces... but in the
> wrong place!.
>
>

[web2py] Need Help with Custom Form Widget (Possible web2py Bug)

2011-12-30 Thread Ross Peoples
Was recently informed of a problem with plugin_ckeditor that I have been 
trying to solve for a while now, but I think it may actually be a web2py 
bug. First of all, here is the widget:

def widget(self, field, value, **attributes):
"""
To be used with db.table.field.widget to set CKEditor as the 
desired widget for the field.
Simply set db.table.field.widget = ckeditor.widget to use the 
CKEditor widget.
"""
default = dict(
value = value,
_cols = 80,
_rows = 10
)

attributes = FormWidget._attributes(field, default, **attributes)
attributes['_class'] = 'text plugin_ckeditor'

textarea = TEXTAREA(**attributes)
javascript = XML('some javascript code here')
result = [textarea, javascript]

return result


And here is a test controller:

def test():
form = SQLFORM.factory(
Field('requiredfield', required=True, notnull=True),
Field('textfield', 'text', widget=ckeditor.widget)
)

if form.accepts(request.vars, session, keepvalues=True):
response.flash = 'Accepted'
elif form.errors:
response.flash = 'There are some errors'

return dict(form=form)


This works great until there is a validation problem while submitting the 
form. Once that happens, instead of getting CKEditor in the form for the 
'textfield' field, I get "[, 
]".

I have tried wrapping both TEXTAREA and XML(javascript) into a single XML() 
object, but when this happens, FORM will not pick up the value for the 
field, even though it's in request.vars.

Thanks for your help.


Re: [web2py] Need Help with Custom Form Widget (Possible web2py Bug)

2011-12-30 Thread Ross Peoples
Thanks Bruno! To solve it, you used CAT() instead of returning a list. I 
have updated my code and tested. Thanks again for the help!

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

2012-01-01 Thread Ross Peoples
I use subprocess.Popen a lot to run shell commands from Python. There is no 
need for a specific web2py feature.

This is the method I use whenever I need to call something:

import subprocess
def run_command(self, *args):
"""
Returns the output of a command as a tuple (output, error).
"""
p = subprocess.Popen(args, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
return p.communicate()

It's very simple to use:

output, error = run_command('python', 'my_script.py', 'arg1', 'arg2', ...)

This runs the command, waits for it to exit, and then you have a string 
"output" for the output from the command, and a string "error" for any 
error output from the command.


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

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

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

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

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


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

2012-01-02 Thread Ross Peoples
Mike,

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

Ross


Re: [web2py] gluon.storage.Storage - No more KeyError breaks backward compatibility

2012-01-03 Thread Ross Peoples
Bruno is correct, and that's the whole point of Storage is that you don't 
have to test request.vars, you just call it. Alternatively, you can treat 
Storage just like any other dict().

For your example, there are many ways to solve the above example:

if 'sort' in request.vars:
sort = request.vars.sort
else:
sort = 'created'


And then there's the one-line solution:

sort = request.vars.get('sort', 'created')

This line accomplishes the same thing, except better. If request.vars has 
'sort', then return its value, otherwise return 'created'.


[web2py] Re: global functions in models

2012-01-04 Thread Ross Peoples
Are you having trouble with the line:

auth.user.my_budgets.append(session.table_token)

Or with return? I only ask because the above line assumes that the current 
user object has a list by the name of my_budgets. Is this list created 
somewhere else in the code? Also, because the user may not actually be 
logged in at the time this code is run, auth.user may equal None.

The best thing to do here is make sure you're running web2py from the 
command line, then insert this line at the beginning of the 
register_new_table_token() function:

import pdb; pdb.set_trace()

This will cause web2py to stop so that you can use the command line to 
inspect variables and such. Once this line is called, the command line will 
show a prompt that looks like "(Pdb)". From here, type "print auth.user" to 
get the current auth.user information, enter "n" to continue execution to 
the next line and stop again, or "c" to continue execution like normal.

This standard Python debugging technique is something I use frequently when 
I have code doing something unexpected.


[web2py] Packaging web2py + application

2012-01-05 Thread Ross Peoples
Hello everyone,

I want to make an RPM package for my application that primarily targets 
CentOS. I am working with version 5, which only has Python 2.4. I would 
like to create an RPM that packages Python 2.7, web2py, and my application. 
Does anyone have any experience with doing anything like this? I'm a 
developer, not a packager, so this is all new to me.

Any help would be greatly appreciated. Thanks,

Ross


Re: [web2py] Packaging web2py + application

2012-01-05 Thread Ross Peoples
StaticPython looks pretty cool, but there are two issues I see with this:

First, my target platform is 64-bit. StaticPython is only 32-bit.
Second, the RPM is a requirement. In the future, we may create a yum repo 
for the application for updates and things like that, so we have to use RPM 
from the beginning.


[web2py] Re: Packaging web2py + application

2012-01-06 Thread Ross Peoples
Thank you for the insight LightDot. When you make web2py RPMs, do you use a 
python setup.py file to make them, or do you manually package an RPM 
yourself using rpmbuild -ba web2py.spec?

Re: [web2py] Re: Is there an example? RPC between applications

2012-01-06 Thread Ross Peoples
The thing that jumps out at me in this one is that you are using an xmlrpc 
client, yet your URL is calling jsonrpc. Change the client connection 
string to:

http://127.0.0.1:8000/api/default/call/xmlrpc


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

2012-01-10 Thread Ross Peoples
Two things:

First, the "my_script.py" is the program you want to run to get output 
from. I just used a Python script as an example. This line could just as 
easily be:

output, error = run_command('ls', '-l')

to list all files in a directory (though you would typically use Python's 
os module for this). Again, the command can be anything that you would type 
yourself, with the exception that arguments need to be in a list format (in 
other words, you can't use 'ls -l' as the command, you have to split it up 
into 'ls', '-l').

Secondly, this may not be the best thing for you to try as a beginner. 
Doing things like this requires managing multiple processes, which makes 
things much more complicated. If you must do this right now, then use the 
first example I gave (that blocks until the command is complete). That is 
the easiest way.

Trust me, if you are uncomfortable with this, then having to sync up 
multiple processes to do live streaming of output will be a nightmare for 
you, no matter what route you take.


[web2py] Re: plugin badmin

2012-01-10 Thread Ross Peoples
What does it do? There's no description, just that it's an "automatic 
admin".

[web2py] Re: digit separator symbol for int

2012-01-10 Thread Ross Peoples
This StackOverflow question should answer 
it: 
http://stackoverflow.com/questions/1823058/how-to-print-number-with-commas-as-thousands-separators-in-python-2-x

The second part of the answer can help you if you are trying to add commas 
in a non-standard way.


[web2py] Re: setup web2py with a virtual host on apache

2012-01-10 Thread Ross Peoples
Using what Kenneth just said, are you trying to access web2py using this 
URL?

http://domain.com:8080/

Also, are you restarting Apache every time you make a change?


[web2py] Re: One to many question

2012-01-10 Thread Ross Peoples
You might be able to do something like this to trick it into being a 
virtual field:

db.user.account = Field.Virtual(lambda row: row.account_id)

This just makes a virtual field "account" which returns the value of 
"account_id". This will only work with reads, though. If you try to set a value 
to db.user.account, it will not work, you have to set it to db.user.account_id.



[web2py] Re: How do you manage your app repo with Mercurial

2012-01-10 Thread Ross Peoples
On my dev machines, I'm using SQLite, so the database is the same 
regardless of what machine I'm using. In your case, you could set your 
db.py file to detect your machine's host name and use the appropriate DAL 
string accordingly.

For example:

import socket
hostname = socket.gethostname()

if hostname == 'dev1':
db = DAL('postgres://123.45.168.90/mydb')
elif hostname == 'dev2':
db = DAL('postgres://98.76.43.21/mydb')
else:
# production database
db = DAL('postgres://22.33.44.55/productiondb')


Another option, which I used to use is to set up the database on your 
primary dev machine (probably your home workstation), then when using your 
laptop, set up an SSH tunnel, forwarding the database port. You would still 
have to use the method above, since your laptop would see your home 
database server as running locally, but at least this way you can work with 
the same database all the time.

The second option may or may not be good for you, but that's up to 
youI'm just making sure I give you a couple of options to chose from.


[web2py] Re: setup web2py with a virtual host on apache

2012-01-10 Thread Ross Peoples
Are you trying to make http://domain.com:8080 go to localhost:8080, or are 
you expecting http://domain.com(:80) to go to localhost:8080?

Re: [web2py] Re: One to many question

2012-01-10 Thread Ross Peoples
Bruno, I've never tried that way before. Will that cause web2py to create a 
new field "account"?

[web2py] Re: setup web2py with a virtual host on apache

2012-01-10 Thread Ross Peoples
Ok, that's what I thought. You cannot do this easily. There are only two 
way that I know of to make this happen: configure your router to map port 
80 to 8080 internally (breaking IIS), or to use an HTTP proxy. The reason 
being that whenever you go to a URL, it implicitly connects to port 80. And 
since IIS is running on port 80, IIS gets the request. You MIGHT be able to 
configure IIS to proxy requests to a specific domain to Apache, but I only 
know how to do that if Apache is the primary (running on 80). I can't help 
with IIS.

[web2py] Re: setup web2py with a virtual host on apache

2012-01-10 Thread Ross Peoples
If you run Apache on port 80, you can setup an Apache site to proxy to 
another web server. For example, I have this Apache site file to forward 
all requests for domain2.com to another web server on the local network:


ServerName domain2.com


Order deny,allow
Allow from all


ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://192.168.1.201:8080/
ProxyPassReverse / http://192.168.1.201:8080/

SetEnv proxy-nokeepalive 1


So all requests that come to domain2.com get proxied to 192.168.1.201:8080.

You may need to install / enable mod_proxy on Apache for this to 
workand Apache HAS to run on port 80. In this case, you would set IIS 
to run on 8080 instead.


Re: [web2py] Forwarding domain to a port

2012-01-12 Thread Ross Peoples
I actually just answered the same question the other day. See my last post 
in this thread: https://groups.google.com/forum/#!topic/web2py/PjqPoHnNwu4

It explains how to use Apache as a proxy to forward requests from a 
specific domain to another computer or another port.


[web2py] Re: Set table name

2012-01-13 Thread Ross Peoples
I don't know if anyone has tried this kind of thing before. The only idea I 
have right now is to alias your table objects. This MIGHT work, or might 
make things worse :) Either way, try this and see if it works (no promises):

db.define_table('person12345',
Field('name'),
)
db.person = db.person12345

db.define_table('dog12345',
Field('name'),
Field('owner', db.person)
)
db.dog = db.dog12345



Re: [web2py] Re: priority of web2py CMS

2012-01-16 Thread Ross Peoples
I am also working on a CMS that will be a bit different than Movuca. The 
goal with my CMS is that I could stick an executive in front of it (someone 
who barely knows how to check their email), and allow them to theme their 
site, lay it out they way they want, and add content with a simple drag & 
drop interface.

That's goal. We will see if I can actually make it happen :)


[web2py] Re: priority of web2py CMS

2012-01-16 Thread Ross Peoples
Not yet. Just a bunch of proof of concept ideas. I have to combine them 
into a workable solution, which will take some time. The good news is I've 
already figured out how to do it, I just have to put the work in.

[web2py] Problem with Rocket and --interfaces

2012-01-18 Thread Ross Peoples
Rocket doesn't seem to like the --interfaces parameter. This is my command 
line string:

python web2py.py -a "" 
--interfaces="0.0.0.0:8001:/home/ross/Desktop/web2py/scripts/service/ca.crt:/home/ross/Desktop/web2py/scripts/service/ca.key"

When this is run, I get the following:

ERROR:Rocket.Errors.Port8001:Socket "0.0.0.0:8001 in use by other process 
and it won't share.
WARNING:Rocket.Errors.Port8001:Listener started when not ready.

However, nothing else is using port 8001 except web2py. If I use this, then 
it works fine:

python web2py.py -a "" -i 0.0.0.0 -p 8001 
-c /home/ross/Desktop/web2py/scripts/service/ca.crt 
-k /home/ross/Desktop/web2py/scripts/service/ca.key

But for some reason, the --interfaces parameter does not work. If I don't 
use quotations (") around it, then web2py starts up on port 8001, but not 
using SSL, just regular HTTP.


[web2py] Re: Is this a bug? Restrictions in model file names

2012-01-18 Thread Ross Peoples
You will find that the underscore is required for a lot file names, not 
just models, as using a hypen in a variable name is invalid in Python. 
Modules are the same way. You can't do this:

import my-module

The Python syntax is invalid. The same is true for models. I believe it 
also applies to controllers and views.


[web2py] Re: TYMR - web2py social network - Invitations for this community

2012-01-18 Thread Ross Peoples
Looks very cool!

[web2py] Re: web2py with Plesk Control Panel ?

2012-01-23 Thread Ross Peoples
You can install Python 2.6 on CentOS by using the EPEL yum repository. It 
will leave the system's Python 2.4 installation alone, since you don't want 
to mess that up. The Python 2.6 name will then be "python26" instead of 
just "python".

[web2py] Re: How to modify the look and text of: Remember me (for 30 days)?

2012-01-24 Thread Ross Peoples
There are settings for almost everything. Sometimes the book doesn't 
explain every single one though. The best way to figure out what's going on 
is to open the "gluon/tools.py" file, and find the Auth class. This class 
will have all the settings listed with their default values at the top of 
the class.

[web2py] Re: google code (mercurial) problem

2012-01-24 Thread Ross Peoples
Which one are we using as the primary repo now, is it Google Code or GitHub?

[web2py] Re: Redbean-like ORM in web2py

2012-01-27 Thread Ross Peoples
I don't know about future development plans, but I can say that web2py does 
not use an ORM, it uses a database abstraction layer that generates the 
proper SQL (and NoSQL) code. Lack of an ORM is sometimes touted as a 
feature of web2py because ORMs are usually big, complicated, and difficult 
to learn and maintain. Web2py's DAL is about the simplest, yet most 
powerful database abstraction layer I've ever used, so I'm very happy with 
the current solution. However, there is nothing stopping you from using 
RedBrean or even SQLAlchemy in your web2py projects.

Re: [web2py] Web2py in large web scenarios

2012-01-27 Thread Ross Peoples
This is very good advice. I have moved many of my plugins and apps from 
using models to modules because of the performance gain. There is nothing 
wrong with the models implementation, but it's really meant to define 
tables and that's it. Functionality that doesn't belong in a controller 
should go to modules.

Some other advice that I have been gathering for my own deployments is to 
use Nginx instead of Apache. You will see an incredible increase in the 
number of requests per second that Nginx can handle over Apache. Also 
setting up an Nginx front-facing server that is proxying requests to 
another server running Nginx + web2py might be a good idea for lots of 
traffic. Have the front-facing server handle the SSL traffic, and maybe 
even enable caching on the front-end as well. When you need to add another 
server to handle increased traffic, this front-facing Nginx server can be 
configured to load balance so that you can scale as much as you need.


Re: [web2py] Web2py in large web scenarios

2012-01-27 Thread Ross Peoples
One other thing I noticed after reading your question a second time: Python 
(Django and web2py) will run much faster than PHP in almost every case. If 
you needed to start passing things to PHP in order to speed things up, then 
you must have been using a highly-tuned PHP configuration and a very 
untuned Python configuration.

[web2py] Usage errors printed to console

2012-01-28 Thread Ross Peoples
I pulled from trunk a week or so ago and ever since, I've been getting this 
every few minutes printed to the console:

WARNING:web2py.cron:WEB2PY CRON Call returned code 2:
-J is reserved for Jython
usage: /usr/bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

I am running web2py using this: python web2py.py -a password -i 0.0.0.0

If I add -N, the error goes away. I'm not using cron or anything. I only 
have one app in this web2py instance. Anyone else noticing these errors?


[web2py] Re: hollywoodr.js

2012-01-30 Thread Ross Peoples
LOL. At first, I wasn't sure where this was going until I read the last 
line of the README.

[web2py] Re: help with js issue

2012-01-30 Thread Ross Peoples
Just wanted to add that this happens to me too, but it actually does stop. 
Sometimes it takes 20 seconds, sometimes it takes a minute or two, but it 
eventually stops without needing to kill -9. So there could be a timeout 
issue somewhere.

Re: [web2py] Re: help with js issue

2012-01-30 Thread Ross Peoples
Usually if I start and immediately stop, then it quits quickly. But after 
using the app (database activity, logout/login, etc) for a few minutes, 
then I start to notice the problem.

Re: [web2py] Re: help with js issue

2012-01-30 Thread Ross Peoples
Also, I am running this:

python web2py.py -a password -i 0.0.0.0 -p 8001 -N

I have to use -N, otherwise I get a web2py cron error in the terminal every 
15 to 30 minutes.


[web2py] Re: [w2py-dev] model less apps (a blog example)

2012-01-30 Thread Ross Peoples
Bruno,

This is a good article. I have done something like this before. My approach 
was a bit different. I was using the singleton pattern, but I think it 
accomplishes the same goal.

I would for example have a module like this:

from gluon import *

class MyModel(object):
instance = None

def get(db):
if instance is None:
instance = MyModel(db)

return instance

def __init__(self, db):
db.define_table()


Then I would still have a db.py for a model, but I would replace the usual 
db.define_table() with this:

from mymodel import MyModel
MyModel.get(db)

This ensures that the tables only get defined once on the first request 
after starting web2py. I have used this approach on other code that I 
needed to keep alive for other requests.


Re: [web2py] Re: help with js issue

2012-01-30 Thread Ross Peoples
I was able to reproduce this a few times by doing this:

Start web2py:
python web2py.py -a password -i 0.0.0.0 -N

Navigate to the admin app from another computer (important):
http://192.168.1.10:8000/admin

You will get the "admin is disabled" message. Now try to Control + C 
web2py. For me, it took about 30 seconds to quit.


Re: [web2py] Re: help with js issue

2012-01-30 Thread Ross Peoples
In reference to the cron error, I posted this a couple days ago:

https://groups.google.com/forum/#!searchin/web2py/ross$20peoples$20cron%7Csort:date/web2py/q4qoTTuu6zw/jo-H1LPjWB4J


Also, I should mention that for the stopping problem: It's not just Mac. 
The previous message with instructions on how to reproduce was done using 
Ubuntu 10.04.


[web2py] Re: Opinions, please: best way to set up multiple apps on one site?

2012-02-02 Thread Ross Peoples
I have used the plugin approach before with success on a medium-sized app. 
You just have to design them properly or the plugins will rely on each 
other, which kind of defeats the purpose.

[web2py] Re: Opinions, please: best way to set up multiple apps on one site?

2012-02-02 Thread Ross Peoples
If they are only sharing the auth table, then it's not a big deal, since 
the auth tables are there by default. But plugins are meant to be 
completely isolated from each other, completely unaware that other plugins 
exist.

Putting core logic (accessing data) into modules and using more generic 
plugins to handle the views might be the best way to go. I use modules 
extensively, and only use models to set up the module instances as global 
variables. I use the singleton pattern for my modules, which works well for 
me, but Bruno's approach is also pretty good, but a little more complicated.


[web2py] Re: Debugging in web2py

2012-02-02 Thread Ross Peoples
Run web2py from console, and put "import pdb; pdb.set_trace()" right above 
the line of code where you want to start debugging. From there, use "n" to 
go to the next line, "s" to "step into" the next line, and "c" to continue 
execution.

Good luck!


  1   2   3   4   5   6   >