I have a question regarding the file loading system from Cakephp2.3.
I have two plugins - let's call them "Contacts" and "Managers", loaded like this:
CakePlugin::load('Contacts');
CakePlugin::load('Managers');
Each of them has a controller called "DashboardController.php" with an index() action.
When I try to access the dashboard page for "Contacts", sometimes I see the following error:
Error: Class "ManagersAppController" not found
even though the url looks like this:
http://mysite.com/contacts/dashboard
I read that Cakephp2.3 doesn't support namespaces and this might happen because I have two php classes (DashboardController.php) with the same name. At the same time, I know that Cake should map the plugin name first, so it should be able to handle duplicate file names.
Do you have any idea why I'm seeing this random error?
Thanks for your help.
I just found the answer from the guys the developed CakePHP. Indeed, you can't have two controllers or models with the same name, even though they are located in different plugins.
This happens only in CakePHP2.x and I quote:
This is a known limitation of Cake2.x and the lazy loading approach
using App::uses()
You can see my question and their answer here: http://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/3558-loading-file-from-a-different-plugin
The solution is to rename the controllers/models with conflicting names and/or name all controllers and models from a plugin using the plugin name (ex. DashboardController.php will become ContactsDashboardController.php)
Related
I'm programming my fist SwiftApp got stuck setting up Core data. Since I'm integrating it into existing code I can't have Xcode set it up on Prohect init anymore. Furthermore I als want to understand what the lines of code actually do. Since all Core libraries are secret I am stuck with Apple's Docs which are not very clear on the matter.
Pfew... with that out of the way here is the question; What is the significance of the name passed to...
let container = NSPersistentContainer(name: "Core_Data")
...in the App Delegate file. I had set it up before but during compilation Xcode complained that it could not find the specified Name's module. Changing it to my project's name, the core data file I had created or the name of the Database passed to the menu when adding a Core Data file did not seem to help at all. Searching the web and a few tutorials people just fly over it and it is still very much unclear to me.
Any help would be much appreciated!
The string passed there is used for two things. If you were to pass the string Foo, Core Data would attempt:
To find the data model by looking for Foo.xcdatamodel or Foo.xcdatamodeld.
To find (or create) the persistent store, using the name Foo.sqlite.
Even an incorrect string value (i.e. one that doesn't match the name of your data model) should not cause a compilation error. It might cause an error at run time if iOS can't find the named data model.
I need to implement a custom ResultHandler but I am confused about how to actually integrate my custom class into the software package.
I have read this: http://elki.dbs.ifi.lmu.de/wiki/HowTo/InvokingELKIFromJava but my question is how are you meant to implement a custom result handler such that it shows up in the GUI?
The only way I can think of doing it is by extracting the elki.jar package and manually inserting my custom class into the source code, and then re-jarring the package. However I am fairly sure this is not the way it is meant to be done.
Also, in my resulthandler I need to output all the rows to a single text file with the cluster that each row belongs to displayed. How tips on how I can achieve this?
There are two questions in here.
in order to make your class instantiable by the UIs (both MiniGUI and command line), the classes must implement our Parameterization API. There are essentially two choices to make your class instantiable:
Add a public constructor without parameters (the UI won't know how to set your parameters!)
Add an inner static class Parameterizer that handles parameterization
in order to add your class to autocompletion (dropdown menu), the classes must be discovered by the MiniGUI/CLI/other UIs. ELKI uses two methods of discovery:
for .jar files, it reads the META-INF/elki/interfacename service files. This is a classic service-loader approach; except that we also allow ordering instances.
for directories only, ELKI will also scan for all .class files, and inspect them. This is mostly meant for development time, to avoid having to update the service files all the time. For performance reasons, we do not inspect the contents of .jar files; these are expected to use service files.
You do not need your class to be in the dropdown menu - you can always type the full class name. If this does not work, adding the name to the service file will not help either, but ELKI can either not find the class at all, or cannot instantiate it.
There is also a tutorial on implementing a custom result handler, but it does not discuss how to add it to the menu. In "development mode" - when having a folder with .class files - it will show up automatically.
I'm trying to solve possibly simple problem, in my 'views' directory, in typical Play framework setup, I would like to group my templates (*.scala.html files) into groups, possibly using another folder for each group, eg. I would like to have customers folder with the following files in it:
createForm.scala.html
editForm.scala.html
list.scala.html
So far so good but when I try to access that view reference from my controller (eg. Ok(views.html.list(..)) -> Ok(views.customers.html.list(...)), I get an error:
object customers is not a member of package views
Is there any best practice/receipe on how to work with multiple views, how to gather them into groups and then how to use them in other views or controllers.
Thx in advance.
The way the template engine works is that a template defined as:
/views/application/index.scala.html
Will be turned into a class:
views.html.application.index
So basically views.html is always kept as a prefix. Cf. the Play template documentation.
In your case that means it should be
Ok(views.html.customers.list(...))
If you have a closer look at the target directory, you'll see how views are compiled and the packages are made:
Ok(views.html.group.view())
You can also import like this:
#import views.html.group._
//...
Ok(view())
After migrating to Play-2.1 I stuck into problem that routes compiler stopped working for my routes file. It's been completely fine with Play-2.0.4, but now I'm getting the build error and can't find any workaround for it.
In my project I'm using cake pattern, so controller actions are visible not through <package>.<controller class>.<action>, but through <package>.<component registry>.<controller instance>.<action>. New Play routes compiler is using all action path components except for the last two to form package name that will be used in managed sources (as far as I can get code in https://github.com/playframework/Play20/blob/2.1.0/framework/src/routes-compiler/src/main/scala/play/router/RoutesCompiler.scala). In my case it leads to situation when <package>.<component registry> is chosen as package name, which results in error during build:
[error] server/target/scala-2.10/src_managed/main/com/grumpycats/mmmtg/componentsRegistry/routes.java:5: componentsRegistry is already defined as object componentsRegistry
[error] package com.grumpycats.mmmtg.componentsRegistry;
I made the sample project to demonstrate this problem: https://github.com/rmihael/play-2.1-routes-problem
Is it possible to workaround this problem somehow without dropping cake pattern for controllers? It's the pity that I can't proceed with Play 2.1 due to this problem.
Because of reputation I can not create a comment.
The convention is that classes and objects start with upper case. This convention is applied to pattern matching as well. Looking at a string there seems to be no difference between a package object and normal object (appart from the case). I am not sure how Play 2.1 handles things, that's why this is not an answer but a comment.
You could try the new # syntax in the router. That allows you to create an instance from the Global class. You would still specify <package>.<controller class>.<action>, but in the Global you get it from somewhere else (for example a component registry).
You can find a bit of extra information here under the 'Managed Controller classes instantiation': http://www.playframework.com/documentation/2.1.0/Highlights
This demo project shows it's usage: https://github.com/guillaumebort/play20-spring-demo
Sorry if this sounds stupid but I'm really new to LiftWeb and just struggling with the basic stuff:)
So I have a parametrized site map entry in Lift's bootstrap. This should be for the view page of an object of type MyItem. The URL would be like: "/myitems/UUID".
Menu.param [UUID]("MyItemView", "MyItemView", p=>Full(UUID.fromString(p)), p=>p.toString) / "myitems"
This adds the sitemap entry correctly. If I go to "/myitems/NOT_AN_UUID", it will throw the "Invalid UUID" exception as expected. But if I go to "/myitems/UUID" I get 404.
I know that I need a view and a snippet class that takes UUID as parameter in order for this to work but I have no idea how to name these and where to place them.
Btw, how would one new to Lift learn something like this? From the hundreds of articles and samples out there I found many to mention more complex stuff but haven't seen any to mention a basic thing like this. Do you know any secret start-up documentation for human beings?
Update: To summarize in case all you see above is jibber-jabber :) HOW DOES LIFT LOCATE TEMPLATES/VIEWS/SNIPPETS FOR PARAMETRIZED MENU ENTRIES?
It was actually the obvious answer. The template name is obtained from the path and the snippet can be whatever you want as long as you call it from the template xml.
I need to get used to all this convention over configuration :) However it would be nice for someone to tell you what is the convention.