I am working with perl Catalyst. I created Model and Schema for a database with model name MyDBI.pm and schema for that are created in SchemaClass/Result directory. Now I have added a new table in my database. Now I need to create a Schema for that table only. The following command I am using for creating Schema
perl script/my_create.pl model MyDBI DBIC::Schema
My::SchemaClass::Result::Tablename create=dynamic
components=TimeStamp 'dbi:Pg:dbname=mydb' username 123 '{ AutoCommit => 1}'
But it creating MyDBI.pm again as MyDBI.pm.new. So how can I create without creating that MyDBI.pm.
Thanks In Advance....
As long as you edit the classes under Schema/Result/.pm classes only under the marked line, there is no problem it re-creates it? That way you know your model is always up-to-date.
The class in models (MyDBI.pm) only contains the connection info, right?
In the Schema classes, you find the line marked by something like this:
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+ZwJisOqZAkKLq170l/CNA
It is much more common and in my opinion much cleaner to add Schema classes not directly into Result.pm, which will get cluttered,
but to the Schema/Result/ directory, for example
..../Schema/Result/New.pm -> Schema::Result::New
Then use base qw/DBIx::Class::Core/; in the package and all is set to be used normally.
Catalyst will discover those and set them up for you automatically.
Related
I started this Turial, Here
And get this error
**mongoengine.errors.NotRegistered:** `Comment` has not been registered in the document registry. Importing the document class automatically registers it, has it been imported?
any idea.
Thank you So much.
Just place the Comment Model above the Post Model, since the Comment Model is being referenced in the Post Model
First register all your models some where like __init__.py file in your models package.
Then you can use get_document('Comment') function (which is imported from mongoengine.base.common) instead of importing your models in each other scripts to avoid circular imports and exceptions like mongoengine.errors.NotRegistered
In SugarCRM, you can create your custom modules (e.g. MyModule) and they are kept in /modules just like stock objects, with any default metadata, views, language files, etc. For a custom module MyModule, you might have something like:
/modules/MyModule/MyModule.class.php
/modules/MyModule/MyModule.php
/modules/MyModule/language/
/modules/MyModule/metadata
And so on, so that everything is nicely defined and all the modules are kept together. The module becomes registered with the system by a file such as /custom/Extension/application/Include/MyModule.php with contents something like:
<?php
$beanList['MyModule'] = 'MyModule';
$beanFiles['MyModule'] = 'modules/MyModule/MyModule.php';
$moduleList[] = 'MyModule';
Obviously, the $beanFiles array references where we can find the base module's class, usually an extension of the SugarBean object. Recently I was advised that we can adjust that file's location for the sake of customization, and it makes sense to a degree. Setting it like $beanFiles['MyModule'] = 'custom/modules/MyModule/MyModule.php'; would allow us to access the base class via Module Loader even if the security scan tool prevents core file changes, and this would also allow us to not exactly extend, but replace stock modules like Accounts or Calls, without modifying core files and having system upgrades to wipe out the changes.
So here's my question: what is the best practice here? I've been working with SugarCRM pretty intensely for several years and this is the first time I've ever been tempted to modify the $beanFiles array. My concern is that I'm deviating from best practice here, and also that somehow both files modules/MyModule/MyModule.php and custom/modules/MyModule/MyModule.php could be loaded which would cause a class name conflict in PHP (i.e. because both classes are named MyModule...). Obviously, any references to the class would need to be updated (e.g. an entryPoint that works with this module), but am I missing any potential ramifications?
Technically it should be fine, but I can see how it could be possible that both the core version and your version could conflict if both are referenced. It all depends on the scenario, but I prefer to extend the core bean and find somewhere in the stack where I can have my custom version used in place of the core bean. I wrote up an example a couple of years ago here: https://www.sugaroutfitters.com/blog/safely-customizing-a-core-bean-in-sugarcrm
For most use-cases, there's a way to hijack Sugar to use your bean at a given point.
If you can't get around it you can always grep to see where the core module is explicitly being included to ensure that there won't be conflict down the road.
In Catalyst development, there are so many modulers. When I run the command as follows, I get the error
No tables found, did you forget to specify db_schema
script/addressbook_create.pl model AddressDB DBIC::Schema AddressBook::Schema::AddressDB create=static dbi:SQLite:/tmp/database
I am reading the book--Catalyst 5.8 the perl MVC framework
My questions:
How to solve this problem?
What can I get some helper from perldoc or something else? The doc is much more, and dependencies about modulers is so difficult. What's the key?
The second reference to AddressDB in your create command there is probably putting the files in a subdirectory below where they should be, ie lib/AddressBook/Schema/AddressBook/Result/People.pm. Have a look at your directory structure and compare it to p141 of the book.
I'd suggest you clean that up, and try:
script/addressbook_create.pl model AddressDB DBIC::Schema AddressBook::Schema \
create=static dbi:SQLite:/tmp/database
As my database was designed using german table- and column names, the default pluralisation feature of entity framework doesn't work for me.
I have found a couple of resources where this is discussed, but none of them seem to work.
What i have found:
There is the PluralisationService where i can add the mappings:
PluralizationService pluralizer =
PluralizationService.CreateService(CultureInfo.GetCultureInfo("en-us"));
ICustomPluralizationMapping mapping = ps as ICustomPluralizationMapping;
mapping.AddWord("Tabelle", "Tabellen");
But what's next?
I have tried to:
EntityModelSchemaGenerator generator = new EntityModelSchemaGenerator(container);
generator.PluralizationService = pluralizer;
generator.GenerateMetadata();
and put both of them in my POCO T4 Template. But it throwed the following exception:
The EntityContainer 'ContainerName' is not a store EntityContainer. Parameter name: storeEntityContainer
at System.Data.Entity.Design.EntityModelSchemaGenerator.Initialize(...)
at Microsoft.VisualStudio.TextTemplating...GeneratedTextTransformation.TransformText()
To completely customize the table names in EF Code First, you can use the Table attribute to explicitly specify the name of the table associated with a class:
[Table("InternalBlogs")]
public class Blog
{
//...
}
I'm also looking for the same thing. Maybe this can help. I'm just not willing to pay for such a basic feature.
EDIT:
The code you posted is to be used with EdmGen2 wich will give you CSDL, SSDL or MSL files pluralized according to your class.
A very old question, but if someone is still looking for a possible workflow/solution:
I had a similar problem where I wanted to customize the schema import (CSDL) from the database. The solution / workflow was as follows:
Deployed the database schema (I used Visual Studio Database Project VS 201x) to a
local database
Imported the database model using EDMGEN to create the CSDL, SSDL and MSDL files
http://msdn.microsoft.com/en-us/library/vstudio/bb387165(v=vs.110).aspx
Modified EDMGEN2 with my changes on how to handle pluralization and naming with custom rules and created EDMX file
Ran the T4 templates (with additional customization as needed) to create
output.
When I use catalyst.pl to auto-generate my application, the AUTHOR section of the POD includes only my name like this.
Kiffin Gish,,,
What are the missing fields and how can I use them? Is it possible to use another boilerplate for the PODs?
It's using the GECOS field from your line in the passwd file (courtesy of getpwuid). You can change the author name that shows up by setting the AUTHOR environment variable, although this doesn't seem documented. As for overriding the entire thing: not so much, unless you want to write your own catalyst.pl that uses a custom subclass of Catalyst::Helper, or submit the patch to -Runtime to let everyone do that.:)