webtek-devel Mailing List for WebTek (Page 5)
Status: Alpha
Brought to you by:
prozessor13
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(3) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
(3) |
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(10) |
May
(32) |
Jun
(65) |
Jul
(31) |
Aug
(9) |
Sep
(15) |
Oct
(9) |
Nov
(24) |
Dec
(12) |
2009 |
Jan
(32) |
Feb
(4) |
Mar
(13) |
Apr
(28) |
May
(66) |
Jun
(76) |
Jul
(45) |
Aug
(24) |
Sep
(22) |
Oct
(30) |
Nov
(6) |
Dec
(3) |
2010 |
Jan
|
Feb
|
Mar
(39) |
Apr
(46) |
May
(61) |
Jun
(48) |
Jul
(38) |
Aug
(45) |
Sep
(20) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: max d. <pro...@gm...> - 2008-06-02 19:23:38
|
yep. i plan to port the _info function into the handler to show all this details. also on the _info action screen there should be links to all available handler's _info pages. On Jun 2, 2008, at 9:17 PM, Adrian Smith wrote: > After our discussion on Skype yesterday where you mentioned one > could write <% if %>, I've found a number of new useful macros in > "Handler.pm" in the WebTek source code. Maybe these macros should be > included into the /_info URL? > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: Adrian S. <adr...@gm...> - 2008-06-02 19:18:26
|
After our discussion on Skype yesterday where you mentioned one could write <% if %>, I've found a number of new useful macros in "Handler.pm" in the WebTek source code. Maybe these macros should be included into the /_info URL? |
From: max d. <pro...@gm...> - 2008-06-02 08:18:36
|
dont know, maybe its a to old version of mysql, but really strange.. On Jun 2, 2008, at 1:51 AM, Adrian Smith wrote: > In the DB module: > sub last_insert_id { > my ($self, $table, $column) = @_; > > return $self->dbh->{'mysql_insertid'}; > > return $self->dbh->last_insert_id( > $self->catalog, $self->schema, $table, $column > ); > } > Strangely it didn't work on the server, which only has MySQL 4.0 > installed (not sure about DBI etc.) I added that line, and now it > works. > > Do you understand what's going on? > > Cheers, Adrian > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: max d. <pro...@gm...> - 2008-06-02 05:36:29
|
yes thats the right solution... On Jun 2, 2008, at 12:29 AM, Adrian Smith wrote: > Don't worry about this question; I've set the language to be "en" > directly from the CGI. My application has only one language so I > don't want stuff randomly breaking based on people's browsers > settings, which I have little intention of extensively testing. > > From: Adrian Smith [mailto:adr...@gm...] > Sent: Monday, June 02, 2008 00:26 > To: 'web...@li...' > Subject: use "en" by default..? > > Is there a possibility that WebTek uses "en" by default, in case > that a particular string is not available in the "de.po"? > > I know that in principle one should use English-language strings as > the keys, so it shouldn't matter if a string is not defined, but at > least for certain keys (e.g. error messages when a field is empty > but PROPERTIES marks it as being mandatory) this cannot be used > (which is a good thing in my opinion!) > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: Adrian S. <adr...@gm...> - 2008-06-01 23:51:09
|
In the DB module: sub last_insert_id { my ($self, $table, $column) = @_; return $self->dbh->{'mysql_insertid'}; return $self->dbh->last_insert_id( $self->catalog, $self->schema, $table, $column ); } Strangely it didn't work on the server, which only has MySQL 4.0 installed (not sure about DBI etc.) I added that line, and now it works. Do you understand what's going on? Cheers, Adrian |
From: Adrian S. <adr...@gm...> - 2008-06-01 22:29:42
|
Don't worry about this question; I've set the language to be "en" directly from the CGI. My application has only one language so I don't want stuff randomly breaking based on people's browsers settings, which I have little intention of extensively testing. _____ From: Adrian Smith [mailto:adr...@gm...] Sent: Monday, June 02, 2008 00:26 To: 'web...@li...' Subject: use "en" by default..? Is there a possibility that WebTek uses "en" by default, in case that a particular string is not available in the "de.po"? I know that in principle one should use English-language strings as the keys, so it shouldn't matter if a string is not defined, but at least for certain keys (e.g. error messages when a field is empty but PROPERTIES marks it as being mandatory) this cannot be used (which is a good thing in my opinion!) |
From: Adrian S. <adr...@gm...> - 2008-06-01 22:26:11
|
Is there a possibility that WebTek uses "en" by default, in case that a particular string is not available in the "de.po"? I know that in principle one should use English-language strings as the keys, so it shouldn't matter if a string is not defined, but at least for certain keys (e.g. error messages when a field is empty but PROPERTIES marks it as being mandatory) this cannot be used (which is a good thing in my opinion!) |
From: max d. <pro...@gm...> - 2008-06-01 14:28:29
|
yep. sure. this is bug... ... and its now fixed and in cvs ... On Jun 1, 2008, at 4:04 PM, Adrian Smith wrote: > If I have a form and I have a field, e.g. with: > > <% input name="company" %> > > if I have an action method which doesn't do anything, e.g. > > sub create :Action { } > > then if I press "Submit" on the web form, the form gets presented > again with > the submitted data as the default values of the fields. This is good > stuff. > However, I assert that quote escaping is not performed correctly. If > I enter > the following text > > abc"def > > i.e. with double-quotes in the text, then HTML like the following gets > generated in the response page: > > <input value="abc\" def="" name="company" type="text"> > > However this is wrong. This results in the following being displayed > in the > form field: > > abc\ > > The value should be > > <input value="abc"def" name="company" type="text"> > > Do you agree, or I have I don't something wrong? > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: max d. <pro...@gm...> - 2008-06-01 14:22:10
|
yep... i have cached it, and its in svn now. On Jun 1, 2008, at 3:29 PM, Adrian Smith wrote: > In WebTek::Model::MySQL there is a test: > > $type =~ /bool/i > > However "bool" isn't a type in MySQL. If you create a column of that > type it gets converted into "tinyint". If you do a "desc" on that > table you see the column as "tinyint" > > However there is a two-value type in MySQL, it's "bit", which can > take the value either 0 or 1. I have used that field for my boolean > values. > > Would it make more sense to change that test to be "bit" instead of > "bool"? > > (It doesn't make a great deal of difference in my case as the > variable is named "is_active" anyway so it gets treated as a boolean > by WebTek.) > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: Adrian S. <adr...@gm...> - 2008-06-01 14:05:59
|
If I have a form and I have a field, e.g. with: <% input name="company" %> if I have an action method which doesn't do anything, e.g. sub create :Action { } then if I press "Submit" on the web form, the form gets presented again with the submitted data as the default values of the fields. This is good stuff. However, I assert that quote escaping is not performed correctly. If I enter the following text abc"def i.e. with double-quotes in the text, then HTML like the following gets generated in the response page: <input value="abc\" def="" name="company" type="text"> However this is wrong. This results in the following being displayed in the form field: abc\ The value should be <input value="abc"def" name="company" type="text"> Do you agree, or I have I don't something wrong? |
From: Adrian S. <adr...@gm...> - 2008-06-01 13:29:54
|
In WebTek::Model::MySQL there is a test: $type =~ /bool/i However "bool" isn't a type in MySQL. If you create a column of that type it gets converted into "tinyint". If you do a "desc" on that table you see the column as "tinyint" However there is a two-value type in MySQL, it's "bit", which can take the value either 0 or 1. I have used that field for my boolean values. Would it make more sense to change that test to be "bit" instead of "bool"? (It doesn't make a great deal of difference in my case as the variable is named "is_active" anyway so it gets treated as a boolean by WebTek.) |
From: Adrian S. <adr...@gm...> - 2008-05-28 11:37:33
|
if the input-field is data for a model you can do the check with the model-PROPERTIES Ah OK - thanks very much - I'll use this (in the cases that the form directly links to data in a Model class) because webtek use for its translation .po files (= gettext) the keys shoud self-explained. e.g. a better error-key will be: my $addr = request->param->emai_address or $self->error_on("email_address", "Please define an Email-Address"); Well I didn't respond to your blog post about gettext yet :) I am not a friend of gettext, one could say. http://www.databasesandlife.com/gettext-is-so-broken/ Amongst other issues I have with gettext, I don't think using English-language text as a message key is a correct approach: http://blogs.msdn.com/oldnewthing/archive/2007/10/04/5269284.aspx WebTek::Exception::PageInvalid->throw if $self->has_errors; Ah perfect, I'll use this - thanks ! |
From: max d. <pro...@gm...> - 2008-05-28 07:34:30
|
On May 27, 2008, at 7:46 PM, Adrian Smith wrote: > Please excuse me if this question is obvious, but I couldn't find it > anywhere. > > If a <input type=text ....> should be e.g. > Mandatory > Match a regular expression e.g. contain only numbers and be at least > 2 characters long if the input-field is data for a model you can do the check with the model-PROPERTIES MyApp/Model/User.pm sub PROPERTIES {{ 'nickname' => '\w{3,20}' 'email' => sub { my ($self, $name, $value) = @_; # self is the User-model obj, $name is 'email' and $value the value return Email::Valid->address($value); }, ... } } your tpl: <% form %> nickname: <% input name="nickname" %><br /> email: <% input name="email" %><br /> ... <br /> <% input name="cancel" type="submit" %> <% input name="register" type="submit" %> <% form_end %> in your Page: sub register :Action { my $self = shift; if (request->is_post) { my $user = app->Model->User->new_default(request->params); $user->save; response->message("User registered"); response->redirect(app->Page->User->new_for_user($user)->href); } } if you do this: * a new user-model is created with the form params * on the $user->save method the $user->is_valid is called * throws an ModelInvalidException on error * if an ObjInvalidException is called, then the action is recalled with method GET (i.e. request->is_post returns false) * so the page is re-rendered with the error-information from the model as response->message if you want to check some form-fields, which are not for a model, the above code is correct: > Is the correct place to do this in the action method, e.g. > sub send_password_reminder :Action { > my $self = shift; > > if (request->is_post) { > my $addr = request->param->email_address > or $self->error_on("email_address", > "TariffCalc::Page::Root::". > "send_password_reminder::missing_email_address"); > .... > } > } but with one small difference: because webtek use for its translation .po files (= gettext) the keys shoud self-explained. e.g. a better error-key will be: my $addr = request->param->emai_address or $self->error_on("email_address", "Please define an Email- Address"); HINT: when you set errors in a page, this is needed, to highlight the invalid form-field, and to print the error-msg. additionally (and only you set custom-errors in page) you have to throw an Exception after all your checks are done. maybe something like this: WebTek::Exception::PageInvalid->throw if $self->has_errors; example: sub register :Action { my $self = shift; if (request->is_post) { #... create user my $user = app->Model->User->new_default(request->params); #... check captcha unless (session->captcha ne request->param->captcha) { $self->error_on('captcha', "Captcha invalid") } #... this is checking for model-errors $user->save; #... this is checking for page-errors WebTek::Exception::PageInvalid->throw if $self->has_errors; response->message("User registered"); response->redirect(app->Page->User->new_for_user($user)->href); } } > Or is there a better place to do this, e.g. regexp field in the <% > field %> somewhere? (I have this memory I've seen this somewhere, > but I couldn't find it) > > Both are fine - I was just wondering what the recommended way to do > it is! > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: Adrian S. <adr...@gm...> - 2008-05-27 17:47:17
|
Please excuse me if this question is obvious, but I couldn't find it anywhere. If a <input type=text ....> should be e.g. * Mandatory * Match a regular expression e.g. contain only numbers and be at least 2 characters long Is the correct place to do this in the action method, e.g. sub send_password_reminder :Action { my $self = shift; if (request->is_post) { my $addr = request->param->email_address or $self->error_on("email_address", "TariffCalc::Page::Root::". "send_password_reminder::missing_email_address"); .... } } Or is there a better place to do this, e.g. regexp field in the <% field %> somewhere? (I have this memory I've seen this somewhere, but I couldn't find it) Both are fine - I was just wondering what the recommended way to do it is! |
From: max d. <pro...@gm...> - 2008-05-26 15:24:22
|
On May 26, 2008, at 4:23 PM, Adrian Smith wrote: > > In another post on the mailing list, concerning breadcrumbs, you > wrote: > > sub breadcrumbs :Macro > :Param(render a breadcrumbs navigation) > :Param(separator=" , " optional, default = ' > ') > :Param(class="...") > { > yep this code-attributes :Param are only used for documentation and are displayed in the _info action > How does this work? What do these parameters mean? Specifically: > > The first Param seems to be some sort of documentation - the others > don't > The "separator" parameter has a default and is optional. But what is > the " , " for? when you declare the macro <% breadcrumbs separator=" , " %> you get something like this PageA , PageB, edit when you declare <% breadcrumbs %> you get PageA > PageB > edit the corespondig code in the "sub breadcrumbs :Macro { .. } is this: my $sep = $params{'separator'} || ' > '; > Is there a documentation of how to create a Macro and the syntax for > Param? If so, please excuse me for having missed it. sorry no, no actual, here a quick reference * a macro can have params * there exists system-wide params * prefix and suffix: their content is rendered if the macro has some content * default: this is rendered if the macro has no content * if and unless: render only if/unless condition <% posts if="<% session.user %>" %> * failmode="silent": dont die when the macro has a runtime-error * all other params go to the macro-function: sub posts :Macro { my ($self, %params) = @_; ... } * a macro can have filters * a filter is delimited to the macro with a | (=pipe): <% create_time | format_date format="%Y%m%d" %> * you can use multiple filters in on macro <% text | truncate limit="10" | uppercase %> * for a detailed list of filters you have to look into the code (WebTek::Filter) * you can create filters also in your application: sub my_filter :Filter { my ($self, $string, $params) = @_; .... return $string } * there a also exists handlers * handlers are in front of the macro-name: app.name, session.user.nickname * a handler has macros * the default handler is the current page * there exists system-wide handlers * app: <% app.name %> * request: <% request.param.nickname %> * response: <% response.title %> * session: <% session.user %> * if the session->user obj is also a handler (every page is a handler) you can say <% session.user.nickname %> * you can define handlers with the :Handler code-attribute: sub user :Handler { ... return $user } if you want to find out which macros has a page try the _info action (http://max.xaok.org/weblog/_info ). every page has this action. but in this action there are only the macros for the actual page, so if you want more informations you have to look at the code (or ask me). search for the :Handler and :Macro and :Filter code-attributes. note the a lot of functions are defined with 'make_accessor' or 'WebTek::Util::make_method' functions. the last parameter of this calls are a list of code-attributes. > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: max d. <pro...@gm...> - 2008-05-26 14:44:05
|
On May 26, 2008, at 4:23 PM, Adrian Smith wrote: > I notice that the "session" table, in the MySQL table-creation > script, is of type "MyISAM" instead of "InnoDB". > I shall be using InnoDB for my MySQL database tables. I assume this > is no problem? should be no problem > > In this case, would you recommend I change the "session" table to be > "InnoDB", in order to keep work done on model objects, and values > saved in the "session" table, consistent in the case of an > unexpected error or power failure? ?? dont understand this question (my poor english) ;) > I had a look at the code, and could not quite work out how/when/if > transactions were started and committed. Can you confirm that I > don't have to do anything special in my code - i.e. before every web > request, a DB transaction is opened, and after every successful web > request, the DB transaction is committed? transactions are done with events (request-end (=commit) or request- had-errors (=rollback). ups. i didnt update the event-names in WebTek::DB. this is done yet and checked in into the trunk repository ps: i havn't tested transactions so far, because i never used them, but the code is there and should work ... :) (hope so) > (Or do I have to explicitly open/close DB transactions in my code, > around logic which I wish to be joined in a transaction?) no. > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: Adrian S. <adr...@gm...> - 2008-05-26 14:25:16
|
I notice that the "session" table, in the MySQL table-creation script, is of type "MyISAM" instead of "InnoDB". I shall be using InnoDB for my MySQL database tables. I assume this is no problem? In this case, would you recommend I change the "session" table to be "InnoDB", in order to keep work done on model objects, and values saved in the "session" table, consistent in the case of an unexpected error or power failure? I had a look at the code, and could not quite work out how/when/if transactions were started and committed. Can you confirm that I don't have to do anything special in my code - i.e. before every web request, a DB transaction is opened, and after every successful web request, the DB transaction is committed? (Or do I have to explicitly open/close DB transactions in my code, around logic which I wish to be joined in a transaction?) |
From: Adrian S. <adr...@gm...> - 2008-05-26 14:25:15
|
> you have request->path, wich will return an array-ref with > all pages in the current url. look at the _info action, here > is such a navigation OK I'll do that > > a "breadcrumb.tpl" in each Page class. > > this is not necesarry, becaue i think all could done in the > message- files (placed in messages/*.po) OK excellent - I'll do that ! > maybe something like this OK thanks ! |
From: Adrian S. <adr...@gm...> - 2008-05-26 14:25:09
|
In another post on the mailing list, concerning breadcrumbs, you wrote: sub breadcrumbs :Macro :Param(render a breadcrumbs navigation) :Param(separator=" , " optional, default = ' > ') :Param(class="...") { How does this work? What do these parameters mean? Specifically: 1. The first Param seems to be some sort of documentation - the others don't 2. The "separator" parameter has a default and is optional. But what is the " , " for? Is there a documentation of how to create a Macro and the syntax for Param? If so, please excuse me for having missed it. |
From: Adrian S. <adr...@gm...> - 2008-05-23 15:59:48
|
Sorry for previous mail (Outlook UI problems) In general there are three ways to model inheritence hierarchies in Object-relational mapping systems: 1. All information is in one table. All attributes accross all subclasses are present in this table. If an object/row is of one concrete class, all attributes for all other concrete classes are null in this table. 2. There is one table for each concrete class. All the common (superclass) attributes are duplicated into each of these tables. In my case there would be an "administrator_user" and "adviser_user" table (but no "user") table. Both of those tables would have "username" and "password" attributes. 3. There is one table for each class in the system, including concrete and abstract classes. So in my case there would be "user", "advisor_user" and "administrator_user" tables. There would be a foreign key from e.g. "advisor_user" to "user". For every row in "user", to find out which subclass that user is, either a select is done against both conrete tables to see which one has a row, or the "user" table can include an extra "discriminator" attribute, e.g. user_type. Which option one chooses depends on how many classes one has, how many attributes one has, and what performance characteristics one desires. I have thought more about my application and decided I wish to go for option 2. Perhaps this could be implemented in WebTek by creating the two tables, and creating the two Model classes, and: 1. Each Model extends a "User" class; this "User" class extends WebTek::Model. (As opposed to the Model class directly extending WebTek::Model which is the default). 2. As Perl requires no attribute definition, the fact that the common attributes (e.g. "username" and "password") are in reality in the subclasses, whereas philosophically they should be in the abstract superclass "User", is irrelevant. 3. The "User" class could contain extra methods such as "find_by_id" which would instanciate the subclass of the right type. 4. Creation and updating would work as usual, as one would always be dealing with a concrete class. Do you understand what I mean? Maybe I haven't explained it clearly... Thanks in advance > -----Original Message----- > From: web...@li... > [mailto:web...@li...] On Behalf > Of max demmelbauer > Sent: Friday, May 23, 2008 14:14 > To: web...@li... > Subject: Re: [Webtek-devel] Inheritance hierarchies for Model objects > > > I have two types of User and they have significantly > different attributes. > > On the other hand, they have a number of attributes in common (e.g. > > username/passwords), the users can log in over the same > login form (so > usernames must be unique across both types > of user), etc. > > are the users in the same table, or two different tables for > each type? > > > Instinctively, the natural way to model this would be an > inheritance > hierarchy, i.e. > > > > * a "User" model class with the id, username, password attributes > > * "AdministratorUser" and "AdvisorUser" (from my > application) which > > extend "User" and have their further attributes > > The > "User" superclass would need to have some kind of > findByUsername method > which would return an instance of > one of the concrete classes, depending on > which type of > user was found. > > that sounds like an attribute in the usertable, role/is_admin > or something like that... > > > Is there any support for anything like this in WebTek? > > maybe not exactly that way? to say it more concretely, i need > more details... > > > > > (If not - no problem! - it's only a small application, so > I can easily use > another solution, such as placing all the > attributes in one single "User" > > class/table which covers both cases.) > > ahh.. > > you want a layout like: > > create table user(id, nickname, password, address); create > table admin_user(user_id, role); create table > advisor_user(user_id, advisor_number); > > is this korrekt? > > > -------------------------------------------------------------- > ----------- > This SF.net email is sponsored by: Microsoft Defy all > challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: Adrian S. <adr...@gm...> - 2008-05-23 15:50:20
|
In general, there are three wa > -----Original Message----- > From: web...@li... > [mailto:web...@li...] On Behalf > Of max demmelbauer > Sent: Friday, May 23, 2008 14:14 > To: web...@li... > Subject: Re: [Webtek-devel] Inheritance hierarchies for Model objects > > > I have two types of User and they have significantly > different attributes. > > On the other hand, they have a number of attributes in common (e.g. > > username/passwords), the users can log in over the same > login form (so > usernames must be unique across both types > of user), etc. > > are the users in the same table, or two different tables for > each type? > > > Instinctively, the natural way to model this would be an > inheritance > hierarchy, i.e. > > > > * a "User" model class with the id, username, password attributes > > * "AdministratorUser" and "AdvisorUser" (from my > application) which > > extend "User" and have their further attributes > > The > "User" superclass would need to have some kind of > findByUsername method > which would return an instance of > one of the concrete classes, depending on > which type of > user was found. > > that sounds like an attribute in the usertable, role/is_admin > or something like that... > > > Is there any support for anything like this in WebTek? > > maybe not exactly that way? to say it more concretely, i need > more details... > > > > > (If not - no problem! - it's only a small application, so > I can easily use > another solution, such as placing all the > attributes in one single "User" > > class/table which covers both cases.) > > ahh.. > > you want a layout like: > > create table user(id, nickname, password, address); create > table admin_user(user_id, role); create table > advisor_user(user_id, advisor_number); > > is this korrekt? > > > -------------------------------------------------------------- > ----------- > This SF.net email is sponsored by: Microsoft Defy all > challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: max d. <pro...@gm...> - 2008-05-23 12:56:11
|
> Is there any facility for supporting "Breadcrumbs", for example > > Root Page > All profiles > Profile 'x' > Edit Data > > I would imagine following features being necessary for a breadcrumbs system: > > * It would make sense to use the Parent concept already in WebTek to > build the breadcrumbs (as opposed to e.g. having the breadcrumb parent/child > relationship external in a config file or something) you have request->path, wich will return an array-ref with all pages in the current url. look at the _info action, here is such a navigation > * As "Edit Data"-type screens are implemented with WebTek actions, and > as they are represented by adding e.g. /edit onto the URL, it would also > make sense to add them to the breadcrumbs > * Obviously the breadcrumbs would be linked to the pages they > represent > * Breadcrumbs should be able to support data for example "Profile 'x'" > for the particular profile that's being viewed. > * Text localizable > * Maybe an obscure point, but I think it'd be cool if the last point, > e.g. "Edit Data" above, could be missed out. That way breadcrumbs would just > be ".... Profile 'x' >" and the actual text of "Edit Data" could be the main > heading of the page. yes you can define such things in macro-params > If there is no such system, then I would be happy to build such a system. > > * I imagine the best place would be in a "module" yep, i dont think about this, but thats pretty cool ;) > * For example exposing a new tag such as <% breadcrumbs %> which is > implemented by the Root page of the module correkt > * In order to follow the convention in WebTek that "templates are in > control" i.e. they suck the data out of the pages with macros (as opposed to > pages populating dumb templates by setting e.g. $-variables), I would create > a "breadcrumb.tpl" in each Page class. this is not necesarry, becaue i think all could done in the message- files (placed in messages/*.po) > * This could include a <% message %> for localization you can use the message-fkt direct in the macro > * Or any other attribute for example <% name %>. In the example above. > if the "ProfileView" page (for "Profile 'x'") uses a Profile model, and that > model has a "name" attribute. you can use all macros also in messages, when they are rendert threw the right page (which knows about the macros) > * Formatting done over CSS, i.e. not really a concern of the > breadcrumb system. Following "programming by convention", the CSS styles > would have fixed names e.g. "breadcrumbItem" which could be styled. yep, i think thats another macro-parameter maybe something like this Page/Root.pm sub breadcrumbs :Macro :Param(render a breadcrumbs navigation) :Param(separator=" , " optional, default = ' > ') :Param(class="...") { my ($self, %params) = @_; #... render path my @crumbs = map { $_->link( 'href' => $_->href, 'display' => $_->message('key' => ref($_) . "::index" ), 'class' => $params('class'); ); } @{request->path}; #... set separator my $sep = $params{'separator'} || ' > '; #... create navigation # FIXME make the last part optional # FIXME if request->action eq 'index' dont render the index-action twice return join $sep, ( @crumbs, $self->message('key' => ref($self) . "::" . request->action) ) } messages/en.po msgid "MyApp::Page::Root::index" nsgstr "Root Page" msgid "MyApp::Page::Profiles::index" nsgstr "All Profiles" msgid "MyApp::Page::Profile::index" nsgstr "Profile <% name %>" msgid "MyApp::Page::Profile::edit" nsgstr "Edit Data" |
From: max d. <pro...@gm...> - 2008-05-23 12:14:21
|
> I have two types of User and they have significantly different attributes. > On the other hand, they have a number of attributes in common (e.g. > username/passwords), the users can log in over the same login form (so > usernames must be unique across both types of user), etc. are the users in the same table, or two different tables for each type? > Instinctively, the natural way to model this would be an inheritance > hierarchy, i.e. > > * a "User" model class with the id, username, password attributes > * "AdministratorUser" and "AdvisorUser" (from my application) which > extend "User" and have their further attributes > > The "User" superclass would need to have some kind of findByUsername method > which would return an instance of one of the concrete classes, depending on > which type of user was found. that sounds like an attribute in the usertable, role/is_admin or something like that... > Is there any support for anything like this in WebTek? maybe not exactly that way? to say it more concretely, i need more details... > > (If not - no problem! - it's only a small application, so I can easily use > another solution, such as placing all the attributes in one single "User" > class/table which covers both cases.) ahh.. you want a layout like: create table user(id, nickname, password, address); create table admin_user(user_id, role); create table advisor_user(user_id, advisor_number); is this korrekt? |
From: max d. <pro...@gm...> - 2008-05-23 12:04:28
|
> The project I am intending to construct with WebTek has quite a few screens. > Is it possible to have some kind of hierarchy such as: > > MyApp::Page::Foo::Bar yep, thats possible, simple set the WebTek::Parent to the right Page and all will work > What about model classes? (Although in my app I only have 3-4 database > tables, so it's not really an issue.) that's also possible, but remember the tablename is the last part of the package-name MyApp::Model::User => tablename is user MyApp::Model::Admin::User => tablename is user if you want an different tablename define TABLE_NAME, e.g. in MyApp/ Model/Admin/User.pm use base qw( WebTek::Model ); sub TABLE_NAME { 'admin_user' } |
From: max d. <pro...@gm...> - 2008-05-23 11:21:05
|
> In the latest tutorial, you remember the logged-in user by setting a > variable on the session, using: > > session->user(request->user) > > What objects are involved here? I assume that: > > * The "request" has a special attribute which is the http-auth user > being submitted with the http request? And that that's a string? correct > * The "session" is able to store only scalar/string attributes. > Looking at the table definition of "session", that would seem to be the > case. no, the session can hold every perl object also, because the session- data is serialized to text using Storable.pm and Base64 > Assuming that one is implementing an authorization system based on Users who > are stored in the database, and not using HTTP authentication, should one > > * set e.g. the user_id in the session, or > * set the whole user object as a session attribute, and the session > persistence system takes care of extracitng the user_id from the user > object? simply set the user-obj. but dont forget to clean the session-table if the prototype of the user-object has changed (i.e. a table-column added/deleted..) |